-
-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Android - Crash): FragmentManager is already executing transactions #1506
Comments
I've been further investigating this and found something that could help shine some light on the crash:
All is fine, there's no crash. However, if we have something like:
Then the crash happens. My guess is that this |
same here. how to sloved? |
Since the pending transaction is the reason, I patched a few lines and the error has seems to resolved in your example project. react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt Lines 215 to 217 in 07a92e9
if (hasFragments) {
transaction.commitAllowingStateLoss() //transaction.commitNowAllowingStateLoss()
} react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt Lines 227 to 230 in 07a92e9
if (!it.isDestroyed) {
removeMyFragments(it)
//it.executePendingTransactions()
} But I could not make a pull request cause I did n't dig deep the codes yet.. :/ |
@nvu I did try something similar and is true that doesn't crash but the problem is that the views are not getting updated ie. you can navigate back and forth and because we are not executing changes the views start disappearing. |
Hi @nvu @luislukas! Would you mind checking these changes out and letting me know whether it works for you? You can put following line in your
|
@kkafar thanks for looking into this. Looks like is working so far and can't reproduce the crash, so this is really great news!. I'll get the changes to a full round of tests with more people and automated tests in place. Thanks again! |
@luislukas @kkafar Thanks, bros !! |
now this version cannot be installed by yarn and why |
Hi @lvst09,
temporarily - until we release version 3.16 (coming soon) |
yes it works thank u |
@kkafar Is this issue fixed, from what i understand by release notes, in v3.17.0, this fix was reverted |
Hi @cw-sanjeev, Do you still see this error (on recent versions of |
I'm facing this issue in the production in the 3.18.2th version. |
@rifad4u, |
@kkafar I'm unable to reproduce the issue and don’t know where it is happening since this issue is happening in production. Caused by java.lang.IllegalStateException: FragmentManager is already executing transactions |
@rifad4u Did you solve it? |
Have same problem
@kkafar did you resolve it? |
Would you mind providing reproduction of your case? |
@kkafar Hello, I have same problem like above cases. It appears after 3~5seconds app launching, especially high possible on android 10. package.json
app/build.gradle:
Firebase Crashlytics Log:
|
|
In my case, I have react-native-screens 3.20, When I tried to debug why my mobile app cannot render screen contains custom Android Fragment if navigate from general screen (but it is okay to render it if I set it as initial route) It throws error in
and I also suspect onDetachedFromWindow of ScreenContainer.kt
When the stack screen has custom Android Fragment, it will trigger this error. |
I have the same issue, using rn-screens 3.20 and react native 0.71.x I'm navigating to a new screen with a custom Android UI and I get this crash. It seems like some race condition or blocked resources which lead to that crash. Havent had this issue with previous versions... I don't know how to fix this. Please help. |
hello this issue still happened on react-native-screens:3.24 version , |
solved or not ? |
If you are able to reproduce the issue, the share a reproducible repo for the same, react native will look in to it. |
you can see this rep : |
We're seeing this issue too in production: so far, we've seen 2 crashes, both on Android 13. 2 different Samsung devices. Stack trace (truncated - I can provide the full one if useful):
We also have a report in Sentry, which contains some interesting details in the breadcrumbs:
|
We're up to 11 crashes today, now also from other manufacturers. Only some reports mention the memory warning, many of them don't. |
do you have any custom UI fragments, also could you give me an overview of how your navigation stack is structured (are there nested stacks, where are these two screens in relation to whole navigation structure, is this brownfield app? (React native loaded on a Fragment / only in subpart of view hierarchy)? |
Our whole app is React Native, not brownfield, and we don't have any custom UI elements (except for what our dependencies may be doing, of course - nothing we wrote ourselves, at least). While it's a fairly large app, we use a pretty standard setup, nothing custom. Our navigation structure looks like this:
The crash happens when we RESET the navigation from the CAMPUS_VIDEO_EXERCISE_MAIN_SCREEN to the DASHBOARD_SCREEN. Main dependencies:
Also note this issue started happening after upgrading react-navigation from v4 to v6, which also updated |
Has anybody been able to solve this? Currently experiencing the same issue with our android application. Running react-native-screens 3.25.0 |
Having same issue for a while now.
My project is open source and here is the navigation: |
@tboba Our application is purely react native & has no custom UI fragments. We do have a few nested stack navigators that is very similar to what @TuurDutoit shared. We've seen 235 total events including the fragment error issue after updating to the newest versions of react native & react-navigation (stack, native & bottom-tabs) 1 month ago. Does anybody have a fix for this? Looking at switching navigators to avoid this error. |
Description
When react native screens are enabled on Android and the architecture is based on a single
Activity
plus React native is loaded in a Fragment, there's a crash when navigating and restoring the fragment state.Having a single
Activity
app and usingFragments
with navigation components as describe here brings us to load React Native apps on aFragment
. We also want to enable React native screens, however, when enabled on Android, there's the following crash:java.lang.RuntimeException: Unable to resume activity {com.swmansion.rnscreens.example/com.swmansion.rnscreens.example.MainActivity}: java.lang.IllegalStateException: FragmentManager is already executing transactions at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4445) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4477) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2067) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7697) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952) Caused by: java.lang.IllegalStateException: FragmentManager is already executing transactions at androidx.fragment.app.FragmentManager.ensureExecReady(FragmentManager.java:1686) at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1716) at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:323) at com.swmansion.rnscreens.ScreenContainer.removeMyFragments(ScreenContainer.kt:216) at com.swmansion.rnscreens.ScreenContainer.onDetachedFromWindow(ScreenContainer.kt:228) at android.view.View.dispatchDetachedFromWindow(View.java:20538) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3942) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3934) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3934) at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5560) at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5531) at android.view.ViewGroup.removeView(ViewGroup.java:5462) at androidx.fragment.app.FragmentContainerView.removeView(FragmentContainerView.kt:288) at androidx.fragment.app.SpecialEffectsController$Operation$State.applyState(SpecialEffectsController.java:470) at androidx.fragment.app.DefaultSpecialEffectsController.applyContainerChanges(DefaultSpecialEffectsController.java:822) at androidx.fragment.app.DefaultSpecialEffectsController$1.run(DefaultSpecialEffectsController.java:111) at androidx.fragment.app.SpecialEffectsController$Operation.complete(SpecialEffectsController.java:713) at androidx.fragment.app.SpecialEffectsController$FragmentStateManagerOperation.complete(SpecialEffectsController.java:770) at androidx.fragment.app.SpecialEffectsController$Operation.completeSpecialEffect(SpecialEffectsController.java:690) at androidx.fragment.app.DefaultSpecialEffectsController$SpecialEffectsInfo.completeSpecialEffect(DefaultSpecialEffectsController.java:855) at androidx.fragment.app.DefaultSpecialEffectsController.startAnimations(DefaultSpecialEffectsController.java:154) at androidx.fragment.app.DefaultSpecialEffectsController.executeOperations(DefaultSpecialEffectsController.java:123) at androidx.fragment.app.SpecialEffectsController.executePendingOperations(SpecialEffectsController.java:306) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1903) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1814) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1751) at androidx.fragment.app.Fragment.performResume(Fragment.java:3177) at androidx.fragment.app.FragmentStateManager.resume(FragmentStateManager.java:606) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:285) 2022-07-03 22:00:08.008 30152-30152/com.swmansion.rnscreens.example E/AndroidRuntime: at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:113) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1424) at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2968) at androidx.fragment.app.FragmentManager.dispatchResume(FragmentManager.java:2900) at androidx.fragment.app.FragmentController.dispatchResume(FragmentController.java:285) at androidx.fragment.app.FragmentActivity.onResumeFragments(FragmentActivity.java:334) at androidx.fragment.app.FragmentActivity.onPostResume(FragmentActivity.java:323) at androidx.appcompat.app.AppCompatActivity.onPostResume(AppCompatActivity.java:204) at android.app.Activity.performResume(Activity.java:8160) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4435)
The reason of the crash seems to be:
ScreenContainer
it receives theFragmentManager
from the Activity at some point.FragmentManager
is used by the Navigation Components to navigate between fragments.Fragment
that has react native tries to recover the state after a navigation, it tries to use theActivity
FragmentManager
which is already in use.Screenshots
Steps To Reproduce
To reproduce, I've recreated in the
Example
app a common use case: Load React native, put the app in the background and trigger a deep link. I've prepared theExample
to do this so the steps are:adb shell am start -W -a android.intent.action.VIEW -d "screens://screens" com.swmansion.rnscreens.example
Expected behavior
The react native screen should display without a crash
Actual behavior
Crash with the above stack trace
Reproduction
To reproduce the crash I've forked
react-native-screens
github project and modified the example with the described architecture. The project can be found here: https:/luislukas/react-native-screensI reported this issue originally on #819 but due to our architecture we had to disable
react-native-screens
. We would like to enable them now so any hint/help would be appreciated.Platform
Architecture
I've forked the
react-native-screens
and added the Navigation Componentes plusFragments
architecture described aboved.Workflow
Package versions
I'm using a fork of this project just changing the Android project architecture.
The text was updated successfully, but these errors were encountered: