coil-kt / coil

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

Gif playback is interrupted until next draw phase #2298

Closed jns-codeworks closed 4 days ago

jns-codeworks commented 1 month ago

Gif playback is stopped as soon as the draw phase is finished and starts again when the composable is redrawn. I see this effect on coil 2.x and 3.x. on my device Xiaomi Redmi Note 11s Android 14. Android emulator with the same api level is not affected. Unfortunately I cannot reproduce when this effect occured for the first time, because gif playing used to work flawless. However, I have the impression it might be coming from a compose update.

https://github.com/coil-kt/coil/assets/28293626/23ff6cdf-4575-4697-ac0a-d68d0986a7c5

colinrtwhite commented 1 month ago

Do you have a code snippit or project that reproduces the issue? You could also make changes to the sample:compose app in this repo. It's not possible to debug the issue without a way to reproduce it.

jns-codeworks commented 1 month ago

It seems like LazyColumnis causing the issue, when it is added to a Columnthat contains an AsyncImage. Still this issue effects my device only. Compose version: 1.7.0-beta02

@Composable
private fun CoilGifTest() {
    val imageLoader = LocalContext.current.imageLoader 

    Surface {
        Column {
            AsyncImage(
                model = "https://gf-mint-website.s3.amazonaws.com/STAGE2/images/5077.gif",
                contentScale = ContentScale.Crop,
                contentDescription = null,
                imageLoader = imageLoader,
            )

            LazyColumn {
                for (idx in 0..10) {
                    item {
                        Box(
                            contentAlignment = Alignment.Center,
                            modifier = Modifier
                                .fillMaxWidth()
                                .height(80.dp)
                        ) {
                            Text("$idx")
                        }
                    }
                }
            }
        }
    }
}

https://github.com/coil-kt/coil/assets/28293626/4c7e2d0c-f52a-4232-a0ed-696cf18b8f62

jns-codeworks commented 1 month ago

The same issue occurs when you add AsyncImage to a LazyColumn.

jns-codeworks commented 2 weeks ago

When I'm using GifDecoder instead of AnimatedImageDecoder everything works fine

colinrtwhite commented 4 days ago

Sorry I'm not able to reproduce this locally and can't debug without a way to reproduce this.