coil icon indicating copy to clipboard operation
coil copied to clipboard

AsyncImagePainter should use `rememberCoroutineScope`

Open ansman opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. Currently, AsyncImagePainter uses Dispatchers.Main.immediate. This normally works fine but during Paparazzi screenshot tests they use a custom dispatcher for composables to synchronize time.

Describe the solution you'd like If possible AsyncImagePainter should use rememberCoroutineScope instead.

ansman avatar Mar 25 '24 13:03 ansman

Hello! @ansman @colinrtwhite

Will this change fix the issue on jvm("desktop") since there is no Dispatchers.Main there? Currently, AsyncImage throws an error on desktop: module with the main dispatcher had failed to initialize It's good to use the same context or scope used inside the composer, or use Dispatchers.Swing for desktop instead of main

tamimattafi avatar May 09 '24 16:05 tamimattafi

As long as rememberCoroutineScope() handles it

ansman avatar May 09 '24 19:05 ansman

@tamimattafi That is intended behaviour and not a bug. See here and here. This is also explained in the docs here.

colinrtwhite avatar May 09 '24 20:05 colinrtwhite

@colinrtwhite Thank you, I already added swing but still getting the error, it seems like some other library is overriding the main dispatcher, will look into it.

tamimattafi avatar May 10 '24 12:05 tamimattafi