coil-kt / coil

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

Disparity between coil2 and coil3's equality delegate #2640

Closed saket closed 2 weeks ago

saket commented 2 weeks ago

While migrating telephoto to coil3, I noticed that some of my tests were running into infinite loops of image requests because the new equality delegate does not account for non-ImageRequest models.

Coil 2.x Coil 3.x
image image

Was this an intention choice?

Here's how I'm using AsyncImageModelEqualityDelegate: https://github.com/saket/telephoto/blob/5d156f836441b2deb684427162ac22d5d00f29a6/zoomable-image/coil3/src/main/kotlin/me/saket/telephoto/zoomable/coil3/ZoomableAsyncImage.kt#L112

It's also interesting that AsyncImage() does not seem to run into this problem. Are you relying on something else for diffing non-ImageRequest models?

colinrtwhite commented 2 weeks ago

Good catch! This is definitely a bug. Added a fix here that we can ship in a 3.0.1 release.

There are a bunch of tests around when AsyncImage/rememberAsyncImagePainter recompose here. I think it might be recomposing infinitely for you because Coil has overloads here that wrap passing the AsyncImageState to the "real" stable, restartable implementation here.

saket commented 2 weeks ago

That was fast, thank you!