question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default MemoryCachePolicy fails in a RecyclerView (default imageLoader & default parameters)

See original GitHub issue

When I load an Image from an URL with the following code and reopen this screen, the ImageViews are mostly just blank. (probably due to caching issues)

fun ImageView.loadUrl(url: String) {
    load(url)
}

When I change the CachePolicy of the memoryCache to anything except CachePolicy.ENABLED (even to READ) the images are shown properly on every attempt, e.g.:

fun ImageView.loadUrl(url: String) {
    load(
        uri = url,
        builder = {
            memoryCachePolicy(CachePolicy.READ_ONLY)
        }
    )
}

I guess the expected behaviour would be showing the cached bitmap, and then replace with the image from the network call. When I tried to debug this with the callbacks in target, onStart and onSuccess were successfully called. Unfortunately I cannot view the bitmap on debug there because of bitmap configuration issues.

coil 0.11.0 Pixel 4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kkcodingscommented, May 22, 2020

When i tried to build a small sample, I found the source of this issue:

The RecyclerView had hasFixedSize = true and the list got an empty list, and afterwards the real dataset, which was causing the issue obviously. I have still no idea, why it worked at the first attempt, and failed at the second one, and why the memory-caching of coil is affected by that.

Nevertheless thanks for your support.

0reactions
colinrtwhitecommented, May 22, 2020

Hmm those logs are the expected behaviour. Do you have a small sample that reproduces the bug? It’s not clear what the root cause is based on the logs and I’m not able to reproduce locally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - Coil
ImageLoader s handle caching, data fetching, image decoding, request management, bitmap pooling, memory management, and more. The default Coil artifact ( io.
Read more >
how to display default image in recycler view - Stack Overflow
if you use volley ,you can do this : ImageListener listener = ImageLoader.getImageListener(imageView, R.drawable.default_image, ...
Read more >
RecyclerView.Adapter - Android Developers
The default implementation of this method returns NO_ID . Parameters. int position. Adapter position to query. Returns ...
Read more >
Using the RecyclerView | CodePath Android Cliffnotes
You may notice an error that says "There is no default constructor available in androidx.recyclerview.widget.ListAdapter ". The reason is that you will declare ......
Read more >
Everything You Should Know To Create A Recyclerview
The third parameter is a boolean, when set true, items are shown in reverse order. Default Linear Layout: // get the reference of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found