material-motion-compose icon indicating copy to clipboard operation
material-motion-compose copied to clipboard

java.lang.IllegalStateException

Open MohitMPulse opened this issue 2 years ago • 2 comments

Getting this error and app crashes when navigating frequently java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.

Full log

java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed. at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:213) at androidx.lifecycle.viewmodel.compose.ViewModelKt.get(ViewModel.kt:206) at androidx.lifecycle.viewmodel.compose.ViewModelKt.viewModel(ViewModel.kt:156)

. . . at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:162) at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2443) at androidx.compose.runtime.ComposerImpl.skipToGroupEnd(Composer.kt:2734) at com.marketpulse.sniper.vte.view.bottom_panel.BottomPanelKt.Container(BottomPanel.kt:77) at com.marketpulse.sniper.vte.view.bottom_panel.BottomPanelKt.access$Container(BottomPanel.kt:1) at com.marketpulse.sniper.vte.view.bottom_panel.BottomPanelKt$BottomPanel$1.invoke(BottomPanel.kt:38) at com.marketpulse.sniper.vte.view.bottom_panel.BottomPanelKt$BottomPanel$1.invoke(BottomPanel.kt:37) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135) at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$2.invoke(ComposableLambda.jvm.kt:141) at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$2.invoke(ComposableLambda.jvm.kt:141) at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:162) at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2443) at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2711) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3342) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3320) at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3320) at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3285) at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:772) at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1047) at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:124) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:541) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:510) at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34) at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035) at android.view.Choreographer.doCallbacks(Choreographer.java:845) at android.view.Choreographer.doFrame(Choreographer.java:775) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022) 2023-03-30 16:38:05.722 20395-20395 AndroidRuntime com.marketpulse.sniper.vte E at android.os.Handler.handleCallback(Handler.java:978) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loopOnce(Looper.java:238) at android.os.Looper.loop(Looper.java:357) at android.app.ActivityThread.main(ActivityThread.java:8090) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@21a437e, androidx.compose.ui.platform.MotionDurationScaleImpl@73350df, StandaloneCoroutine{Cancelling}@ef7912c, AndroidUiDispatcher@1ac67f5]

MohitMPulse avatar Mar 30 '23 11:03 MohitMPulse

I couldn't reproduce this. Can you give me more details?

  • What version does it happen on?
  • Does it happen in the sample project?

And please tell me the code that is causing the problem.

fornewid avatar Apr 06 '23 02:04 fornewid

I think, the problem is caused by Compose. Please refer to the following links:

  • https://github.com/google/accompanist/issues/1487
  • https://issuetracker.google.com/issues/268422136
  • https://issuetracker.google.com/issues/254645321

fornewid avatar Apr 06 '23 02:04 fornewid