lvgl / lv_drivers

TFT and touch pad drivers for LVGL embedded GUI library
https://docs.lvgl.io/master/porting/index.html
MIT License
290 stars 309 forks source link

Fix crash when running on Weston 10.0.2 w/pixman rendering backend #308

Closed etag4048 closed 3 months ago

etag4048 commented 3 months ago

Hello,

When running the wayland client under weston v10.0.2 with the pixman software rendering backend, The demo application crashes even before the first frame is shown.

A detailed explanation/investigation is available here https://github.com/etag4048/lv_drivers/blob/weston-pixman-crash-doc/wayland/doc/shared_memory_manager.txt

TL;DR The shared memory manager introduced in #270 was not designed to work with simple compositors using pixman, it's only suited for compositors using EGL as a backend, on systems not constrained by memory since it allocates buffers on demand inside the lv_wayland_flush function.

However, this is not possible on Weston (and probably other more simplistic wayland compositors), because in Weston's case it does not tolerate the resizing of the SHM pool in between two frames.

This PR is only to get the discussion started and is very much a work in progress, as there is still a crash when the window is resized.

A few questions need to be answered.

Is there a need for a double buffered mode for this driver? It seems there are several issues mentioning Weston shipped with Poky from the Yocto project. Or is it intended to be used solely as a LVGL simulator on complex EGL backed compositors ?

While #270 is certainly more flexible, the simple approach taken in the stale pr #253 seems to work best for software rendering, so the solution is to configure shared memory manager to pre-allocate two buffers for the window body. Or should it be ported to the new display API used in LVGL 9 ? as mentioned in issue #287

Any feedback is greatly appreciated, Best regards

etag4048 commented 3 months ago

This is not a work in progress anymore, it's a proper fix for the multiple issues that were apparent on Weston with a non-EGL backend when using the shared memory manager introduced in PR#270. This commit changes the way subsurfaces are handled, they are now in 'sync mode' , they are not destroyed on each resize instead another buffer is attached and the position is updated , it also fixes a race condition where XDG configure was called after the the first flush occured. There is also another patch on the way that will make the wayland client compatible with LVGL9. Moreover, It was tested on Gnome and Weston 10 & 9 with both backends and on different hardware with decorations and without decorations with wl_shell and xdg_shell. Seems to be working correctly.

kisvegabor commented 3 months ago

It's amazing, thank you very much! It's even better that apparently you have tried it with LVGL v9 too. If so, could you send a PR for the lvgl master too?

etag4048 commented 3 months ago

Thanks, I sure will when it's ready.