Failing to load .glb/.gltf objects after lv_timer_handler() runs. - wayland display crashes while application keeps running
LVGL version
v9.5.0
Platform
Hello,
Thank you for your great library.
I am currently using lv_port_linux with LVGL simulator and also Wayland to create an app where the goal is to load .glb/.gltf objects dynamically depending on user input. Ideally, only one 3d model is loaded at a time and, when the user input changes, the screen updates or is re-initialized with the new model while the old model is discarded.
What happened?
To keep the app lightweight, I want to avoid loading all the needed .glb models and/or creating a dedicated screen for each at initialization time and then choosing one of these objects/screens depending on user input, despite this working well in the current implementation.
However, when I try to use lv_gltf_load_model_from_file function after the first time lv_timer_handler() is called, the full display turns completely white and unresponsive. While the app seems to keep running (timers, etc) according to logs, it essentially crashes. This happens whether lv_gltf_load_model_from_file is called from a callback function, a timer, or even within the lv_timer_handler() loop, making the user input -> model load strategy not function.
If I comment out the lv_gltf_load_model_from_file call, the app keeps running normally, without loading any .glb file of course, but the rest of the widgets (buttons, etc) are displayed correctly.
My question is whether:
- I am approaching this problem incorrectly and there is a better way to achieve the desired result;
- if this is a bug/not allowed in LVGL or a problem with my current implementation.
Thank you very much for your help.
How to reproduce?
For example, if a whole screen is created from a button callback:
/*
* Screen creation where app holds the screen's variables.
*/
void create_glb_screen() {
lv_obj_t * scr = lv_obj_create(NULL);
app.viewer = lv_gltf_create(scr);
lv_obj_set_size(app.viewer, LV_PCT(100),LV_PCT(100));
lv_obj_remove_flag(app.viewer, LV_OBJ_FLAG_SCROLLABLE);
app.model = lv_gltf_load_model_from_file(
app.viewer,
path
);
LV_ASSERT_NULL(app.model);
...
}
/*
* Callback to create a .glb rendering screen from a button click.
*/
void callback_to_create_glb_screen() {
create_glb_screen()
}Source: lvgl/lvgl