Skip to content

IllegalStateException: FragmentManager is already executing transactions #170

@alashow

Description

@alashow

How can I avoid this exception?

Fatal Exception: java.lang.IllegalStateException: FragmentManager is already executing transactions
	androidx.fragment.app.FragmentManagerImpl.ensureExecReady (SourceFile:2207)
	androidx.fragment.app.FragmentManagerImpl.execPendingActions (SourceFile:2267)
	androidx.fragment.app.FragmentManagerImpl.executePendingTransactions (SourceFile:814)
	com.ncapdevi.fragnav.FragNavController.tryPopFragmentsFromCurrentStack (SourceFile:745)
	my.app.ui.base.BaseFragNavActivity.navigate (SourceFile:76)
	my.app.ui.base.interfaces.FragmentNavigator$DefaultImpls.navigate$default (SourceFile:10)
	my.app.ui.main.module.Fragment$initLive$7.invoke (SourceFile:80)
	my.app.ui.main.module.Fragment$initLive$7.invoke (SourceFile:24)
	my.app.ui.utils.extensions.LiveDataExtensionsKt$witness$1.onChanged (SourceFile:16)
	my.app.util.arch.SingleLiveEvent$observe$1.onChanged (SourceFile:26)
	androidx.lifecycle.LiveData.considerNotify (SourceFile:113)
	androidx.lifecycle.LiveData.dispatchingValue (SourceFile:126)
	androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged (SourceFile:424)
	androidx.lifecycle.LiveData$LifecycleBoundObserver.onStateChanged (SourceFile:376)
	androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent (SourceFile:355)
	androidx.lifecycle.LifecycleRegistry.forwardPass (SourceFile:293)
	androidx.lifecycle.LifecycleRegistry.sync (SourceFile:333)
	androidx.lifecycle.LifecycleRegistry.moveToState (SourceFile:138)
	androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent (SourceFile:124)
	androidx.fragment.app.Fragment.performStart (SourceFile:2487)
	androidx.fragment.app.FragmentManagerImpl.moveToState (SourceFile:1494)
	androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState (SourceFile:1784)
	androidx.fragment.app.BackStackRecord.executeOps (SourceFile:797)
	androidx.fragment.app.FragmentManagerImpl.executeOps (SourceFile:2625)
	androidx.fragment.app.FragmentManagerImpl.executeOpsTogether (SourceFile:2411)
	androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute (SourceFile:2366)
	androidx.fragment.app.FragmentManagerImpl.execPendingActions (SourceFile:2273)
	androidx.fragment.app.FragmentManagerImpl$1.run (SourceFile:733)
	android.os.Handler.handleCallback (Handler.java:789)
	android.os.Handler.dispatchMessage (Handler.java:98)
	android.os.Looper.loop (Looper.java:164)
	android.app.ActivityThread.main (ActivityThread.java:6938)
	java.lang.reflect.Method.invoke (Method.java)
	com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
	com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

76's line is navController.executePendingTransactions():

 override fun navigate(fragment: Fragment, pop: Int) {
        when (fragment) {
            is BaseFragment<*> -> setTitle(fragment.getTitle(resources))
        }
        when (pop == 0) {
            true -> navController.pushFragment(fragment)
            else -> {
                if (!navController.isRootFragment) {
                    navController.popFragments(pop)
                } else Timber.e("Tried to pop when it's root fragment. Not cool.")

                navController.pushFragment(fragment)
            }
        }
        navController.executePendingTransactions()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions