[iOS] RCTLogBoxView crashes on dealloc when app uses SceneDelegate because it still assumes AppDelegate.window exists
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C++
- Sterne
- 127k
- Forks
- 25.3k
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 4
Beschreibung
Description
When using a SceneDelegate-based iOS app lifecycle, React Native crashes in RCTLogBoxView during deallocation because it still accesses RCTSharedApplication().delegate.window.
The following code in RCTLogBoxView is problematic:
- (void)dealloc
{
#if !TARGET_OS_MACCATALYST // sharedApplication.delegate is not available on Mac Catalyst
[RCTSharedApplication().delegate.window makeKeyWindow];
#endif
}
In a SceneDelegate setup, the app’s main window is typically owned by the active UIWindowScene, not exposed as AppDelegate.window. As a result, this code can crash with an unrecognized selector / invalid access depending on how the app delegate is implemented.
This looks like the same broader class of SceneDelegate compatibility issues as other places in React Native that still assume application.delegate.window exists.
Steps to reproduce
- Create a React Native app on iOS
- Adopt SceneDelegate / UIScene lifecycle
- Ensure the app delegate does not expose a window property
- Trigger LogBox presentation and dismissal / teardown in development
- Observe crash when RCTLogBoxView is deallocated
React Native Version
0.83.0
Output of npx @react-native-community/cli info
npx @react-native-community/cli info
Screenshots and Videos
RCTLogBoxView
- (void)dealloc
{
#if !TARGET_OS_MACCATALYST
[RCTSharedApplication().delegate.window makeKeyWindow];
#endif
}
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, RCTLogBoxView zu lokalisieren und seine dealloc-Implementierung zu lesen, insbesondere den Zugriff auf RCTSharedApplication().delegate.window. Bilde den Teardown-Ablauf mit einer auf SceneDelegate basierenden App nach und überprüfe anschließend, dass das Schließen und die Deallokierung von LogBox nicht mehr abstürzen, während das bestehende Verhalten intakt bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ios, objective-c, react-native
- Bereich
- mobile-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 58/100