coil-kt / coil

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

Image Not Loading After Reloading or Returning to View - Possible Issue with Coil 3.0.2 #2677

Closed cdanielvalente closed 1 day ago

cdanielvalente commented 1 day ago

After updating Coil from version 2.7.0 to 3.0.2, I’m experiencing an issue where previously network-loaded images are not displayed upon reloading or returning to the view. Instead of loading the images again, the views show blank or empty spaces where the images should be.

I am uncertain if this is a bug in version 3.0.2 of Coil or if there is an implementation issue due to changes in the API for the latest version.

Steps to Reproduce:

  1. Update Coil from version 2.7.0 to 3.0.2.
  2. Implement Coil to load images via network in a view.
  3. Load the view for the first time (images load as expected).
  4. Navigate away from the view, then return or reload it.
  5. Observe that the images are not displayed, leaving blank spaces.

Expected Behavior: Images should reload and display properly when returning to the view or reloading it, as they did in version 2.7.0.

Actual Behavior: Upon returning to a view or reloading it, previously loaded images do not appear and are replaced with blank spaces.

Environment:

Coil Version: 3.0.2 Previous Coil Version: 2.7.0 Platform: Android Language/Framework: Kotlin, Compose Additional Information: I’m open to suggestions in case there is a new implementation approach required in Coil 3.0.2 that I may have missed. Any guidance on resolving this or confirming it as a version-related issue would be greatly appreciated.

image

val imageLoader = ImageLoader.Builder(context)
        .components {
            add(
                OkHttpNetworkFetcherFactory(
                    callFactory = {
                        createSecureOkHttpClient()
                    }
                )
            )
        }
        .build()
fun createSecureOkHttpClient(): OkHttpClient {
    return OkHttpClient.Builder()
        .build()
}
AsyncImage(
    model = ImageRequest.Builder(LocalContext.current)
        .data("$pathItemImage${itemID}_MD.webp")
        .crossfade(true).build(),
    contentDescription = null,
    contentScale = ContentScale.FillBounds,
    imageLoader = imageLoader,
    error = painterResource(id = R.drawable.error),
)
colinrtwhite commented 1 day ago

@cdanielvalente Please enable logging and attach any stack traces.

cdanielvalente commented 1 day ago

Sorry, the problem was my implementation, I had it poorly structured.