Different behavior of the built-in image cache for filesystem images

While working on this I noticed that image cache, while used with images from filesystem, results in almost no speedup. I would expect the images to be cached in RAM, but it seems only the files descriptors are cached and the files left open. The cache life value is also calculated only based on open (link).

I’ve implemented my own simple cache that caches whole images in SPIRAM
and got much better results.

Wouldn’t it be better change this behavior of the built-in image cache feature?

If the whole image would be cached it used many RAM and I’m not the users wants it by default.

If you want the image to be fully buffered you can copy it from the file system to an array in your code and build an lv_img_dsc_t using that array.

1 Like

Yes, this is exactly what I’ve done. My point is that the built-in cache option for filesystem images has little sense.

The purpose of image caching is not to speed up loading binary images from files. But e.g. to save the time of decoding png images. However it’d be possible to add a custom image decoder that loads the whole image into RAM.

Okay, so you admit that for converted binary images (not PNG) it make little sense to use/have the cache.

Yes, cache doesn’t help much in this case.