API 23 is throwing `java.lang.IllegalStateExceptio...
# compose
k
API 23 is throwing
java.lang.IllegalStateException: Snapshot is not open
Anyone experienced it?
Copy code
java.lang.IllegalStateException: Snapshot is not open
                                                                                                    	at androidx.compose.runtime.snapshots.SnapshotKt.validateOpen(Snapshot.kt:1767)
                                                                                                    	at androidx.compose.runtime.snapshots.SnapshotKt.access$validateOpen(Snapshot.kt:1)
                                                                                                    	at androidx.compose.runtime.snapshots.MutableSnapshot.apply(Snapshot.kt:709)
                                                                                                    	at androidx.compose.runtime.Recomposer.applyAndCheck(Recomposer.kt:954)
                                                                                                    	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1283)
                                                                                                    	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:107)
                                                                                                    	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:485)
                                                                                                    	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:454)
                                                                                                    	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:856)
                                                                                                    	at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                                                    	at android.view.Choreographer.doFrame(Choreographer.java:603)
                                                                                                    	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:739)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                                    	at android.os.Looper.loop(Looper.java:148)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                                    	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@dcbbfad, androidx.compose.ui.platform.MotionDurationScaleImpl@f582e2, StandaloneCoroutine{Cancelling}@335c673, AndroidUiDispatcher@4eb930]
z
Which version of compose, and can you share a minimal repro case?
k
Version
1.2.1
, compiler
1.3.0
, Kotlin
1.7.10
I literally don't know when it happens, I just tried API 23, and it just breaks, API 24 works. Removing
StateFlows
from
ViewModels
makes bug go away. There isn't anything in particular special about those, as I've done it hundreds of times.
c
If you have some reproducible code you could share I can try to repro on my end. lmk
k
Thanks a lot Colton. As it happens only on API 23, not even 24, for now I'll focus on some other stuff and come back to this some time later on. It's a companies project and we are 2 months into the development of the project.
z
Cc @Chuck Jazdzewski [G] in case this rings any bells for him
c
I haven't seen anything similar. It appears something is applying the snapshot early. I am uncertain what could cause this.
k
There are already some issues on Google search about it, none of these helped atm.
c
Like @Zach Klippenstein (he/him) [MOD] said, if you have a repro case that would be very helpful.
m
We are also seeing this in our app, same versions of everything. Only seems to come up in tests (Firbase Test Lab, NexusLowRes api 23), I haven't seen a production report with this error yet.
It is also not something that happens every test execution. It's flaky.
c
What is the test doing?
m
One that I see flake often is on a line where we call painterResource inside a recycler view adapter via a composeview. The test is just asserting things are on screen and navigating around, nothing too fancy
We use painterResource to load a vector drawable
While it's composing the vector painter, when it calls setContent it throws the error
c
Can you 1) create a bug for this (https://goo.gle/compose-feedback), 2) Attach the stack trace of the crash, 3) at least a sketch of the test or code of the test itself if it is not privileged 4) include the information of the test lab failure (such as NexusLowRes api 23) or any other descriptions where you are seeing this failure. We have heard other reports of similar failures but we have not been able to reproduce this locally in order to track this down. Any help you can give would be greatly appriciated.
m
Are there any debug traces or logs which we might be able to generate and then share with the bug report?
c
No. The runtime doesn't have any logging. I rely on runtime asserts for such things and I suspect that I missed an assert. A reproducible test case here would be helpful even if it is flakey.
m
Got it, we're trying to get that created
a
Is there any update on this @mruno?
m
No, but we have not seen it with recent versions of compose. It also seemed to be somewhat device dependent in how it reproduced for us.. api23 was the easiest way to cause it. We’ve since moved to api27 to run our tests
229 Views