Image caching and lv_img_set_src()


System information:

  • MPU: Arm Cortex-A7 (528 MHz).
  • RAM: External DDR3 SDRAM of 128 MBytes.
  • 1 Display of 320x240.
  • OS: Linux
  • Interface to the display: SPI (~4 Hz refresh rate)

I have 200 png images stored in a file system. In total they take 1,4 MBytes, so there is RAM enough to cache them.
My applications consists of a single display in which I have to represent overlapped combinations from the 200 images. But not all 200 images will be overlapped at the same time, only up to 60 images will be overlapped at the same time.
To do this:
I do not use threads and I use a single process.
I set ‘LV_HOR_RES_MAX’ to 240 and ‘LV_VER_RES_MAX’ to 320.
I call ‘lv_tick_inc()’ within the signal context from a timer and I specify the actual time (not the configured timer periodicity). The timer is configured to 5 ms, so most of the times 5 to 7 ms are elapsed, but from time to time (once every minute) 50 ms or more can be elapsed.
I call ‘lv_task_handler()’ whenever the sleep time it returns has expired and I do it from the Main thread context (the only one apart from signal).
Within the main thread I create a single screen object via ‘lv_obj_create()’. Within this screen object, I create 60 different image objects via ‘lv_img_create()’. None of these 60 image objects has a path assigned yet. I set 200 images as cache size with ‘lv_img_cache_set_size()’. I am not using ‘lv_img_cache_invalidate_src()’. Then my application starts updating the paths of those 60 images using different path locations from the 200 images with ‘lv_img_set_src()’.
Everything looks okay and smooth in the display according to the system specs I defined before.


  • ‘lv_task_handler()’ can take up to 1,1 seconds and it makes it very hard to do things in parallel without multi-threading or multi-processing.


  • Is there a way to improve performance (reduce the time in ‘lv_task_handler()’) by managing the library different than I do or using different APIs than I do? For example, a different way to handle what my application does would be to have an image object per image, i.e. 200 image objects instead of 60, and then use ‘lv_obj_set_hidden()’ instead of ‘lv_img_set_src()’ to make sure than no more than 60 images are shown in the display at the same time. But I don’t know whether this would improve performance, since I am already setting the cache size to 200 images.
  • Would calling ‘lv_img_cache_invalidate_src()’ improve performance in my case having a cache size of 200 images?

Best regards,