Crash lv_task_handler

Description

If i change screen, it’s randomly crash.

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

ESP32 WRover

What LVGL version are you using?

ESP IDF v5
LVGL 7.5.4

What do you want to achieve?

What have you tried so far?

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.

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

Core  1 register dump:
PC      : 0x400f0aa9  PS      : 0x00060e30  A0      : 0x800f2ff0  A1      : 0x3ffcb970  
0x400f0aa9: anim_task at /home/molnarm/esp-workspace/project/components/lv_port_esp32/components/lvgl/lvgl/src/lv_misc/lv_anim.c:448 (discriminator 3)

A2      : 0x000000fd  A3      : 0xfffffffd  A4      : 0x3ffb4e50  A5      : 0xfffffc00  
A6      : 0x3ffb03cc  A7      : 0x00000000  A8      : 0x800f0abf  A9      : 0x3ffcb950  
A10     : 0xffffffff  A11     : 0x3ffb6e50  A12     : 0x00000156  A13     : 0x3ffb4fb4  
A14     : 0x000000c0  A15     : 0x0005dc00  SAR     : 0x00000000  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x0000003f  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  


Backtrace: 0x400f0aa6:0x3ffcb970 0x400f2fed:0x3ffcb990 0x400f30ba:0x3ffcb9b0 0x400d80fc:0x3ffcb9d0 0x4008dee5:0x3ffcba40
0x400f0aa6: anim_task at /home/molnarm/esp-workspace/project/components/lv_port_esp32/components/lvgl/lvgl/src/lv_misc/lv_anim.c:447

0x400f2fed: lv_task_exec at /home/molnarm/esp-workspace/project/components/lv_port_esp32/components/lvgl/lvgl/src/lv_misc/lv_task.c:409 (discriminator 1)

0x400f30ba: lv_task_handler at /home/molnarm/esp-workspace/project/components/lv_port_esp32/components/lvgl/lvgl/src/lv_misc/lv_task.c:129

0x400d80fc: menuTask at /home/molnarm/esp-workspace/project/main/guiTask.c:118

0x4008dee5: vPortTaskWrapper at /home/molnarm/esp-idf/esp-idf-v5.0.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:154





ELF file SHA256: a905f799158a3934

CPU halted.
	    while (1) {
	        vTaskDelay(pdMS_TO_TICKS(50));
	        if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY)) {

	        	if(lv_scr_act() == scrMenu){
		        	refreshVoltage();
		        		if(timeIsSet == true){
				        	refreshTime();
		        		}
	        	}

	        	if(lv_scr_act() == scrChart){
	        		lv_chart_refresh(chart);
	        	}
				lv_task_handler();
	        	xSemaphoreGive(xGuiSemaphore);
	       }
	    }

void refreshChart(){

    esp_timer_init();

    esp_timer_create_args_t timer_args = {
        .callback = timer_callback,
        .arg = NULL,
        .name = "drawChartTimer"
    };

    esp_timer_create(&timer_args, &timer);

    const int64_t interval = 1000000;
    esp_timer_start_periodic(timer, interval);

}

void timer_callback(void* arg) {
	if(chartRun){
	drawChart(getVoltage());
	}

}


void drawChart(){
	float chart_value = getVoltage();
	if(i == 0){
		min = chart_value-10;
		max = chart_value+10;
	}
	if(i < measure_time_value){

		if(writeFile_measure(i, chart_value) == 1){
			chartRun = false;
			// i = measure_time_value +1;
			vTaskDelay(pdMS_TO_TICKS(1000));
			lv_scr_load(scrMenu);
		}

		if(chart_value >= max){
			max = chart_value;
		}
		if(chart_value <= min){
			min = chart_value;
		}
		float temp = 1;
		float max_temp = max - chart_value;
		float min_temp =  chart_value - min;

		if(max_temp > min_temp){
			temp = max_temp;
		}else{
			temp = min_temp;
		}

			    lv_label_set_text_fmt(max_label, "%.0f", chart_value+temp);
			    lv_label_set_text_fmt(min_label, "%.0f", chart_value-temp);
			    lv_label_set_text_fmt(avg_label, "%.0f", chart_value);
			    lv_label_set_text_fmt(up_label, "%.0f", chart_value+(temp/2));
			    lv_label_set_text_fmt(down_label, "%.0f", chart_value-(temp/2));

		lv_chart_set_range(chart, chart_value-temp, chart_value+temp);
		ser1->points[i]=chart_value;

}
	i++;
}


Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

You might be trying to update your label objects that is no longer valid. When you create a label are you creating them locally or globally? If locally then they’re out of scope when you change screens. without seeing the full code It’s hard to see the problem. Are you trying to read an sd card in an interrupt?

To start with try this for everything you want to update,
if (lv_obj_is_valid(max_label)) lv_label_set_text_fmt(max_label, “%.0f”, chart_value+temp);

That checks if the object is valid before trying to update it.

If that doesn’t fix the problem you might have to make a state machine to handle your code because having a delay in a interrupt can cause the wdt to trigger I’m pretty sure. Interrupts are meant to be very short.

Backtrace show anim crash , then maybe you switch screen on anim run state.
And too refresh chart you call from timer callback = ISR. Not good practice.