Using delay with LVGL causes freezing

Description

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?

ESP32S3

What LVGL version are you using?

v8

What have you tried so far?

I have made sure that the

static void lvgl_timer_task(void* param)
{
	while(1) {
		lv_timer_handler();
		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

Taskhandler:

extern SemaphoreHandle_t xGuiSemaphore;

    while (1) {

        vTaskDelay(pdMS_TO_TICKS(10));

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

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);
					xSemaphoreGive(xGuiSemaphore);
				}

More info from Espressif:. Mutex Semaphore