LVGL not refreshing the display at set frame rate

Hi,

I have some long running circular horizontal scrolling animations going on, and I can clearly see that the animation is jittery.

I have narrowed down the problem to LVGL skipping frames. Before I move forward to try to debug this problem, I want to check whether this is even a bug or if it’s expected behavior.

I have LV_DISP_DEF_REFR_PERIOD set to 30. The animation speed is set to 33 pixels/s as follows:

lv_style_set_anim_speed(&label_style, 33);

These are logs explaining the issue:

// The display is refreshed with this call to the timer handler
[Info]  (18.857, +0)   lv_timer_handler: begin  (in lv_timer.c line #70)
[Info]  (18.857, +0)   lv_timer_exec: calling timer callback: 0x6001ff41  (in lv_timer.c line #319)
[Info]  (18.857, +0)   _lv_disp_refr_timer: begin   (in lv_refr.c line #293)
[Info]  (18.871, +14)  call_flush_cb: Calling flush_cb on (0;0)(255;63) area with 0x20008760 image pointer  (in lv_refr.c line #1044)
[Info]  (18.871, +0)   _lv_disp_refr_timer: finished  (in lv_refr.c line #445)
[Info]  (18.871, +0)   lv_timer_exec: timer callback 0x6001ff41 finished  (in lv_timer.c line #321)
[Info]  (18.872, +1)   lv_timer_handler: finished (15 ms until the next timer call)   (in lv_timer.c line #145)

// Called the timer handler 15 ms later, as requested by LVGL, but nothing was rendered
// This should have refreshed the display in order to keep the FPS close to 30 fps
[Info]  (18.887, +15)  lv_timer_handler: begin  (in lv_timer.c line #70)
[Info]  (18.887, +0)   lv_timer_exec: calling timer callback: 0x60038e79  (in lv_timer.c line #319)
[Info]  (18.887, +0)   lv_timer_exec: timer callback 0x60038e79 finished  (in lv_timer.c line #321)
[Info]  (18.887, +0)   lv_timer_handler: finished (30 ms until the next timer call)   (in lv_timer.c line #145)

// Called the timer handler 30 ms later, as requested by LVGL, but nothing was rendered either
[Info]  (18.917, +30)  lv_timer_handler: begin  (in lv_timer.c line #70)
[Info]  (18.917, +0)   lv_timer_exec: calling timer callback: 0x60038e79  (in lv_timer.c line #319)
[Info]  (18.917, +0)   lv_timer_exec: timer callback 0x60038e79 finished  (in lv_timer.c line #321)
[Info]  (18.917, +0)   lv_timer_handler: finished (0 ms until the next timer call)  (in lv_timer.c line #145)

// Because the timer handler returned 0 to next call, it gets called immediately
// This call finally refreshes the display, 60 ms after the last refresh
[Info]  (18.917, +0)   lv_timer_handler: begin  (in lv_timer.c line #70)
[Info]  (18.917, +0)   lv_timer_exec: calling timer callback: 0x6001ff41  (in lv_timer.c line #319)
[Info]  (18.917, +0)   _lv_disp_refr_timer: begin   (in lv_refr.c line #293)
[Info]  (18.930, +13)  call_flush_cb: Calling flush_cb on (0;0)(255;63) area with 0x20006760 image pointer  (in lv_refr.c line #1044)
[Info]  (18.931, +1)   _lv_disp_refr_timer: finished  (in lv_refr.c line #445)
[Info]  (18.931, +0)   lv_timer_exec: timer callback 0x6001ff41 finished  (in lv_timer.c line #321)
[Info]  (18.931, +0)   lv_timer_handler: finished (16 ms until the next timer call)   (in lv_timer.c line #145)

I did go through the changelog to see if there was a fix in a newer version related to this but I didn’t find one.

What MCU/Processor/Board and compiler are you using?

NXP MIMXRT1010, arm gcc 10.3

What LVGL version are you using?

Some commit after 8.2.0:
340d45cfa91b7108d43af906fc51b1c431877827

What do you want to achieve?

Stable frame rate, get rid of jittery animations/scrolling

What have you tried so far?

Call lv_timer_handler() more often.

Screenshot and/or video

I’d post the animation but the jitter is not really visible in video.

I found out what the problem is and I’ve opened a PR to address this issue.