LVGL can't switch screen in FreeRTOS task

MCU:NXP RT1176
LVGL version:8.2

Hello,there is no touch panel on my board,so the physical keys on the board are used to switch screens.Difference screens are switched in the event key handler of every screen,and switching screen in the event hander works well.

In the meantime,I’d like to realize that switching to a shutdown screen if one of the keys is pressed for 3 seconds.So I switch the screen in the key_detect FreeRTOS task,and a bus fault occurs where PC is pointed to _lv_obj_get_layer_type() and LR is pointed to refr_obj().

It is likely that the system is drawing the current screen and interrupted by the key_detect task.All objects are deleted after I load a new screen,so the system hangs when the program resumes to draw.
How can I avoid this?

Below is the switching code:

page_switch(lv_obj_t *page, lv_scr_load_anim_t animation, bool del)
{
	lv_obj_t *act_scr = lv_scr_act();
	lv_disp_t *d = lv_obj_get_disp(act_scr);
	if(d->prev_scr == NULL && (d->scr_to_load == NULL || d->scr_to_load == act_scr))
	{
		if(del)
		{
			lv_obj_clean(act_scr);
		}
		lv_scr_load_anim(page, animation, 150, 50, del);
	}
}

Your guess is right.
lvgl is not thread safe. See the lvlg docs.
In this case you have to use a mutex/semaphore.
With a mutex/semaphore the appropriate FreeRTOS tasks can gain exclusive access to lvgl.