-
Notifications
You must be signed in to change notification settings - Fork 662
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
Placeholder issue with reloading same images on recyclerView when the images are not in memory #797
Comments
The device in the GIF is an Android 8 device using It looks to me that the |
Adding some more gifs to help visualize the issue I'm seeing. Here two mountains images are
Edit: Adding some logs with |
Added some code to Code section in the description. |
Some more updates... It does look like the images have to be in-memory to avoid this issue on When I set However, even with the same set of images, the gifs and video frames result in memory most of the time on Do you have any plan or suggestions for supporting downsample image requests at the time of request creation? Please let me know if you have any other suggestions to increase memory hit with images from gif/video frame decoders. |
Glide's gif downsizing done in |
Also found this logic which might have been the reason why I saw the same issue when I set
Looks like From the comment:
|
Updating my questions here based on my investigation above. I think I need support for the items below to match the
Other questions:
|
@seankim-android From the videos it looks like you're running into the flickering behaviour as Coil doesn't keep animated images in its memory cache (due to a couple reasons including animated images can only be used by one target at a time whereas bitmaps can be shared). If you're reloading the recyclerview, you'll need keep a reference to the drawable returned by Coil to set it on the new If you need global memory caching of animated images, I'd recommend creating an To answer your questions:
|
@colinrtwhite Thank you for your response and explanations. Based on your response, I think skip setting the drawable in I have some follow-up questions. 1.I wrote a similar explanation in the issue description, but I've tried using a custom What I'm looking for is similar to 2.ImageLoader already has a default memory caching implementation for Ideally, if we allocate some memory for Coil's memory cache, I think it makes sense that it covers both bitmap and non-animated drawables. But I'm also not aware of all the reasons as to why it is currently not implemented as part of Coil's memory cache. What are your thoughts on adding animated image cache to Coil and have both animated images & bitmap cache managed by the library? I'm thinking something like 3.For downsampling, I was thinking something similar to Glide's DownsampleStrategy logic. The downsampling is done after source size is read in the decoder. It uses both source size and target size (view size) to figure out final sizing. In |
val request = ImageRequest.Builder(context)
.data(url)
.target(CustomImageViewTarget(imageView))
.build()
imageView.setTag(R.id.coil_request, request)
context.imageLoader.enqueue(request)
// Call imageView.getTag(R.id.coil_request, request) inside onStart to get the latest request.
|
@colinrtwhite I was trying to skip 2 & 3 make a lot of sense. Thank you for all the clarifications. It does look like a lot of work and extra complexity. I'll see if I can solve the issue with a custom I'm hoping the tag or some other approach to skip the new request based on the previous request works out. My actual code from Thanks again for your response! I'll either close this issue or come back with new questions in the next couple of days. |
Closing with updates. Thanks again for your suggestions and clarifications.
|
Hello - I’m running into some reload/flicker issues with gif/video frame support in RecyclerView. I think it might be related to #280
We have
RecyclerView
s wherenotifyDataSetChanged()
is called under certain conditions (when clicking on the item and etc.). I’m noticing some flicker when the same images should be re-bind but they aren’t loaded from memory.For example, when the same image (I’m mostly seeing gif or video frame) is loaded after
notifyDataSetChanged()
from DISK, I’m noticing the issue from step 4 & 5 below.Image A
notifyDataSetChanged()
is calledImage A
When I load with a custom ViewTarget and disable setting the placeholder, the step 4 doesn’t happen so the same image stays between the reload. This isn't a solution because I do need to clear out the image when a new load starts, but I cannot differentiate if the view is binding from
notifyDataSetChanged()
or if it is a fresh load. I’m hoping there is a way not to callonStart()
if we’re requesting the same image.While I’m looking into why I’m not seeing the issue on Glide, I was wondering if you could advise if this can be handled from Coil. Thank you 🙇♂️
The resulting experience looks like this
Code
From RecyclerView.Adapter
The text was updated successfully, but these errors were encountered: