react / react/react-native

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

Open
#56,571 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Debugging Needs: Attention Needs: Repro Platform: iOS
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

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

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating RCTLogBoxView and reading its dealloc implementation, especially the RCTSharedApplication().delegate.window access. Reproduce the teardown flow with a SceneDelegate-based app, then verify that LogBox dismissal and deallocation no longer crash while the existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.