https://kotlinlang.org logo
#compose
Title
# compose
k

K Merle

08/16/2022, 7:49 AM
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

Zach Klippenstein (he/him) [MOD]

08/16/2022, 11:38 PM
Which version of compose, and can you share a minimal repro case?
k

K Merle

08/17/2022, 5:40 AM
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

Colton Idle

08/17/2022, 3:33 PM
If you have some reproducible code you could share I can try to repro on my end. lmk
k

K Merle

08/18/2022, 5:45 AM
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

Zach Klippenstein (he/him) [MOD]

08/18/2022, 3:51 PM
Cc @Chuck Jazdzewski [G] in case this rings any bells for him
c

Chuck Jazdzewski [G]

08/18/2022, 3:58 PM
I haven't seen anything similar. It appears something is applying the snapshot early. I am uncertain what could cause this.
k

K Merle

08/18/2022, 3:59 PM
There are already some issues on Google search about it, none of these helped atm.
c

Chuck Jazdzewski [G]

08/20/2022, 12:06 AM
Like @Zach Klippenstein (he/him) [MOD] said, if you have a repro case that would be very helpful.
m

mruno

08/26/2022, 9:16 PM
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

Chuck Jazdzewski [G]

08/26/2022, 9:17 PM
What is the test doing?
m

mruno

08/26/2022, 9:21 PM
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

Chuck Jazdzewski [G]

08/26/2022, 9:26 PM
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

mruno

08/29/2022, 6:52 PM
Are there any debug traces or logs which we might be able to generate and then share with the bug report?
c

Chuck Jazdzewski [G]

08/30/2022, 4:41 PM
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

mruno

08/30/2022, 4:43 PM
Got it, we're trying to get that created
a

aliftc12

02/01/2024, 3:47 AM
Is there any update on this @mruno?
m

mruno

02/20/2024, 11:06 PM
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
206 Views