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 308 forks source link

LVGL 8.3+wayland can't find wayland shell #311

Open arilink opened 1 month ago

arilink commented 1 month ago

weston version:10.0.0 LVGL version:8.3.0 LVGL driver 8.3.0

I tried to run LVGL on the rk3568 platform. The macro definition enables wayland and XDG shell, but the segment err is prompted when lvgl demo is run, so I further debug the problem that lvgl cannot find wayland shell. But my qt program can work normally, what could be the problem?

image

arilink commented 1 month ago

image

arilink commented 1 month ago

After searching the problem step by step, I found that weston10 did not have wl_shell interface, instead of xdg_shell, so I opened the macro definition of XDG_SHELL, searched the header file and lib again, and compiled and ran it. At this time, the following error occurred, I do not know how to solve it

arilink commented 1 month ago

image

kisvegabor commented 1 month ago

@daniel-rossier it might be useful for the LVGL v9 Wayland driver.

daniel-rossier commented 1 month ago

Thanks Gábor! Indeed, it may help; I forward the info to @etag4048 who is nearly ready to submit a PR with the support of LVLG 9 in wayland.

arilink commented 1 month ago

So the lvgl v9 doesn't have this problem?

etag4048 commented 1 month ago

@arilink Did you update the lv_drv_conf.h and set LV_WAYLAND_XDG_SHELL to 1 ? Support for wl-shell has been deprecated for 3 years, it has been dropped in Weston 10.x

arilink commented 1 month ago

@etag4048 Yes, I have set LV_WAYLAND_XDG_SHELL to 1 but it still won't display properly, this picture is USE LV_WAYLAND_XDG_SHELL ![Uploading image.png…]()

etag4048 commented 1 month ago

@arilink Looking at the screenshots more carefully, there is something abnormal in the wayland debug logs. It seems like create_window is called two times since xdg_toplevel@12.set_title is present two times, are you calling lv_wayland_create_window multiple times ?

At it's core this problem is caused by a race condition that is apparent on some weston configurations. The buffer is attached to the surface before weston sends the configure event. Upon the configure event xdg_surface_handle_configure is called where the surface_configured flag is set. Instead, in your case the surface_configured is set in create_graphic_obj and when LVGL calls the flush cb _lv_wayland_flush on line 1992 the buffer gets attached too early..

Try commenting out the line 1411 obj->surface_configured = true; Add wl_display_dispatch(application.display); in create_window right after wl_surface_commit(window->body->surface); on line 1800.

Also check why xdg_toplevel@12.set_title is present two times.

Please avoid screenshots, you can capture the wayland logs like so ./your_app 2>/tmp/wayland_debug and then paste the logs it makes life easy :)

arilink commented 1 month ago

@etag4048 I only called lv_wayland_create_window once in main.c file. You mean that surface was not fully configured when flush cb was used, so this problem occurred, right? I uploaded wayland.c, could you please help me adjust the code, because the code line number you described seems to be inconsistent with mine wayland.zip

etag4048 commented 1 month ago

@arilink It looks like lvgl drivers on the rk3568 are outdated, please apply the patch https://github.com/lvgl/lv_drivers/commit/c8d483f308abaf5d6796e1fbe7605af610a31709 this issue has been fixed in commit c8d483f by previous contributors. Another solution could be to update to release/v8.3 the above answer is applicable on 8cdabe8 you have to checkout the correct branch to be on version 8.3. Also weston 10 is not the most up date version.

arilink commented 1 month ago

OK. I will try release/v8.3

arilink commented 1 month ago

@etag4048
After replacing the Driver of release/v8.3, lvgl can display normally, but there will be other problems, as follows 1.RK3568 hardware supports multi-screen display, so does weston. I plan to use HDMI as the main display, run Qt app, and DSI as the secondary display to display lvgl app

  1. I start the Qt app first, and once I run lvgl->demo qt app the app screen disappears
  2. In the/etc/XDG/weston/weston. Ini. I configured two outputs and corresponding app ids Where could this be a problem?
arilink commented 1 month ago

lvgl app start log is blow: root@ATK-DLRK356X:~# /opt/lvgl/lvgl-wayland2 [ 854435.514] -> wl_display@1.get_registry(new id wl_registry@2) [ 854435.711] wl_display@1.get_registry(new id wl_registry@2) [ 854435.773] -> wl_registry@2.global(1, "wl_compositor", 4) [ 854435.824] -> wl_registry@2.global(2, "wl_subcompositor", 1) [ 854435.848] -> wl_registry@2.global(3, "wp_viewporter", 1) [ 854435.870] -> wl_registry@2.global(4, "zxdg_output_manager_v1", 2) [ 854435.894] -> wl_registry@2.global(5, "wp_presentation", 1) [ 854435.917] -> wl_registry@2.global(6, "zwp_relative_pointer_manager_v1", 1) [ 854435.940] -> wl_registry@2.global(7, "zwp_pointer_constraints_v1", 1) [ 854435.962] -> wl_registry@2.global(8, "zwp_input_timestamps_manager_v1", 1) [ 854435.987] -> wl_registry@2.global(9, "wl_data_device_manager", 3) [ 854436.009] -> wl_registry@2.global(10, "wl_shm", 1) [ 854436.034] -> wl_registry@2.global(11, "mali_buffer_sharing", 4) [ 854436.058] -> wl_registry@2.global(12, "wl_seat", 7) [ 854436.081] -> wl_registry@2.global(13, "zwp_linux_dmabuf_v1", 3) [ 854436.103] -> wl_registry@2.global(14, "weston_direct_display_v1", 1) [ 854436.125] -> wl_registry@2.global(15, "wl_output", 3) [ 854436.148] -> wl_registry@2.global(16, "wl_output", 3) [ 854436.172] -> wl_registry@2.global(17, "xdg_wm_base", 3) [ 854436.195] -> wl_registry@2.global(18, "weston_screenshooter", 1) [ 854436.342] wl_registry@2.global(1, "wl_compositor", 4) [ 854436.403] -> wl_registry@2.bind(1, "wl_compositor", 1, new id [unknown]@3) [ 854436.447] wl_registry@2.global(2, "wl_subcompositor", 1) [ 854436.511] -> wl_registry@2.bind(2, "wl_subcompositor", 1, new id [unknown]@4) [ 854436.548] wl_registry@2.global(3, "wp_viewporter", 1) [ 854436.604] wl_registry@2.global(4, "zxdg_output_manager_v1", 2) [ 854436.647] wl_registry@2.global(5, "wp_presentation", 1) [ 854436.699] wl_registry@2.global(6, "zwp_relative_pointer_manager_v1", 1) [ 854436.741] wl_registry@2.global(7, "zwp_pointer_constraints_v1", 1) [ 854436.771] wl_registry@2.global(8, "zwp_input_timestamps_manager_v1", 1) [ 854436.799] wl_registry@2.global(9, "wl_data_device_manager", 3) [ 854436.856] wl_registry@2.global(10, "wl_shm", 1) [ 854436.919] -> wl_registry@2.bind(10, "wl_shm", 1, new id [unknown]@5) [ 854437.105] -> wl_shm@5.create_pool(new id wl_shm_pool@6, fd 5, 4096) [ 854437.881] -> wl_shm_pool@6.resize(8832) [ 854438.011] -> wl_shm_pool@6.resize(18624) [ 854438.077] wl_registry@2.global(11, "mali_buffer_sharing", 4) [ 854438.139] wl_registry@2.global(12, "wl_seat", 7) [ 854438.188] -> wl_registry@2.bind(12, "wl_seat", 1, new id [unknown]@7) [ 854438.263] wl_registry@2.global(13, "zwp_linux_dmabuf_v1", 3) [ 854438.317] wl_registry@2.global(14, "weston_direct_display_v1", 1) [ 854438.361] wl_registry@2.global(15, "wl_output", 3) [ 854438.412] wl_registry@2.global(16, "wl_output", 3) [ 854438.461] wl_registry@2.global(17, "xdg_wm_base", 3) [ 854438.501] -> wl_registry@2.bind(17, "xdg_wm_base", 3, new id [unknown]@8) [ 854438.575] wl_registry@2.global(18, "weston_screenshooter", 1) [ 854438.620] -> wl_display@1.sync(new id wl_callback@9) [ 854438.757] wl_registry@2.bind(1, "wl_compositor", 1, new id [unknown]@3) [ 854438.888] wl_registry@2.bind(2, "wl_subcompositor", 1, new id [unknown]@4) [ 854438.955] wl_registry@2.bind(10, "wl_shm", 1, new id [unknown]@5) [ 854438.997] -> wl_shm@5.format(0) [ 854439.026] -> wl_shm@5.format(1) [ 854439.048] -> wl_shm@5.format(909199186) [ 854439.084] -> wl_shm@5.format(842093913) [ 854439.105] -> wl_shm@5.format(842094158) [ 854439.118] -> wl_shm@5.format(909203022) [ 854439.130] -> wl_shm@5.format(1448695129) [ 854439.159] -> wl_shm@5.format(1448434008) [ 854439.194] -> wl_shm@5.format(808665665) [ 854439.221] -> wl_shm@5.format(808665688) [ 854439.244] wl_shm@5.create_pool(new id wl_shm_pool@6, fd 48, 4096) [ 854439.373] wl_shm_pool@6.resize(8832) [ 854439.436] wl_shm_pool@6.resize(18624) [ 854439.483] wl_registry@2.bind(12, "wl_seat", 1, new id [unknown]@7) [ 854439.573] -> wl_seat@7.capabilities(6) [ 854439.608] wl_registry@2.bind(17, "xdg_wm_base", 3, new id [unknown]@8) [ 854439.700] wl_display@1.sync(new id wl_callback@9) [ 854439.725] -> wl_callback@9.done(4) [ 854439.752] -> wl_display@1.delete_id(9) [ 854439.866] wl_display@1.delete_id(9) [ 854439.915] wl_shm@5.format(0) [ 854439.942] wl_shm@5.format(1) [ 854439.973] wl_shm@5.format(909199186) [ 854440.002] wl_shm@5.format(842093913) [ 854440.020] wl_shm@5.format(842094158) [ 854440.033] wl_shm@5.format(909203022) [ 854440.057] wl_shm@5.format(1448695129) [ 854440.073] wl_shm@5.format(1448434008) [ 854440.102] wl_shm@5.format(808665665) [ 854440.120] wl_shm@5.format(808665688) [ 854440.132] wl_seat@7.capabilities(6) [ 854440.157] -> wl_seat@7.get_keyboard(new id wl_keyboard@10) [ 854440.192] -> wl_seat@7.get_touch(new id wl_touch@11) [ 854440.217] wl_callback@9.done(4) [ 854440.350] -> wl_compositor@3.create_surface(new id wl_surface@9) [ 854440.398] -> xdg_wm_base@8.get_xdg_surface(new id xdg_surface@12, wl_surface@9) [ 854440.453] -> xdg_surface@12.get_toplevel(new id xdg_toplevel@13) [ 854440.490] -> xdg_toplevel@13.set_title("Window Title") [ 854440.519] -> xdg_toplevel@13.set_app_id("Window Title") [ 854440.547] -> wl_surface@9.commit() [ 854440.616] -> wl_shm@5.create_pool(new id wl_shm_pool@14, fd 6, 1536000) [ 854440.691] -> wl_shm_pool@14.create_buffer(new id wl_buffer@15, 0, 800, 480, 3200, 0) [ 854462.682] -> wl_surface@9.damage(0, 0, 800, 480) [ 854462.948] wl_seat@7.get_keyboard(new id wl_keyboard@10) [ 854463.240] -> wl_keyboard@10.keymap(1, fd 51, 48967) [ 854463.337] wl_seat@7.get_touch(new id wl_touch@11) [ 854463.385] wl_compositor@3.create_surface(new id wl_surface@9) [ 854463.436] xdg_wm_base@8.get_xdg_surface(new id xdg_surface@12, wl_surface@9) [ 854463.495] xdg_surface@12.get_toplevel(new id xdg_toplevel@13) [ 854463.543] xdg_toplevel@13.set_title("Window Title") [ 854463.583] xdg_toplevel@13.set_app_id("Window Title") [ 854463.617] wl_surface@9.commit() [ 854463.679] wl_shm@5.create_pool(new id wl_shm_pool@14, fd 49, 1536000) [ 854463.780] wl_shm_pool@14.create_buffer(new id wl_buffer@15, 0, 800, 480, 3200, 0) [ 854463.849] wl_surface@9.damage(0, 0, 800, 480) [ 854463.908] -> xdg_toplevel@13.configure(720, 1280, array[4]) [ 854463.948] -> xdg_surface@12.configure(5) [ 854468.038] wl_keyboard@10.keymap(1, fd 6, 48967) [ 854478.215] xdg_toplevel@13.configure(720, 1280, array[4]) [ 854478.301] xdg_surface@12.configure(5) [ 854478.320] -> xdg_surface@12.ack_configure(5) [ 854478.339] -> wl_surface@9.attach(wl_buffer@15, 0, 0) [ 854478.386] -> wl_surface@9.commit() [ 854478.531] xdg_surface@12.ack_configure(5) [ 854478.604] wl_surface@9.attach(wl_buffer@15, 0, 0) [ 854478.686] wl_surface@9.commit() [13:39:11.613] xdg_surface geometry (800 x 480) is larger than the configured fullscreen state (720 x 1280)[ 854481.880] -> wl_keyboard@7.leave(6, wl_surface@21) [ 854481.953] -> wl_keyboard@10.enter(7, wl_surface@9, array[0]) [ 854482.028] -> wl_keyboard@10.modifiers(7, 0, 0, 0, 0) [ 854482.129] -> xdg_toplevel@13.configure(720, 1280, array[8]) [ 854482.201] -> xdg_surface@12.configure(8) [ 854482.238] -> xdg_toplevel@24.configure(1920, 1080, array[4]) [ 854482.287] -> xdg_surface@23.configure(9) [ 854499.026] wl_keyboard@10.enter(7, wl_surface@9, array[0]) [ 854499.145] wl_keyboard@10.modifiers(7, 0, 0, 0, 0) [ 854499.257] xdg_toplevel@13.configure(720, 1280, array[8]) [ 854499.292] xdg_surface@12.configure(8) [ 854499.310] -> xdg_surface@12.ack_configure(8) [ 854503.715] wl_display@1.sync(new id wl_callback@31) [ 854503.778] -> wl_callback@31.done(9) [ 854503.810] -> wl_display@1.delete_id(31) [ 854503.836] xdg_surface@23.set_window_geometry(0, 0, 1920, 1080) [ 854503.915] xdg_toplevel@24.set_min_size(0, 0) [ 854503.958] xdg_toplevel@24.set_max_size(0, 0) [ 854504.033] xdg_surface@23.ack_configure(9) [ 854504.052] wl_surface@21.frame(new id wl_callback@30) [ 854506.571] -> wl_buffer@15.release() [ 854515.834] wl_display@1.sync(new id wl_callback@31) [ 854515.899] -> wl_callback@31.done(9) [ 854515.948] -> wl_display@1.delete_id(31) [ 854515.974] wl_surface@21.attach(wl_buffer@29, 0, 0) [ 854516.012] wl_surface@21.damage(0, 0, 2147483647, 2147483647) [ 854516.073] wl_surface@21.commit() [ 854516.128] -> wl_buffer@27.release() [ 854518.033] -> wl_callback@30.done(554926) [ 854518.080] -> wl_display@1.delete_id(30) [ 854519.945] wl_buffer@15.release() [ 854519.988] -> wl_buffer@15.destroy() [ 854520.170] -> wl_shm_pool@14.resize(3686400) [ 854520.235] -> wl_shm_pool@14.create_buffer(new id wl_buffer@16, 0, 720, 1280, 2880, 0) [ 854531.068] xdg_surface@12.ack_configure(8) [ 854531.194] wl_buffer@15.destroy() [ 854531.258] -> wl_display@1.delete_id(15) [ 854531.365] wl_shm_pool@14.resize(3686400) [ 854531.644] wl_shm_pool@14.create_buffer(new id wl_buffer@16, 0, 720, 1280, 2880, 0) [ 854538.898] -> wl_surface@9.damage(0, 0, 720, 533) [ 854541.451] -> wl_surface@9.damage(0, 533, 720, 533) [ 854542.765] -> wl_surface@9.damage(0, 1066, 720, 214) [ 854542.897] -> wl_surface@9.attach(wl_buffer@16, 0, 0) [ 854542.992] -> wl_surface@9.commit() [ 854543.162] wl_surface@9.damage(0, 0, 720, 533) [ 854543.522] wl_surface@9.damage(0, 533, 720, 533) [ 854543.784] wl_surface@9.damage(0, 1066, 720, 214) [ 854543.906] wl_surface@9.attach(wl_buffer@16, 0, 0) [ 854544.304] wl_surface@9.commit() [ 854555.626] -> wl_buffer@16.release() [ 854564.729] wl_display@1.delete_id(15) [ 854564.796] wl_buffer@16.release() [ 854570.256] -> wl_surface@9.damage(572, 185, 110, 46) [ 854570.332] -> wl_surface@9.attach(wl_buffer@16, 0, 0) [ 854570.414] -> wl_surface@9.commit() [ 854570.565] wl_surface@9.damage(572, 185, 110, 46) [ 854570.666] wl_surface@9.attach(wl_buffer@16, 0, 0) [ 854570.718] wl_surface@9.commit() [ 854572.269] -> wl_buffer@16.release() [ 854581.056] wl_buffer@16.release() [ 854591.880] -> wl_surface@9.damage(572, 185, 110, 46) [ 854591.984] -> wl_surface@9.attach(wl_buffer@16, 0, 0) [ 854592.079] -> wl_surface@9.commit() [ 854592.232] wl_surface@9.damage(572, 185, 110, 46) [ 854592.379] wl_surface@9.attach(wl_buffer@16, 0, 0) [ 854592.439] wl_surface@9.commit() [ 854594.091] -> wl_buffer@16.release() [ 854602.975] wl_buffer@16.release() [ 903844.951] wl_surface@21.frame(new id wl_callback@30) [ 903854.355] wl_display@1.sync(new id wl_callback@31) [ 903854.540] -> wl_callback@31.done(9) [ 903854.729] -> wl_display@1.delete_id(31) [ 903854.841] wl_surface@21.attach(wl_buffer@27, 0, 0) [ 903855.158] wl_surface@21.damage(0, 0, 2147483647, 2147483647) [ 903855.737] wl_surface@21.commit() [ 903856.043] -> wl_buffer@29.release() [ 903862.831] -> wl_callback@30.done(604276) [ 903862.941] -> wl_display@1.delete_id(30)

arilink commented 1 month ago

I think this problem is about window geometry

etag4048 commented 1 month ago

@arilink Yes it is indeed, this is a different problem that is also apparent when running older versions of the wayland driver on weston.. The flush occurs before the buffers are resized.

It looks like weston runs the application in fullscreen right at the beginning. Upon the configure event the compositor communicates the size it wants the client app to have:

[ 854478.215] [xdg_toplevel@13.configure] xdg_toplevel@13.configure(720, 1280, array[4])

In this case 720*1280

As a workaround, try passing these values to the lv_wayland_create_window function in your main.c file so that it matches the expectations of weston

This issue is fixed in the opened PR.

BR

arilink commented 1 month ago

@etag4048
I found a way to do it, which is as follows: 1.lvgl seems to prefer to display on the main display

  1. I designated DSI as the primary monitor and HDMI as the secondary monitor
  2. Run Qt program on the secondary monitor Qt can be specified by set_geometry on HDMI display
  3. Run lvgl's demo on the main display
  4. It seems to be working well and there is no tear. The photos are as follows: img_v3_02bc_6e3db5b0-e63b-43b9-a2f2-4c39677dadbg

In theory, lvgl should call xdg_surface_set_window_geometry to specify the display location, but when I try, I'm told that xdg_surface must have a role. I think this is related to the way I call, could you please help confirm the correct calling method, the specific log is as follows: [13:45:23.809] libwayland: error in client communication (pid 3277) xdg_surface@12: error 1: xdg_surface must have a role

etag4048 commented 1 month ago

@arilink A xdg surface can have a top-level role or popup role. Before sending any request related to a surface the role needs to be set, the get_xdg_surface request assigns the top-level role to a wl_surface, So you need to 'paste' the function after get_xdg_surface in create_window.

However, sending a xdg_surface_set_window_geometry request to weston, won't solve this issue. The book on wayland explains the purpose of this request better than the official spec https://wayland-book.com/xdg-shell-basics/xdg-surface.html

' ...is used primarily for applications using client-side decorations, to distinguish the parts of their surface which are considered a part of the window, and the parts which are not. Most commonly, this is used to exclude client-side drop-shadows rendered behind the window from being considered a part of it.'

There are no decorations and no windowing in the above screenshot, both apps are running in full screen.

The proper solution to this is to resize the underlining SHM buffers before the first flush occurs.

BR

arilink commented 4 weeks ago

@etag4048 As you said, set_window_geometry doesn't work. How do I resize the shm?

etag4048 commented 4 weeks ago

@arilink You can attempt to backport https://github.com/lvgl/lv_drivers/pull/313/commits/092610cdcaac9bbc52acbc743b65066b823d0b09 to release/v8.3