Interface refresh exception

Hello everyone:
the following is my description of the problem, I hope everyone can help to solve this problem, thank you very much


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


What do you experience?

littlevgl version:5.30
There are three types of interfaces in the product:
1. Message interface: Create a message object directly on the screen parent object, other child objects depend on this parent object, delete the parent object after leaving the interface

2. Device interface:Created directly on the screen parent object, not destroyed

3. Scene interface: Create a message object directly on the screen parent object, other child objects depend on this parent object, delete the parent object after leaving the interface

Interface switching sequence:
Scenario-> device1-> device2-> device3-> scenario

Problem Description:
Press the button at normal time to switch the interface. Occasionally, extra things will refresh in the upper left corner of the scene interface. These things are not what I want

These abnormal objects are all things in my scene interface, but the display in other places is affected.

What do you expect?

I hope to solve or avoid this problem

Code to reproduce

There are more codes and more objects are involved, which cannot be copied, please understand

//Screen parent object generation
static void Display_Cht_Creat_Screen(void)

	windows_background = lv_obj_create(lv_scr_act(),NULL);
	// windows_background = lv_obj_create(NULL,NULL);
	lv_style_copy(&style_windows_background, &lv_style_plain);
	style_windows_background.body.main_color = BACK_GROUND_COLOR;
	style_windows_background.body.grad_color = BACK_GROUND_COLOR;
	style_windows_background.body.opa = LV_OPA_100;
	lv_obj_set_size(windows_background, 240, 320);
	lv_obj_set_pos(windows_background, 0, 0);
	lv_obj_set_style(windows_background, &style_windows_background);
	// vTaskDelay(pdMS_TO_TICKS(20));

	// vTaskDelay(pdMS_TO_TICKS(20));

	// UpdateSettingScreen();
	// lv_obj_set_style(windows_background, &style_windows_background);
//After investigation, when the screen object is created, the word Nodata appears. After investigation, it is found that the lv_draw_img function is called. I don't know if it has anything to do with this.
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
                 const void * src, const lv_style_t * style, lv_opa_t opa_scale)
    if(src == NULL) {
        LV_LOG_WARN("Image draw: src is NULL");
        lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
        lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL);

    lv_res_t res;
    res = lv_img_draw_core(coords, mask, src, style, opa_scale);

    if(res ==  LV_RES_INV) {
        LV_LOG_WARN("Image draw error");
        lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
        lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL);

Why can’t my other account ( post any topic?

For some reason you were flagged by the system as a spammer. I’ve manually unflagged you.

I suspect you are either accidentally creating extra objects or not hiding all the objects you need to.

thank you very much for taking the time out of your busy schedule to help me solve the problem.
Before that, I have already checked the possible problems according to the code. I also suspect that extra objects have been created, but I have not analyzed them There are redundant builds.

The following figure is a more complete graphic description

Extra note:Adding content between // is easy to reproduce such display problems

    img_scene = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(img_scene, &image_scene_pic);

    scene_selected = lv_obj_create(img_scene, NULL);
    for( u32I = 0; u32I < 5000; u32I++ )
        for( u32J = 0; u32J < 100; u32J++ );
    lv_style_copy(&style_scene_selected, &lv_style_scr);
    style_scene_selected.body.main_color = LV_COLOR_MAKE(106,235,133);
    style_scene_selected.body.grad_color = LV_COLOR_MAKE(24,241,255);
    style_scene_selected.body.radius = 6;
    style_scene_selected.body.opa = LV_OPA_0;
    lv_obj_set_style(scene_selected, &style_scene_selected);
    lv_obj_set_size(scene_selected, 100, 100);

    lv_style_copy(&style_img_scene_lable, &lv_style_transp);
    style_img_scene_lable.text.font = &pingfang_ZHT_18;
    style_img_scene_lable.text.opa = LV_OPA_100;
    style_img_scene_lable.text.letter_space = 0;
    style_img_scene_lable.text.color = WHITE_COLOR;

    LcdInterface_vSceneModule1(img_scene, psDlg->m_u8ICON[E_LCD_SCENE_ICON_0]);
    LcdInterface_vSceneModule2(img_scene, psDlg->m_u8ICON[E_LCD_SCENE_ICON_1]);
    LcdInterface_vSceneModule3(img_scene, psDlg->m_u8ICON[E_LCD_SCENE_ICON_2]);
    LcdInterface_vSceneModule4(img_scene, psDlg->m_u8ICON[E_LCD_SCENE_ICON_3]);

    img_scene_lock = lv_img_create(img_scene, NULL);
    lv_img_set_src(img_scene_lock, &image_lock);
    lv_obj_align(img_scene_lock, img_scene, LV_ALIGN_IN_TOP_RIGHT, -10, 10);    
    if( psDlg->m_bKeyLock )
        lv_obj_set_style( img_scene_lock, &style_icon_show );
        lv_obj_set_style( img_scene_lock, &style_icon_hide );

My account Joker ( has been retained again. Am I doing something wrong?

You got flagged by the system once again for typing your post too quickly. I’ve manually increased your trust level. That may help prevent this from occuring in the future.

Hi, I described before,why is it easy to reproduce this phenomenon after I create a blocking delay .(Is this illegal operation),Should I set the priority of my lvgl to the highest?
2.In addition, I have deleted a lot of code to ensure that there are no extra objects and unhidden objects, but there will still be refresh exception.(Is there any way I can see all the objects I created,such as Log?)
lv_task_handler();-This function is in a 5ms timer,It seems that there are new actions based on the message.
Very grateful for your help

Another problem,the program will be reset during initialization

Are you using multiple threads? Do you guard LittlevGL calls with a mutex?

Thank you. Regarding the problem of program restart, I adjusted the execution order of some programs, and the problem has been fixed.
void lvgl_init()
/* LittlevGL work fine only when CONFIG_FREERTOS_HZ is 1000HZ */
assert(CONFIG_FREERTOS_HZ == 1000);

/* Initialize LittlevGL */

esp_timer_create_args_t timer_conf = {
    .callback = lv_tick_timercb,
    .name     = "lv_tick_timer"

esp_timer_handle_t g_wifi_connect_timer = NULL;
esp_timer_create(&timer_conf, &g_wifi_connect_timer);

esp_timer_start_periodic(g_wifi_connect_timer, 1 * 1000U);

/* Display interface */
lvgl_lcd_display_init(); /*Initialize your display*/
/*user init*///myself
if( s_userInit )

/* Input device interface */
lv_indev_drv_t indevdrv = lvgl_indev_init(); /Initialize your indev/

esp_timer_create_args_t lv_task_timer_conf = {
    .callback = lv_task_timercb,
    .name     = "lv_task_timer"

esp_timer_handle_t lv_task_timer = NULL;
esp_timer_create(&lv_task_timer_conf, &lv_task_timer);

esp_timer_start_periodic(lv_task_timer, 5 * 1000U);

vTaskDelay(LVGL_INIT_DELAY / portTICK_PERIOD_MS);    // wait for execute lv_task_handler and lv_tick_inc to avoid some widget don't refresh.

/* Calibrate touch screen */
lvgl_calibrate_mouse(indevdrv, false);

I added my initialization here to solve the problem。

There is still a remaining problem, as shown in the figure
My interface occasionally refreshes incompletely

Is there any way to avoid or solve the current situation

This looks like it might be an issue with your display driver.

Do you mean that there is something wrong with the driver part of my ST7789? Which point does it refer to? This phenomenon happens by accident, and when I call the function of lvgl, inserting a delay function between the two functions will be more prone to this problem.

It looks like you are using LittlevGL in a multithreaded environment. You need to use a mutex around all calls to LittlevGL functions.


This is not a safe way of avoiding the issue. Depending on the timing you could end up with lv_task_handler running concurrently with another LittlevGL API. This is explained in the documentation.