-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jetpack Compose Coil gets stuck in Loading state in a LazyColumn that uses a placeholder #1799
Comments
Thanks for the repro project! Will take a look unless someone beats me to it. |
I took a look into this, since I had some free time, and I think I know what's causing the issue, kind of. eventListener.resolveSizeStart(request).also { println("before size") }
val size = request.sizeResolver.size() //TODO: This is blocking it
eventListener.resolveSizeEnd(request, size).also { println("after size") } the middle guy is blocking it. If I change the @Composable
@ReadOnlyComposable
internal fun requestOf(model: Any?): ImageRequest {
if (model is ImageRequest) {
return model
} else {
return ImageRequest.Builder(LocalContext.current).size(400).data(model).build() //<-- here!!!
}
} everything works as intended. But that is just a work around. |
I figured out what the problem is! private val drawSize = MutableStateFlow(Size.Zero) Since that guy starts with size { drawSize.mapNotNull { it.toSizeOrNull() }.first() }
private fun Size.toSizeOrNull() = when {
isUnspecified -> CoilSize.ORIGINAL
isPositive -> CoilSize(
width = if (width.isFinite()) Dimension(width.roundToInt()) else Dimension.Undefined,
height = if (height.isFinite()) Dimension(height.roundToInt()) else Dimension.Undefined
)
else -> null
} Since it ends up going to the else condition. private val drawSize = MutableStateFlow(Size.Unspecified) it works without issue! |
Thanks for taking a look! The |
I have found that if I do: val painter = rememberAsyncImagePainter(
model = ImageRequest.Builder(LocalContext.current)
.data(imageUrl)
.size(Size.ORIGINAL)
.build()
) It works completely fine. |
@jakepurple13 Setting |
Yeah, the problem is that I'm not using AsyncImage. I'm using a normal image and it only happens when a placeholder is used. Unless I'm misunderstanding something which could be the case here. |
Describe the bug
When going to a screen that has a LazyColumn, the images load. The problem is when going back a screen, then returning to the LazyColumn screen. I'm making use of Accompanist's placeholder library as well. For some reason, coil is getting stuck in a loading state.
The code that enables the placeholder:
To Reproduce
This project makes it easy to reproduce:
https://github.com/jakepurple13/CoilWeirdness
When running, press
Go
then press on an image or back and it will return to theGo
screen. Then pressGo
again and stuck loading state happens.Logs/Screenshots
https://github.com/coil-kt/coil/assets/2065574/5bb84723-659f-4c0b-b820-4b08b9e09589
Version
Coil version: 2.4.0
The text was updated successfully, but these errors were encountered: