Fixed
Status Update
Comments
il...@google.com <il...@google.com>
lo...@gmail.com <lo...@gmail.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
ch...@gmail.com <ch...@gmail.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
lo...@gmail.com <lo...@gmail.com> #4
I think that I can confirm this crash happens when immediately navigating to another screen. After I removed that navigation pattern from my app, no more crashes occured until now (still Pixel 6 running Android 13).
am...@gmail.com <am...@gmail.com> #5
I have this runtime crashes all the time. Android 13
java.lang.IllegalStateException: removeReporter() called when all reporters have already been removed.
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:46)
at androidx.compose.runtime.PausableMonotonicFrameClock.withFrameNanos(PausableMonotonicFrameClock.kt:63)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.invokeSuspend(Recomposer.kt:510)
at androidx.compose.runtime.Recomposer$recompositionRunner$2$2.invokeSuspend(Recomposer.kt:899)
at androidx.compose.runtime.Recomposer$recompositionRunner$2.invokeSuspend(Recomposer.kt:898)
at androidx.compose.ui.platform.WindowRecomposer_androidKt$createLifecycleAwareWindowRecomposer$2$onStateChanged$1.invokeSuspend(WindowRecomposer.android.kt:391)
Caused by java.lang.IllegalStateException: removeReporter() called when all reporters have already been removed.
at androidx.activity.FullyDrawnReporter.removeReporter(FullyDrawnReporter.kt:107)
at androidx.activity.compose.ReportDrawnComposition.removeReporter(ReportDrawn.kt:74)
at androidx.activity.compose.ReportDrawnKt$ReportDrawnWhen$1$invoke$$inlined$onDispose$2.dispose(Effects.kt:484)
at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1094)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:820)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:842)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:592)
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:1299)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
at android.view.Choreographer.doCallbacks(Choreographer.java:923)
at android.view.Choreographer.doFrame(Choreographer.java:847)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
ja...@google.com <ja...@google.com> #6
I'm also seeing this in Robolectric tests with native graphics 100% reproducible. Removing the call to ReportDrawnWhen fixes it.
java.lang.IllegalStateException: removeReporter() called when all reporters have already been removed.
at androidx.activity.FullyDrawnReporter.removeReporter(FullyDrawnReporter.kt:107)
at androidx.activity.compose.ReportDrawnComposition.removeReporter(ReportDrawn.kt:74)
at androidx.activity.compose.ReportDrawnKt$ReportDrawnWhen$1$invoke$$inlined$onDispose$2.dispose(Effects.kt:484)
at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1094)
at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:624)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.disposeCurrentNodes(SubcomposeLayout.kt:712)
at androidx.compose.ui.layout.SubcomposeLayoutState.disposeCurrentNodes$ui_release(SubcomposeLayout.kt:230)
at androidx.compose.ui.layout.SubcomposeLayoutKt$SubcomposeLayout$5$1$invoke$$inlined$onDispose$1.dispose(Effects.kt:485)
at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1094)
at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:624)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.disposeCurrentNodes(SubcomposeLayout.kt:712)
at androidx.compose.ui.layout.SubcomposeLayoutState.disposeCurrentNodes$ui_release(SubcomposeLayout.kt:230)
at androidx.compose.ui.layout.SubcomposeLayoutKt$SubcomposeLayout$5$1$invoke$$inlined$onDispose$1.dispose(Effects.kt:485)
at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1094)
at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:624)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.disposeCurrentNodes(SubcomposeLayout.kt:712)
at androidx.compose.ui.layout.SubcomposeLayoutState.disposeCurrentNodes$ui_release(SubcomposeLayout.kt:230)
at androidx.compose.ui.layout.SubcomposeLayoutKt$SubcomposeLayout$5$1$invoke$$inlined$onDispose$1.dispose(Effects.kt:485)
at androidx.compose.runtime.DisposableEffectImpl.onForgotten(Effects.kt:85)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1094)
at androidx.compose.runtime.CompositionImpl.dispose(Composition.kt:624)
at androidx.compose.ui.platform.WrappedComposition.dispose(Wrapper.android.kt:171)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:179)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.kt:266)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.kt:283)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.kt:136)
at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.kt:119)
at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release(ReportFragment.kt:192)
at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPreDestroyed(ReportFragment.kt:148)
at android.app.Activity.dispatchActivityPreDestroyed(Activity.java:1553)
at android.app.Activity.performDestroy(Activity.java:8543)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1419)
at org.robolectric.android.internal.RoboMonitoringInstrumentation.callActivityOnDestroy(RoboMonitoringInstrumentation.java:290)
at org.robolectric.android.controller.ActivityController.lambda$destroy$13(ActivityController.java:309)
at org.robolectric.shadows.ShadowPausedLooper.runPaused(ShadowPausedLooper.java:204)
at org.robolectric.android.controller.ActivityController.destroy(ActivityController.java:307)
at org.robolectric.android.internal.LocalActivityInvoker.finishActivity(LocalActivityInvoker.java:142)
at androidx.test.core.app.ActivityScenario.moveToState(ActivityScenario.java:677)
at androidx.test.core.app.ActivityScenario.close(ActivityScenario.java:416)
at androidx.test.ext.junit.rules.ActivityScenarioRule.after(ActivityScenarioRule.java:115)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:59)
at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1$evaluate$1.invoke(AndroidComposeTestRule.android.kt:148)
at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1$evaluate$1.invoke(AndroidComposeTestRule.android.kt:147)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$AndroidComposeUiTestImpl.withDisposableContent(ComposeUiTest.android.kt:476)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1$1$1.invoke(ComposeUiTest.android.kt:294)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withTextInputService(ComposeUiTest.android.kt:360)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withTextInputService(ComposeUiTest.android.kt:217)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1$1.invoke(ComposeUiTest.android.kt:293)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withComposeIdlingResource(ComposeUiTest.android.kt:347)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withComposeIdlingResource(ComposeUiTest.android.kt:217)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1.invoke(ComposeUiTest.android.kt:292)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withWindowRecomposer(ComposeUiTest.android.kt:321)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withWindowRecomposer(ComposeUiTest.android.kt:217)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1.invoke(ComposeUiTest.android.kt:291)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withTestCoroutines(ComposeUiTest.android.kt:334)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withTestCoroutines(ComposeUiTest.android.kt:217)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1.invoke(ComposeUiTest.android.kt:290)
at androidx.compose.ui.test.junit4.IdlingStrategy.withStrategy(IdlingStrategy.android.kt:52)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1.invoke(ComposeUiTest.android.kt:289)
at androidx.compose.ui.test.junit4.IdlingResourceRegistry.withRegistry(IdlingResourceRegistry.jvm.kt:157)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1.invoke(ComposeUiTest.android.kt:288)
at androidx.compose.ui.test.junit4.ComposeRootRegistry.withRegistry(ComposeRootRegistry.android.kt:146)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.runTest(ComposeUiTest.android.kt:287)
at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1.evaluate(AndroidComposeTestRule.android.kt:147)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
at dagger.hilt.android.internal.testing.MarkThatRulesRanRule$1.evaluate(MarkThatRulesRanRule.java:108)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:589)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:290)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:99)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Suppressed: org.robolectric.android.internal.AndroidTestEnvironment$UnExecutedRunnablesException: Main looper has queued unexecuted runnables. This might be the cause of the test failure. You might need a shadowOf(Looper.getMainLooper()).idle() call.
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit 5713d41811d5a99c93b5d585cbac46bfaa9ed5a6
Author: mlykotom <mlykotom@google.com>
Date: Fri May 12 13:03:02 2023
Fix ReportDrawn* crashing when navigating away from a screen
Doesn't crash when removeReporter() is called multiple times, which is caused by onDismiss and observeReporter().
Relnote: Fix ReportDrawn crashing when navigating away from a screen before report is called.
Fixes: 260506820
Test: testDisposingBeforeReporting
Change-Id: Ic46f17d4dfd9a0758398564dce72fbb5f637626e
M activity/activity-compose/src/androidTest/java/androidx/activity/compose/ReportDrawnTest.kt
M activity/activity/src/main/java/androidx/activity/FullyDrawnReporter.kt
https://android-review.googlesource.com/2584244
Branch: androidx-main
commit 5713d41811d5a99c93b5d585cbac46bfaa9ed5a6
Author: mlykotom <mlykotom@google.com>
Date: Fri May 12 13:03:02 2023
Fix ReportDrawn* crashing when navigating away from a screen
Doesn't crash when removeReporter() is called multiple times, which is caused by onDismiss and observeReporter().
Relnote: Fix ReportDrawn crashing when navigating away from a screen before report is called.
Fixes: 260506820
Test: testDisposingBeforeReporting
Change-Id: Ic46f17d4dfd9a0758398564dce72fbb5f637626e
M activity/activity-compose/src/androidTest/java/androidx/activity/compose/ReportDrawnTest.kt
M activity/activity/src/main/java/androidx/activity/FullyDrawnReporter.kt
ml...@google.com <ml...@google.com>
ju...@google.com <ju...@google.com> #8
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.activity:activity:1.7.2
androidx.activity:activity-compose:1.7.2
ja...@google.com <ja...@google.com> #9
Can confirm activity 1.7.2 fixed it.
Description
Component used: androidx.activity:activity:1.7.0-alpha02
Devices/Android versions reproduced on: Pixel 6
I tried out the new
ReportDrawnWhen
API for compose. Generally, it works fine, but sometimes this runtime crash occurs. Unfortunately, I can't reproduce it consistently.I simply call it like this inside my composable:
ReportDrawnWhen{appViewModel.reloadFinished}
.reloadFinished
is a simply boolean.