Using delay with LVGL causes freezing


When using delay with LVGL, very randomly it freezes;
I’ve made an app, that every few seconds updates some values on a display, but every time I use for example an vTaskDelay(1000 / portTICK_PERIOD_MS);, there is a random chance (1/10 maybe) that it will either freeze, and not respond to anything else, or will glitch in some unexpected way. Sometimes (but ONLY sometimes), spamming lv_task_handler(); helps, but that is not consistent either.

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


What LVGL version are you using?


What have you tried so far?

I have made sure that the

static void lvgl_timer_task(void* param)
	while(1) {
		vTaskDelay(10 / portTICK_PERIOD_MS);
xTaskCreatePinnedToCore(lvgl_timer_task, "lvgl Timer", 10000, NULL, 4, NULL, 1);

is running. I have ran out of ideas on how to get around this - maybe LVGL simply hates the vTaskDelay in other parts of the code so much, but I wasn’t able to find any source confirming it online. I know I can delay certain functions from being called with some builtin LVGL function, but I cannot really do that, since I need to wait for different periods of time in different parts of code.

My main question is if that is some known thing and how to get around it. If there is some idea on what test should I perform in order to pinpoint this problem I would be very glad.

Such occasional freezing is often caused because you need to lock your treads.

I’m doing it like so


extern SemaphoreHandle_t xGuiSemaphore;

    while (1) {


        // Try to take the semaphore, call lvgl related function on success 
        if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY)) {

Everywhere else when ANY LVGL function is used to update the display, except in events:

SemaphoreHandle_t xGuiSemaphore;

				if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY)) {
					lv_label_set_text_fmt(ui_s5SensorVal,"%d", sensor_resistance);

More info from Espressif:. Mutex Semaphore