How to solve the memory error when using masking to draw a arc?

We want ESP32 to be an audio player and use LVGL V8.2 to display spectrum and other information. When I use masking to draw a moving light ball as the background, the product will report an error after running for a few minutes;

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x4016448f  PS      : 0x00060230  A0      : 0x8016a1e0  A1      : 0x3f803b30  
0x4016448f: lv_draw_mask_free_param at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/lv_draw_mask.c:216
 (inlined by) lv_draw_mask_free_param at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/lv_draw_mask.c:210

A2      : 0x3f803c24  A3      : 0x3f803bbc  A4      : 0x3f803c54  A5      : 0x00000001
A6      : 0x00000000  A7      : 0x3ffcc330  A8      : 0x00007fff  A9      : 0x0000003d
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x00000000  A13     : 0x3f803bbc
A14     : 0x3f803bbc  A15     : 0x00000000  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000800f  LBEG    : 0x401643d8  LEND    : 0x401643e3  LCOUNT  : 0x0000000f  
0x401643d8: lv_draw_mask_add at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/lv_draw_mask.c:86

0x401643e3: lv_draw_mask_add at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/lv_draw_mask.c:91



Backtrace:0x4016448c:0x3f803b300x4016a1dd:0x3f803b50 0x400dc465:0x3f803cc0 0x400dc4ad:0x3f803d00 0x400dbff1:0x3f803d20 0x4015bfcd:0x3f803d40 0x4015c09f:0x3f803d60 0x40162012:0x3f803da0 0x40161ff7:0x3f803de0 0x4016203c:0x3f803e20 0x401621d4:0x3f803e50 0x4016268a:0x3f803ec0 0x40167bfb:0x3f803f20 0x400dbf6a:0x3f803f50
0x4016448c: lv_draw_mask_free_param at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/lv_draw_mask.c:215
 (inlined by) lv_draw_mask_free_param at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/lv_draw_mask.c:210

0x4016a1dd: lv_draw_sw_arc at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/draw/sw/lv_draw_sw_arc.c:118

0x400dc465: ball_color_sports at F:\MC\SpaceMan\software\esp32\build/../components/gui_task/src/sport_ball.c:196 (discriminator 3)

0x400dc4ad: ball_position_refresh at F:\MC\SpaceMan\software\esp32\build/../components/gui_task/src/sport_ball.c:317

0x400dbff1: spectrum_draw_event_cb at F:\MC\SpaceMan\software\esp32\build/../components/gui_task/src/my_music.c:79
 (inlined by) spectrum_draw_event_cb at F:\MC\SpaceMan\software\esp32\build/../components/gui_task/src/my_music.c:59

0x4015bfcd: event_send_core at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_event.c:467

0x4015c09f: lv_event_send at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_event.c:75

0x40162012: lv_refr_obj at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:188

0x40161ff7: lv_refr_obj at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:180 (discriminator 3)

0x4016203c: lv_refr_obj_and_children at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:720

0x401621d4: lv_refr_area_part at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:652

0x4016268a: lv_refr_area at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:571
 (inlined by) lv_refr_areas at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:511
 (inlined by) _lv_disp_refr_timer at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/core/lv_refr.c:313

0x40167bfb: lv_timer_exec at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/misc/lv_timer.c:313
 (inlined by) lv_timer_handler at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/misc/lv_timer.c:109

0x400dbf6a: lv_task_handler at F:\MC\SpaceMan\software\esp32\build/../components/lvgl/src/lv_api_map.h:37
 (inlined by) lvgl_task at F:\MC\SpaceMan\software\esp32\build/../components/gui_task/src/taskgui.c:129





ELF file SHA256: a9d7f26d93636dd4

CPU halted.

The code implementation of the following moving light ball

void ball_color_sports(lv_event_t * e)
{
    lv_draw_ctx_t * draw_ctx = lv_event_get_draw_ctx(e);

    lv_draw_arc_dsc_t draw_arc_dsc;
    lv_draw_arc_dsc_init(&draw_arc_dsc);
    draw_arc_dsc.opa = LV_OPA_COVER;
    draw_arc_dsc.width = 8;
    draw_arc_dsc.blend_mode = LV_BLEND_MODE_NORMAL;

    lv_point_t pos;
    for (uint8_t i = 0; i < BALL_CNT; i++)
    {
        pos.x = ball_buff[i].x;
        pos.y = ball_buff[i].y;
        draw_arc_dsc.color = lv_palette_main(COLOR_BALL[i%6]);
        draw_ctx->draw_arc(draw_ctx,&draw_arc_dsc,&pos,8,0,360);
    }

}

Can you send a more complete code to reproduce the issue? Not whole project, just to see where ball_color_sports is attached.

static void spectrum_draw_event_cb(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);

    portDISABLE_INTERRUPTS();//Open the dispatching lock, and the error does not appear again

    if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {


        lv_event_set_ext_draw_size(e, LV_VER_RES);

    }
    else if(code == LV_EVENT_COVER_CHECK) {
        lv_event_set_cover_res(e, LV_COVER_RES_NOT_COVER);
    }
    else if(code == LV_EVENT_DRAW_MAIN_END) {
        ball_position_refresh(e,fft_display_mode);
        fft_draw_pro(e,fft_display_mode);
    }
    else if(code == LV_EVENT_DRAW_POST) {

        
    }
    else if( code == LV_EVENT_DRAW_PART_END )
    {
    }

    portENABLE_INTERRUPTS();

}

lv_obj_t * create_spectrum_obj(lv_obj_t * parent)
{
    /*Create the spectrum visualizer*/
    lv_obj_t * obj = lv_obj_create(parent);

    lv_obj_remove_style_all(obj);

    lv_obj_center(obj);
    lv_obj_set_style_bg_color(obj,lv_color_black(),0);
    lv_obj_set_style_bg_opa(obj,LV_OPA_COVER,0);

    lv_obj_set_size(obj,LV_HOR_RES,LV_VER_RES);


    lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE);
    lv_obj_add_event_cb(obj, spectrum_draw_event_cb, LV_EVENT_ALL, NULL);
    lv_obj_refresh_ext_draw_size(obj);

    return obj;
}

Thank you for your reply. I am referring to the music demo, which is used to display the spectrum,

[Why do you need to enable/disable the interrupts?

Please try out these:

  • try drawing a rectangle border instead of an arc
  • increase LV_MEM_SIZE
  • enable logging (at least warnings)