coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.8k stars 661 forks source link

GIF freezes espresso instrumented tests #1916

Closed DBroli closed 12 months ago

DBroli commented 1 year ago

Describe the bug When loading a GIF in an instrumented test the test freezes and is unable to continue. When there is no GIF, the test passes.

To Reproduce Run an instrumented test with a GIF somewhere in it. Test is unable to progress when a GIF is loaded.

Version 2.4.0

colinrtwhite commented 12 months ago

Do you have an example test that reproduces this? What Android device was this tested on? Which GIF decoder class are you using? Does it freeze on the first frame or a subsequent frame? If you call start on the drawable is it still frozen?

DBroli commented 12 months ago

Device: Android 8 Google APis x86 emulator GIF decoder doesn't seem to matter, this happens with both ImageDecoderDecoder or GifDecoder The GIF itself doesn't freeze, it seems that when it plays indefinetely it freezes the test. When manually scrolling past the indefinetely playing GIF, the test continues.

colinrtwhite commented 12 months ago

I did a quick check on my physical device and the GIF played correctly in my test. It's likely that this is an issue with the Android emulator.

DBroli commented 12 months ago

This is also reproducible on a physical device (Google pixel 4A). When running an espresso test with Idling resources, GIF decoder set and GIF playing an indefinite amount of time, the test won't continue until the GIF is off the screen. My guess is that indefinitely playing GIF somehow blocks the main thread so that the test can't progress. There is a workaround to disable or limit GIF play time in tests, however it would be nice if that wasn't necessary.