Skip to content

Commit 2be4e82

Browse files
FASTSHIFTpengyiqiang
and
pengyiqiang
authored
fix(refr): fix performance monitor NULL pointer access (lvgl#3105)
* fix(refr) performance monitor NULL pointer access * doc(refr): describe the setting of LV_DISP_DEF_REFR_PERIOD Co-authored-by: pengyiqiang <[email protected]>
1 parent c49430b commit 2be4e82

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/porting/display.md

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ If you have multiple displays call `lv_disp_set_deafult(disp1);` to select the d
228228

229229
Note that `lv_timer_handler()` and `_lv_disp_refr_timer()` can not run at the same time.
230230

231+
If the performance monitor is enabled, the value of `LV_DISP_DEF_REFR_PERIOD` needs to be set to be consistent with the refresh period of the display to ensure that the statistical results are correct.
232+
231233
## Further reading
232234

233235
- [lv_port_disp_template.c](https://github.com/lvgl/lvgl/blob/master/examples/porting/lv_port_disp_template.c) for a template for your own driver.

src/core/lv_refr.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,16 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
376376
}
377377
else {
378378
perf_monitor.perf_last_time = lv_tick_get();
379-
uint32_t fps_limit = 1000 / disp_refr->refr_timer->period;
379+
uint32_t fps_limit;
380380
uint32_t fps;
381381

382+
if(disp_refr->refr_timer) {
383+
fps_limit = 1000 / disp_refr->refr_timer->period;
384+
}
385+
else {
386+
fps_limit = 1000 / LV_DISP_DEF_REFR_PERIOD;
387+
}
388+
382389
if(perf_monitor.elaps_sum == 0) {
383390
perf_monitor.elaps_sum = 1;
384391
}

0 commit comments

Comments
 (0)