lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
250 stars 161 forks source link

Update the webassembly part to to latest master #289

Closed kisvegabor closed 1 year ago

kisvegabor commented 1 year ago

In the latest LVGL master the handling of GC roots was updated. @embeddedt, do you have some free time to update the webassembly port?

We have tried it, but it crashed with memory access error. Probably we are missing something, but we can't see what.

embeddedt commented 1 year ago

I can look into this in a few days. Do you know if lv_micropython master can compile and pass CI with the update? It's easier to debug that than the WASM port.

kisvegabor commented 1 year ago

Thank you!

Right now we are using the

The CI is passing, but we have disabled some MicroPython examples because they weren't updated yet with the latest MicroPython changes.

kisvegabor commented 1 year ago

cc @leidto

embeddedt commented 1 year ago

@kisvegabor I think I have found the issue after some debugging. The lv_initialized variable was moved into the new globals structure, which is only initialized when lv_init is called. However there are functions which call lv_is_initialized before lv_init (such as the constructor in display_driver_utils), and at that time, LV_GLOBAL_DEFAULT() is not initialized yet. This causes a segfault if debug is enabled, and weird behavior consistent with memory corruption otherwise.

To confirm this theory I replaced lv_initialized with a static variable, after which the GUI appears to initialize and run without problems.

embeddedt commented 1 year ago

I'm also not sure why the CI does not pick up on this - perhaps it never makes any calls to lv_is_initialized before LVGL has already been initialized.

kisvegabor commented 1 year ago

Thank you! Could you try if modifying lv_is_initialized() like this solves the issue?

bool lv_is_initialized(void)
{
#if LV_ENABLE_GLOBAL_CUSTOM
    if(LV_GLOBAL_DEFAULT()) return lv_initialized;
    else return false;
#else
    return lv_initialized;
#endif
}
embeddedt commented 1 year ago

Yes, this works.

kisvegabor commented 1 year ago

Great, I've just added the above changes.

kisvegabor commented 1 year ago

@embeddedt Could you confirm if the JS port is working with the latest LVGL master and if so update it?

embeddedt commented 1 year ago

Typically @amirgon and I have had an unwritten convention where the main master branch of lv_micropython is updated first and then I merge it to the JS branch. Just wanted to clarify that the multi-instance changes are special and I should update JS out-of-order?

kisvegabor commented 1 year ago

Please update it out of order as we still don't how and when will we merge the feat/multi-instance branch back to master. Until that it would be great to make the latest LVGL master available in the online simulator.

embeddedt commented 1 year ago

Updated and deployed. :+1:

kisvegabor commented 1 year ago

Thank you :pray: