Is it correct for LV_USE_PERF_MONITOR to show a steady 33FPS in PC Simulator?

Description

When I’m running any lvgl application on my PC with LV_USE_PERF_MONITOR enabled, I see what looks like accurate fluctuations in CPU utilization, but a steady 33FPS. I thought maybe the framerate is pegged at 33 in this mode, but I can’t find anything that suggests that. Furthermore, when running the benchmark demo, I see results that contradict the readout. Does this feature not work correctly when running on PC?

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

PC Simulator on Ubuntu 22.04 on WSL2.

What LVGL version are you using?

8.3

What do you want to achieve?

I’d like the FPS counter to indicate to me the relative complexity of what I’m drawing in simulator mode.

What have you tried so far?

I’ve messed with the lv_tick_

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

int main(int argc, char **argv)
{
  (void)argc; /*Unused*/
  (void)argv; /*Unused*/

  /*Initialize LVGL*/
  lv_init();

  /*Initialize the HAL (display, input devices, tick) for LVGL*/
  hal_init();

  lv_demo_music();

//  user_image_demo();

  while(1) {
    /* Periodically call the lv_task handler.
     * It could be done in a timer interrupt or an OS task too.*/
    lv_timer_handler();
    usleep(5 * 1000);
  }

  return 0;
}

Screenshot and/or video

Yes, this is normal. By default the lvgl display is updated periodically from an lv_timer. Calling lv_timer_handler(), even at a high rate, doesn’t automatically imply calling this display update timer at the same rate. lv_timer_handler() just pushes the timeout handling along until it notices that enough time has passed for the display to need updating.

By default the display refresh period is 30ms (https://github.com/lvgl/lvgl/blob/release/v8.3/lv_conf_template.h#L80-L81). 1000ms per second divided by 30ms ends up being around 33 updates or frames per second.

There’s a bit more discussion about this at Display interface — LVGL documentation. As that doco says, the fps counters that lvgl tries to keep does rely on the
LV_DISP_DEF_REFR_PERIOD value, so you have to be careful how you measure.

If you’re really just trying to push lvgl as fast as possible to see how complicated stuff is, I would call _lv_disp_refresh_timer from the while loop, count how many times you go through that loop, and report that periodically (every second or so). Alternatively, you could try actual profiling/tracing.

Thanks @dlg, that makes sense.