Stm32 lvgl 9.3 + rtthread using gif in fatfs/rom mode and get some trouble

I wanna share with you the experiment of the solution for lvgl gif stuck.

Down below is the lvgl flush task thread.

void lvgl_flush_task(void *params)
{
while (1)
{
lv_task_handler();
rt_thread_mdelay(1);
}

}
thread_lvgl_flush_task = rt_thread_create(“lvgl_flush_task”, lvgl_flush_task, NULL, 4096, 31, 1000);

Here is my lvgl gif example, I have read the doc carefully, and lvgl api offer 2 ways to open a gif.(from file or rom)

Code

ui_Gif1 = lv_gif_create(ui_Screen1);

////////////////////////////////////////////////////////////////////
lv_gif_set_src(ui_Gif1, “0:/lvgl_pic/cat_meme4.gif”);
////////////////////////////////////////////////////////////////////
lv_gif_set_src(ui_Gif1, &cat_meme);
////////////////////////////////////////////////////////////////////
lv_obj_set_width(ui_Gif1, LV_SIZE_CONTENT);
lv_obj_set_height(ui_Gif1, LV_SIZE_CONTENT);
lv_obj_set_align(ui_Gif1, LV_ALIGN_CENTER);
lv_obj_set_x(ui_Gif1, 0);
lv_obj_set_y(ui_Gif1, 50);
lv_obj_set_style_bg_color(ui_Gif1, lv_color_hex(0), LV_PART_MAIN);
lv_obj_set_style_bg_opa(ui_Gif1, 0, LV_PART_MAIN);

Screenshot and/or video

the first trouble i meet was when i use the fatfs to open a gif and play it, it will stuck after the gif play 1-3 minues.
VID_20250722_164357
I tried changed the ffconf.h / lv_conf.h / (rtthread)board.c. use 1 file lock/ larger the cache / large the thread heap/ rase the sdio div slow down the clk.
BUT still useless.
The one of solution is raise the priority of the lvgl flush task. like
thread_lvgl_flush_task = rt_thread_create(“lvgl_flush_task”, lvgl_flush_task, NULL, 4096, 8, 1000);

When I debugging i note the programe stuck in the funtion, it belong gifdec.c
so i guess the fatfs might cause some wrong.(like got interrupted while it reading data)
////////////////////////////////////////////////////////////////////////////
static void discard_sub_blocks(gd_GIF * gif)
{
uint8_t size;

do {
    f_gif_read(gif, &size, 1);
    f_gif_seek(gif, size, LV_FS_SEEK_CUR);
} while(size);

}
////////////////////////////////////////////////////////////////////////////

Another one solution is plus the “enter critical” when sdio doing io operation,