Android app crashed when navigating from react fragment to native fragment
See original GitHub issueDescription
I have a closed repository in which I integrate React Native with Android Native. I put the react native component inside a fragment and use it for a bottom tab navigation screen. The bottom tab was made in native. So whenever I try to navigate after the react fragment is loaded, the app will crash. Navigation between tabs aside from the one with react fragment works fine.
I also put a react native screen in another place, not in a fragment because it’s not connected directly to the bottom tab navigation. That screen works fine and doesn’t cause any crash. So I assume the problem is within the fragment. I’m not too familiar with native android development so I was having a difficulty in this.
Steps To Reproduce
- The Main screen which has bottom tab navigation with react fragment on one of its tab
- Navigate to the tab with react fragment and load the rn component
- Click on other tabs, the app crashed
Expected behavior
Other native fragment will show according to clicked the bottom tab
Actual behavior
App crashed (only if the rn screen is loaded and navigate to other tab) Here’s the error
E/AndroidRuntime: FATAL EXCEPTION: main
Process: java.lang.IllegalStateException: FragmentManager is already executing transactions
at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java:1778)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1814)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:303)
at com.swmansion.rnscreens.ScreenContainer.removeMyFragments(ScreenContainer.kt:219)
at com.swmansion.rnscreens.ScreenContainer.onDetachedFromWindow(ScreenContainer.kt:231)
at com.swmansion.rnscreens.ScreenStack.onDetachedFromWindow(ScreenStack.kt:81)
at android.view.View.dispatchDetachedFromWindow(View.java:19607)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3814)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3806)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5431)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5402)
at android.view.ViewGroup.removeView(ViewGroup.java:5333)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1250)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:442)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2169)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1992)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1947)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Package versions
- React: 17.0.1
- React Native: 0.64.0
- React Native Screens: 3.7.2
- React Navigation: 6.0.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)

Top Related StackOverflow Question
@WoLewicki Thank you for checking! I thought since it just happens when using NativeStackNavigator from react-navigation, and the crash happening when navigating back, it might come from the same cause.
Could it be related to this bug? https://github.com/callstack/react-native-pager-view/issues/440 It only happens when using NativeStackNavigator, so I´m thinking it might be a react-native-screen issue. The error message is different though.