Skip to content

Crash in interfaceOrientationDidChange when using SceneDelegate (Xcode 26) #53602

Description

@TeunVR

Description

When using Xcode 26 a warning is shown that UIScene lifecycle must be supported:
UIScene lifecycle will soon be required. Failure to adopt will result in an assert in the future.

I added a SceneDelegate that uses the RCTReactNativeFactory to start React Native.
However there are parts in React Native that still expect a window property on the AppDelegate.

For example in RCTDeviceInfo.interfaceOrientationDidChange:
BOOL isRunningInFullScreen = CGRectEqualToRect(application.delegate.window.frame, application.delegate.window.screen.bounds);

Steps to reproduce

Note: Use Xcode 26.

  1. Launch the reproducer app on ios simulator or device
  2. Press home button to background the app
  3. Rotate the device
  4. Foreground the app again: crash

React Native Version

0.81.1

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

info Fetching system and libraries information...
System:
  OS: macOS 15.6.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 209.25 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.7.0
    path: ~/.nvm/versions/node/v24.7.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/Documents/development/ReactNativeSceneDelegate/ReproducerApp/node_modules/.bin/yarn
  npm:
    version: 11.5.1
    path: ~/.nvm/versions/node/v24.7.0/bin/npm
  Watchman:
    version: 2024.11.25.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/lib/ruby/gems/3.3.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.0
      - iOS 26.0
      - macOS 26.0
      - tvOS 26.0
      - visionOS 26.0
      - watchOS 26.0
  Android SDK:
    API Levels:
      - "26"
      - "27"
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 28.0.3
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-28 | Google ARM64-V8a Play ARM 64 v8a
      - android-29 | Google Play ARM 64 v8a
      - android-30 | Google Play ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
      - android-35 | Google Play Tablet ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 26.0/17A5305k
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.3.5
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.1
    wanted: 0.81.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ReproducerApp.AppDelegate window]: unrecognized selector sent to instance 0x60000000c7b0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001804f39e8 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018009c084 objc_exception_throw + 72
	2   CoreFoundation                      0x00000001805092a8 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
	3   UIKitCore                           0x000000018628a264 -[UIResponder doesNotRecognizeSelector:] + 232
	4   CoreFoundation                      0x00000001804f7b28 ___forwarding___ + 796
	5   CoreFoundation                      0x00000001804fa1fc _CF_forwarding_prep_0 + 92
	6   ReproducerApp.debug.dylib           0x000000010616352c -[RCTDeviceInfo interfaceOrientationDidChange] + 200
	7   CoreFoundation                      0x00000001804171c4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 140
	8   CoreFoundation                      0x00000001804170e8 ___CFXRegistrationPost_block_invoke + 88
	9   CoreFoundation                      0x00000001804165d0 _CFXRegistrationPost + 404
	10  CoreFoundation                      0x0000000180415fbc _CFXNotificationPost + 696
	11  Foundation                          0x00000001810a30ec -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
	12  UIKitCore                           0x0000000186258f10 -[UIApplication _stopDeactivatingForReason:] + 1336
	13  UIKitCore                           0x000000018580b9f8 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 260
	14  UIKitCore                           0x000000018580bc98 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 576
	15  UIKitCore                           0x000000018580b6b0 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 240
	16  UIKitCore                           0x00000001858175cc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_blo	17  UIKitCore                           0x0000000185cb7c50 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 656
	18  UIKitCore                           0x0000000185de5cec _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 196
	19  UIKitCore                           0x00000001858172d8 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 288
	20  UIKitCore                           0x000000018563a0e4 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.190 + 612
	21  UIKitCore                           0x0000000185638e84 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 200
	22  UIKitCore                           0x0000000185639d64 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
	23  UIKitCore                           0x0000000185ce35f8 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 308
	24  FrontBoardServices                  0x00000001884f0860 __76-[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.99 + 328
	25  FrontBoardServices                  0x00000001884ef5f4 -[FBSScene _callOutQueue_maybeCoalesceClientSettingsUpdates:] + 116
	26  FrontBoardServices                  0x00000001884f054c -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 656
	27  FrontBoardServices                  0x000000018855d854 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2.cold.1 + 328
	28  FrontBoardServices                  0x000000018851d61c __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 92
	29  FrontBoardServices                  0x00000001884fc864 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160
	30  libdispatch.dylib                   0x00000001039659dc _dispatch_client_callout + 12
	31  libdispatch.dylib                   0x000000010394fe80 _dispatch_block_invoke_direct + 388
	32  BoardServices                       0x0000000187f6c73c __BSSERVICEMAINRUNLOOPQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 44
	33  BoardServices                       0x0000000187f6b76c BSServiceMainRunLoopSourceHandler + 180
	34  CoreFoundation                      0x000000018044d4dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
	35  CoreFoundation                      0x000000018044d424 __CFRunLoopDoSource0 + 168
	36  CoreFoundation                      0x000000018044cbb0 __CFRunLoopDoSources0 + 220
	37  CoreFoundation                      0x000000018044bd84 __CFRunLoopRun + 760
	38  CoreFoundation                      0x0000000180446e24 _CFRunLoopRunSpecificWithOptions + 496
	39  GraphicsServices                    0x00000001925299bc GSEventRunModal + 116
	40  UIKitCore                           0x000000018625d94c -[UIApplication _run] + 772
	41  UIKitCore                           0x0000000186261b74 UIApplicationMain + 124
	42  UIKitCore                           0x00000001854da044 block_destroy_helper.15 + 5120
	43  ReproducerApp.debug.dylib           0x0000000105fbe2d8 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128
	44  ReproducerApp.debug.dylib           0x0000000105fbe248 $s13ReproducerApp0B8DelegateC5$mainyyFZ + 44
	45  ReproducerApp.debug.dylib           0x0000000105fbe354 __debug_main_executable_dylib_entry_point + 28
	46  dyld                                0x0000000102e353d0 start_sim + 20
	47  ???                                 0x0000000103166b98 0x0 + 4346768280
)
libc++abi: terminating due to uncaught exception of type NSException

MANDATORY Reproducer

https://github.com/athombv/ReactNativeSceneDelegate

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions