Shakil Karim
03/31/2023, 10:48 AMval list = SnapshotStateList<VoiceItem>()
appScope.launch {
voicesList.add(VoiceItem(id))
}
But i'm getting a lot of ANR in production app like this
``````Shakil Karim
03/31/2023, 10:48 AMat androidx.compose.runtime.snapshots.SnapshotStateList$StateListStateRecord.assign (SnapshotStateList.kt:458)
The main thread is blocked here. It is waiting, trying to acquire lock 0x0de00d89 (java.lang.Object), held by thread 23
at androidx.compose.runtime.snapshots.SnapshotKt.overwriteUnusedRecordsLocked (Snapshot.kt:1941)
at androidx.compose.runtime.snapshots.SnapshotKt.advanceGlobalSnapshot (Snapshot.kt:1773)
at androidx.compose.runtime.snapshots.SnapshotKt.advanceGlobalSnapshot (Snapshot.kt)
at androidx.compose.runtime.snapshots.SnapshotKt.access$advanceGlobalSnapshot (Snapshot.kt)
at androidx.compose.runtime.snapshots.Snapshot$Companion.sendApplyNotifications (Snapshot.kt:568)
at androidx.compose.ui.platform.GlobalSnapshotManager$ensureStarted$1.invokeSuspend (GlobalSnapshotManager.android.kt:46)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch (AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch (AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run (AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:268)
at android.app.ActivityThread.main (ActivityThread.java:8017)
at java.lang.reflect.Method.invoke (Native method)
Zach Klippenstein (he/him) [MOD]
04/04/2023, 6:21 PMChuck Jazdzewski [G]
04/05/2023, 8:41 PMChuck Jazdzewski [G]
04/05/2023, 8:56 PMconditionalUpdate
in the synchronized
call on around line 204. Is what you are seeing then I believe the code can be fixed by moving the synchronized
call inside the writable
call both in conditionalUpdate
and mutate
(which would have a a similar issue).Chuck Jazdzewski [G]
04/05/2023, 11:07 PMShakil Karim
04/06/2023, 6:56 AM"Timer-0" tid=23 Waiting
at java.lang.Object.wait (Native method)
at java.lang.Object.wait (Object.java:442)
at java.lang.Object.wait (Object.java:568)
at java.util.TimerThread.mainLoop (Timer.java:533)
at java.util.TimerThread.run (Timer.java:512)
Chuck Jazdzewski [G]
04/06/2023, 9:43 PM