Hey guys, when I use AsyncImage from `coil` in a `...
# squarelibraries
e
Hey guys, when I use AsyncImage from
coil
in a
lazyList
I see lags during scrolling because image needs some time to load. Especially when I use VideoFrameDecoder. Does
coil
cache the result in this case? If not by default is there any API to force it using cache? In this case I will be able to prefetch the items into cache.
j
Please don't cross post as you fragment discussion and break search
e
@jw good point. I should make this post mode precise, since it’s goal is different. Let me change the question.
Changed my question to better reflect the main point.
j
Thanks. I'm actually enjoying that you're asking in here, for the record!
🙂 3
c
Which version of Coil are you using (3.x or 2.x)? Is the lag due to dropped frames or slow loading of the image? I believe
VideoFrameDecoder
has limited parallelism so it can be slow to decode lots of frames at the same time. Coil will cache the result in its memory cache until the cache fills up
If it’s dropping frames I’d recommend testing with R8 enabled and see if it’s still slow. There are also some perf improvements coming in 2.6.0 that are already present in the latest 3.x alphas
e
@Colin White I am using 3.0.0-alpha04. I am not sure about dropped frames, think that it is not the case. But the loading is pretty slow (on small local mp4 files). So I don’t need to do anything special to make it cache the result images?
c
Yep it should cache the result by default. You can verify it’s caching it by enabling logging and scrolling up and down to retry the same request. In the logs it should say it’s served from the memory cache
👍 1
Unfortunately
MediaMetadataRetreiver
(the underlying class used by Coil) is pretty slow. Probably out of scope, but if you wanted it to decode much faster you could write a
Decoder
that integrates with FFmpeg (and if you do, please open source it!). That’ll include native libs in your apk, though
e
Thank you, I will check!