react-native-screens
react-native-screens copied to clipboard
Android couldn't found for fragment (Fabric only)
Description
Hello,
I have experienced an app crash while navigating between bottom tabs multiple times. I have attached the stacktrace and a repro example for reference. The issue may be related to https://github.com/react-navigation/react-navigation/issues/11165. Please take a look and let me know if you could advise.
Thank you.
java.lang.IllegalArgumentException: No view found for id 0x646 (unknown) for fragment ScreenFragment{34a3771} (f38da73b-6497-4306-a70a-402ae94cea5f id=0x646)
FATAL EXCEPTION: main
Process: com.app, PID: 5488
java.lang.IllegalArgumentException: No view found for id 0x646 (unknown) for fragment ScreenFragment{34a3771} (f38da73b-6497-4306-a70a-402ae94cea5f id=0x646)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:513)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1764)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1670)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:323)
**at com.swmansion.rnscreens.ScreenContainer.onUpdate(ScreenContainer.kt:366)**
at com.swmansion.rnscreens.ScreenContainer.performUpdates(ScreenContainer.kt:311)
at com.swmansion.rnscreens.ScreenContainer.performUpdatesNow(ScreenContainer.kt:303)
at com.swmansion.rnscreens.ScreenContainer.setFragmentManager(ScreenContainer.kt:127)
at com.swmansion.rnscreens.ScreenContainer.setupFragmentManager(ScreenContainer.kt:180)
at com.swmansion.rnscreens.ScreenContainer.onAttachedToWindow(ScreenContainer.kt:217)
at android.view.View.dispatchAttachedToWindow(View.java:20107)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3619)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3626)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3626)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3626)
at android.view.ViewGroup.addViewInner(ViewGroup.java:5404)
at android.view.ViewGroup.addView(ViewGroup.java:5190)
at android.view.ViewGroup.addView(ViewGroup.java:5130)
at androidx.fragment.app.FragmentStateManager.addViewToContainer(FragmentStateManager.java:839)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:528)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1764)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1670)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:323)
at com.swmansion.rnscreens.ScreenContainer.onUpdate(ScreenContainer.kt:366)
at com.swmansion.rnscreens.ScreenContainer.performUpdates(ScreenContainer.kt:311)
at com.swmansion.rnscreens.ScreenContainer.performUpdatesNow(ScreenContainer.kt:303)
at com.swmansion.rnscreens.ScreenContainer.notifyChildUpdate(ScreenContainer.kt:87)
at com.swmansion.rnscreens.Screen.setActivityState(Screen.kt:132)
at com.swmansion.rnscreens.ScreenViewManager.setActivityState(ScreenViewManager.kt:49)
at com.swmansion.rnscreens.ScreenViewManager.setActivityState(ScreenViewManager.kt:34)
at com.swmansion.rnscreens.ScreenViewManager.setActivityState(ScreenViewManager.kt:21)
at com.facebook.react.viewmanagers.RNSScreenManagerDelegate.setProperty(RNSScreenManagerDelegate.java:81)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:46)
at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:84)
at com.facebook.react.views.view.ReactViewManagerWrapper$DefaultViewManager.updateProperties(ReactViewManagerWrapper.kt:59)
at com.facebook.react.fabric.mounting.SurfaceMountingManager.updateProps(SurfaceMountingManager.java:872)
at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.java:153)
at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.java:351)
at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.java:274)
at com.facebook.react.fabric.mounting.MountItemDispatcher.tryDispatchMountItems(MountItemDispatcher.java:120)
at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1245)
at com.facebook.react.fabric.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1278)
at android.view.Choreographer.doCallbacks(Choreographer.java:1019)
at android.view.Choreographer.lambda$new$0$Choreographer(Choreographer.java:235)
at android.view.-$$Lambda$Choreographer$zXV0PrqwmpdPajenUBozqc6c8Hs.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Steps to reproduce
- Run android react-native run-android
- Switch tabs multiple times
Snack or a link to a repository
https://github.com/Bort-777/react-native-screens-tabs-repro
Screens version
3.20.0
React Native version
0.71.6
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Fabric (New Architecture)
Build type
Debug mode
Device
Android emulator
Device model
No response
Acknowledgements
Yes
As a temporary workaround (?),
set detachInactiveScreens={false}
for StackNavigator https://reactnavigation.org/docs/stack-navigator/#detachinactivescreens
to prevent this error.
Same issue!
Is there any update for this issue? I have this exact problem
detachInactiveScreens={false} is work
This crash occurs on enable Fabric.
Add this line in your Navigator and fix the problem.
detachInactiveScreens={false}