What might be the cause of "_*Detected multithread...
# compose-android
z
What might be the cause of "_*Detected multithreaded access to SnapshotStateObserver*_" connected to
AndroidContentCaptureManager
? Full stacktrace in 🧵
Afaik, all state updates happen on the main thread and this issue only started showing up more frequently after upgrading to compose 1.7.x. Not sure if its related, but I do have a ComposeView thats rendered as part of an overlay (
WindowManager.add
) in a foreground service.
Copy code
Fatal Exception: java.lang.IllegalArgumentException: Detected multithreaded access to SnapshotStateObserver: previousThreadId=334), currentThread={id=2, name=main}. Note that observation on multiple threads in layout/draw is not supported. Make sure your measure/layout/draw for each Owner (AndroidComposeView) is executed on the same thread.
       at androidx.compose.runtime.PreconditionsKt.throwIllegalArgumentException(Preconditions.kt:26)
       at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:704)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
       at androidx.compose.ui.node.OwnerSnapshotObserver.observeSemanticsReads$ui_release(OwnerSnapshotObserver.kt:121)
       at androidx.compose.ui.node.LayoutNode.getCollapsedSemantics$ui_release(LayoutNode.kt:429)
       at androidx.compose.ui.semantics.SemanticsNodeKt.SemanticsNode(SemanticsNode.kt:49)
       at androidx.compose.ui.semantics.SemanticsNode.fillOneLayerOfSemanticsWrappers(SemanticsNode.kt:278)
       at androidx.compose.ui.semantics.SemanticsNode.unmergedChildren$ui_release(SemanticsNode.kt:257)
       at androidx.compose.ui.semantics.SemanticsNode.getChildren$ui_release(SemanticsNode.kt:338)
       at androidx.compose.ui.semantics.SemanticsNode.getChildren$ui_release$default(SemanticsNode.kt:322)
       at androidx.compose.ui.semantics.SemanticsNode.getReplacedChildren$ui_release(SemanticsNode.kt:305)
       at androidx.compose.ui.platform.SemanticsUtils_androidKt.getAllUncoveredSemanticsNodesToIntObjectMap$findAllSemanticNodesRecursive(SemanticsUtils_android.kt:196)
       at androidx.compose.ui.platform.SemanticsUtils_androidKt.getAllUncoveredSemanticsNodesToIntObjectMap$findAllSemanticNodesRecursive(SemanticsUtils_android.kt:198)
       at androidx.compose.ui.platform.SemanticsUtils_androidKt.getAllUncoveredSemanticsNodesToIntObjectMap(SemanticsUtils_android.kt:231)
       at androidx.compose.ui.contentcapture.AndroidContentCaptureManager.getCurrentSemanticsNodes$ui_release(AndroidContentCaptureManager.android.kt:111)
       at androidx.compose.ui.contentcapture.AndroidContentCaptureManager.sendSemanticsStructureChangeEvents(AndroidContentCaptureManager.android.kt:236)
       at androidx.compose.ui.contentcapture.AndroidContentCaptureManager.contentCaptureChangeChecker$lambda$0(AndroidContentCaptureManager.java:136)
       at android.os.Handler.handleCallback(Handler.java:959)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loopOnce(Looper.java:232)
       at android.os.Looper.loop(Looper.java:317)
       at android.app.ActivityThread.main(ActivityThread.java:8501)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
315 Views