Skip to content

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

Open

Description

@zhfwch

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

}

Activity

  1. added
    DebuggingIssues related to React Native DevTools or legacy JavaScript/Hermes debugging
    on Apr 23, 2026
  2. react-native-bot commented on Apr 23, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  3. zhfwch commented on Apr 28, 2026

    @zhfwch
    Author

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:

    You can read more about about it on our website: How to report a bug.
    A reproducer should not be necessary here, because the root cause of the crash is already clear.

    The crash happens in RCTLogBoxView’s dealloc method:

    [RCTSharedApplication().delegate.window makeKeyWindow];
    

    This assumes that UIApplication.sharedApplication.delegate.window is always available. However, in apps using SceneDelegate, the app delegate may not own a window, so delegate.window can be nil or invalid.

    The implementation should not rely on sharedApplication.delegate.window. It should instead obtain the appropriate window from the active UIWindowScene, or avoid calling makeKeyWindow from dealloc altogether.

    A possible concise version:

    No reproducer is needed in this case. The root cause is clear: RCTLogBoxView assumes UIApplication.sharedApplication.delegate.window exists, but this is not true for apps using SceneDelegate. This can cause a crash when dealloc calls makeKeyWindow on delegate.window.

  4. react-native-bot commented on Oct 25, 2026

    @react-native-bot
    Collaborator

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  5. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    and removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebuggingIssues related to React Native DevTools or legacy JavaScript/Hermes debuggingNeeds: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.Platform: iOSiOS applications.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions