react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

UIViewControllerHierarchyInconsistency crash when RCT_NEW_ARCH_ENABLED=1 on iOS

Open mpawar-ep-910 opened this issue 3 months ago • 8 comments

Description

When running a React Native app with New Architecture enabled (RCT_NEW_ARCH_ENABLED=1), the app crashes on iOS with the following error:

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<RNSViewController: 0x10737c1d0> should have parent view controller:(null) but actual parent is:<RNSScreen: 0x10988a400>'

This issue does not occur when running with Old Architecture (RCT_NEW_ARCH_ENABLED=0).

Crash Log (truncated):

*** First throw call stack: ( 0 CoreFoundation __exceptionPreprocess + 172 1 libobjc.A.dylib objc_exception_throw + 72 2 UIKitCore -[UIView(Hierarchy) _associatedViewControllerForwardsAppearanceCallbacks...] 3 UIKitCore -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] 4 UIKitCore -[UIView(Internal) _addSubview:positioned:relativeTo:] ... libc++abi: terminating due to uncaught exception of type NSException )

Steps to reproduce

Create a new React Native project or upgrade to RN 0.77.0.

Install the following dependencies:

"react-native": "0.77.0", "react-native-screens": "4.5.0", "react-native-gesture-handler": "2.22.1", "react-native-reanimated": "3.18.0", "expo": "52.0.0"

Enable New Architecture by setting RCT_NEW_ARCH_ENABLED=1.

Run the iOS app.

Observe crash during navigation transitions.

Snack or a link to a repository

None

Screens version

4.5.0

React Native version

0.77.0

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

Debug mode

Device

iOS simulator

Device model

iPhone 16 Pro

Acknowledgements

Yes

mpawar-ep-910 avatar Sep 20 '25 06:09 mpawar-ep-910

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Sep 20 '25 06:09 github-actions[bot]

@kkafar @kligarski @mfazekas @ckknight @Minishlink Can any one help on this.

mpawar-ep-910 avatar Sep 20 '25 07:09 mpawar-ep-910

Hey @mpawar-ep-910!

We'll be happy to help, but:

  1. the report does not contain reproduction,
  2. the report does not contain steps to reproduce the issue,
  3. the stack trace is for some reason truncated and brings no suggestions where in the library code the crash happened,
  4. first thing to do is to update library version; 4.5.0 was released over 8 months ago and there is a chance the crash was mitigated in later version (small chances here, I do not recall this particular crash).

When upgrading please take into consideration the compatibility table and follow the upgrade helper.

We won't be able to help in any other way unless we are able to reproduce the issue on our end. Can you provide us with more information?

kkafar avatar Sep 21 '25 19:09 kkafar

@kkafar There are no specific steps; once the app launches, it immediately throws this error.

running only yarn ios command only

mpawar-ep-910 avatar Sep 22 '25 16:09 mpawar-ep-910

I'm sorry, but we do not observe the error on our end.

Unless you provide us with information I've mentioned above, we won't be able to help much.

kkafar avatar Sep 22 '25 18:09 kkafar

I get the same, it seems to only appear if using an expo application on iOS and pressing R on the console to reload the application. Once it reloads it seems to throw this error and cause a crash.

I'll see if I can create a minimal reproducible scenario to assist.

I'm currently reproducing on an iPhone 15 Pro

ghost1face avatar Sep 25 '25 12:09 ghost1face

Thanks for the information @ghost1face! 🤞🏻 you manage to reproduce it!

kkafar avatar Sep 25 '25 13:09 kkafar

Facing the same crash when launching the iOS app. "react-native": "0.82.1", "react-native-screens": "^4.18.0",

scrapecoder avatar Nov 27 '25 10:11 scrapecoder