react / react/react-native

[iOS] RCTLogBoxView crashes on dealloc when app uses SceneDelegate because it still assumes AppDelegate.window exists

Offen
#56,571 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Debugging Needs: Attention Needs: Repro Platform: iOS
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
  1. Create a React Native app on iOS
  2. Adopt SceneDelegate / UIScene lifecycle
  3. Ensure the app delegate does not expose a window property
  4. Trigger LogBox presentation and dismissal / teardown in development
  5. 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

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Ö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

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.