You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm not certain but I think there is a problem with Coil and the way it acts when the image loading is cancelled by AsyncImage moving out of scope, specifically on wasmJs. Using the circuit navigation library, when changing the Screen (effectively the @Composable) from a LaunchedEffect while the current AsyncImage is still loading, this exception occurs (app/website crash):
The demo loads 20 images which increases the chance of this bug occurring to about every 2nd page reload.
note: In this sample, the bug can be prevented by changing whether the initial screen is even shown, which makes it so that the image loading is never cancelled.
NOTE: in this demo, the bug only occurs when the QuizView (Screen) also uses AsyncImage, but in the project where I noticed this issue the QuizView does not use AsyncImage and the bug still occurs.
Also the bug is significantly rarer in Chromium (^ report was with Firefox) and the Stacktrace there is differnt:
Uncaught runtime errors:
×
ERROR
BodyStreamBuffer was aborted
AbortError: BodyStreamBuffer was aborted
at io.ktor.client.fetch.abort_$external_fun (webpack-internal:///./kotlin/composeApp.uninstantiated.mjs:4645:73)
at <CoilBug:composeApp>.io.ktor.client.engine.js.JsClientEngine$execute$lambda.invoke (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[59948]:0x761a81)
at <CoilBug:composeApp>.io.ktor.client.engine.js.JsClientEngine$execute$lambda.invoke (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[59949]:0x761aa9)
at <CoilBug:composeApp>.kotlinx.coroutines.InvokeOnCancelling.invoke (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15857]:0x3c6146)
at <CoilBug:composeApp>.kotlinx.coroutines.JobSupport.notifyCancelling (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15773]:0x3c33df)
at <CoilBug:composeApp>.kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15816]:0x3c53e1)
at <CoilBug:composeApp>.kotlinx.coroutines.JobSupport.tryMakeCompleting (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15815]:0x3c5202)
at <CoilBug:composeApp>.kotlinx.coroutines.JobSupport.cancelMakeCompleting (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15806]:0x3c495c)
at <CoilBug:composeApp>.kotlinx.coroutines.JobSupport.cancelImpl (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15805]:0x3c4847)
at <CoilBug:composeApp>.kotlinx.coroutines.JobSupport.cancelInternal (http://localhost:8080/5bf60037f095d0dccd78.wasm:wasm-function[15801]:0x3c47c1)
Hmm considering this only occurs on wasmJs I think this is likely either be a wasm JS Kotlin compiler bug or bug in the Chromium/Firefox runtime. Coil doesn't have much wasm JS specific code and relies on common code entirely for the Compose integration. I'm not sure if there's anything we can do on Coil's end to work around this.
Describe the bug
I'm not certain but I think there is a problem with Coil and the way it acts when the image loading is cancelled by
AsyncImage
moving out of scope, specifically on wasmJs. Using the circuit navigation library, when changing theScreen
(effectively the@Composable
) from aLaunchedEffect
while the currentAsyncImage
is still loading, this exception occurs (app/website crash):To Reproduce
Here is a very simple repository to reproduce: https://github.com/julius-b/coil-bug
It's basically just an
AsyncImage
: https://github.com/julius-b/coil-bug/blob/main/composeApp/src/wasmJsMain/kotlin/ch/whatever/MainScreen.kt#L69LaunchedEffect
that cancels theAsyncImage
: https://github.com/julius-b/coil-bug/blob/main/composeApp/src/wasmJsMain/kotlin/ch/whatever/App.kt#L30The demo loads 20 images which increases the chance of this bug occurring to about every 2nd page reload.
note: In this sample, the bug can be prevented by changing whether the initial screen is even shown, which makes it so that the image loading is never cancelled.
NOTE: in this demo, the bug only occurs when the
QuizView
(Screen
) also usesAsyncImage
, but in the project where I noticed this issue theQuizView
does not useAsyncImage
and the bug still occurs.Also the bug is significantly rarer in Chromium (^ report was with Firefox) and the Stacktrace there is differnt:
(similar to #2462)
Version
coil = "3.1.0"
compose-multiplatform = "1.7.3"
kotlin = "2.1.10"
ktor = "3.0.3"
The text was updated successfully, but these errors were encountered: