coil icon indicating copy to clipboard operation
coil copied to clipboard

Coil 3.0.0-alpha07 crash on Android

Open kamgurgul opened this issue 7 months ago • 2 comments

After upgrade from version 3.0.0-alpha06 to 3.0.0-alpha07 this crash starts to occur on Android (tested on 14):

java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
                 	at androidx.compose.runtime.snapshots.SnapshotKt.readError(Snapshot.kt:2033)
                 	at androidx.compose.runtime.snapshots.SnapshotKt.current(Snapshot.kt:2378)
                 	at androidx.compose.runtime.SnapshotMutableStateImpl.setValue(SnapshotState.kt:308)
                 	at coil3.compose.AsyncImagePainter.setPainter(AsyncImagePainter.kt:420)
                 	at coil3.compose.AsyncImagePainter.updateState(AsyncImagePainter.kt:307)
                 	at coil3.compose.AsyncImagePainter.access$updateState(AsyncImagePainter.kt:181)
                 	at coil3.compose.AsyncImagePainter$onRemembered$1$1.invokeSuspend$updateState(AsyncImagePainter.kt:253)
                 	at coil3.compose.AsyncImagePainter$onRemembered$1$1.access$invokeSuspend$updateState(Unknown Source:0)
                 	at coil3.compose.AsyncImagePainter$onRemembered$1$1$3.emit(AsyncImagePainter.kt:253)
                 	at coil3.compose.AsyncImagePainter$onRemembered$1$1$3.emit(AsyncImagePainter.kt:253)
                 	at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:33)
                 	at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(Channels.kt:1)
                 	at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:14)
                 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
                 	at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:65)
                 	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:369)
                 	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith$default(DispatchedContinuation.kt:271)
                 	at kotlinx.coroutines.DispatchedCoroutine.afterResume(Builders.common.kt:255)
                 	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
                 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
                 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
                 	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
                 	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:96)
                 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
                 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:816)
                 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
                 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
                 	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@391b699, androidx.compose.runtime.BroadcastFrameClock@e038d5e, StandaloneCoroutine{Cancelling}@14a053f, Dispatchers.Unconfined]

Affected code:

AsyncImage(
    model = ImageRequest.Builder(LocalPlatformContext.current)
        .data(appData.appIconUri)
        .crossfade(true)
        .build(),
     contentDescription = null,
     modifier = Modifier.size(50.dp),
)

App icon URI is created like that:

private fun getAppIconUri(packageName: String): String {
        return Uri.Builder()
            .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
            .authority(packageName)
            .path(getResourceId(packageName).toString())
            .build()
            .toString()
    }

Compose multiplatform version: 1.6.11

kamgurgul avatar Jun 30 '24 06:06 kamgurgul