Describe the bug
When you try to render a recycler with a lot of images and some of them don't exist, the performance of the view is seriously affected.
Expected behavior
The performance of the view shouldn't be affected. As an example, the performance for this scenario with Glide works right.
To Reproduce
Create a list of urls pointing to a non existing link, create an adapter for a recycler and try to scroll the recyclerview. You will see a problem with the performance.
Logs/Screenshots
Not applicable.
Version
0.9.0
What do you mean by performance? It is an issue with draw time, cpu usage, memory usage, or something else? I did a quick test by loading a URL that has an invalid host in the sample app and didn't notice any performance issues. If you're able to create a sample project that reproduces the issue that would help debug the issue.
Ok. I cannot do it until Monday probably.
Anyway, You can create a recyclerview with 30 or 40 items with different non existing url. If you make scroll, the movement is not fluid.
In my example I'm using databinding with this code to load images:
@BindingAdapter("imageUrl")
fun loadImageByUrl(view: ImageView, url: String?) {
if (url != null) {
view.load(url) {
crossfade(true)
(view.context as? LifecycleOwner)?.let { lifecycleOwner -> lifecycle(lifecycleOwner.lifecycle) }
placeholder(R.drawable.placeholder)
error(R.drawable.error)
} else {
view.setImageResource(R.drawable.placeholder)
}
}
Not sure if it helps, but you can collapse that into:
view.load(url) {
crossfade(true)
placeholder(R.drawable.placeholder)
fallback(R.drawable.placeholder) // Fallback is used if url is null.
error(R.drawable.error)
}
Coil will autodetect the view's lifecycle.
So I've tested this by altering the sample app:
load("http://123.com") {
placeholder(ColorDrawable(item.color))
}
and I failed to see any performance issues :-/
I have re-created the same scenario and now I cannot reproduce this error... I don't know if I have changed anything else, but now the scroll is working fine. I can only apologize for the inconvenience and congratulate you for your library.
You can close this ticket.
@RubenGonzalezGonzalez No worries!
Most helpful comment
So I've tested this by altering the sample app:
load("http://123.com") { placeholder(ColorDrawable(item.color)) }and I failed to see any performance issues :-/