I'm using crashlytics to monitor my app, and I can see some users are having this crash:
Fatal Exception: java.util.ConcurrentModificationException:
at java.util.ArrayList$Itr.next(ArrayList.java:860)
at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:181)
at kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3$1.invokeSuspend(SafeCollector.common.kt:1)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:1)
at kotlinx.coroutines.flow.internal.SafeCollector.invokeSuspend(SafeCollector.kt:1)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:1)
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:1)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:100)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:100)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:33)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:26)
at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:26)
at kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$$inlined$Runnable$1.run(HandlerContext.java:169)
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)
the thing is that this logs doesn't point to any place in my app's code. it looks like i have some concurrent array modification, but i cannot figure out where it can be.
I do use proguard rules and minify enables, if it matters. i would still assume that the crash would point to somewhere in my package.
any ideas how I can investiagte this? thanks
I'd suggest find at all places, were you use .asFlow()
or other flow builders in project, wrap all those flows' collect
or other terminal operators like first()
or single()
in try/catch and add a defining log in catch.