Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland Backend Not Working on Raspberry Pi #62

Open
jefftranter opened this issue Nov 1, 2024 · 7 comments
Open

Wayland Backend Not Working on Raspberry Pi #62

jefftranter opened this issue Nov 1, 2024 · 7 comments

Comments

@jefftranter
Copy link

I am trying to get LVGL to work on a Raspberry Pi 3 using Wayland.
It is running the most recent version of Raspberry Pi OS which uses Wayland by default.
I am using the latest code from https://github.com/lvgl/lv_port_linux
In lv_conf.h I have set:

#define LV_USE_LINUX_FBDEV 0
#define LV_USE_LINUX_DRM 0
#define LV_USE_SDL 0
#define LV_USE_WAYLAND 1

The demo builds without without errors, but when run it get no display and I see these errors:

[Warn] (0.000, +0) lv_init: Memory integrity checks are enabled via LV_USE_ASSERT_MEM_INTEGRITY which makes LVGL much slower lv_init.c:262
[Warn] (0.000, +0) lv_init: Object sanity checks are enabled via LV_USE_ASSERT_OBJ which makes LVGL much slower lv_init.c:266
[Warn] (0.000, +0) lv_init: Style sanity checks are enabled that uses more RAM lv_init.c:270
wl_registry#2: error 0: invalid version for global xdg_wm_base (18): have 2, wanted 4
[Error] (0.000, +0) wayland_init: Asserted at expression: (application.shm_format != SHM_FORMAT_UNKNOWN) (WL_SHM_FORMAT not available) lv_wayland.c:2399
pi@raspberrypi

I tried changing LV_COLOR_DEPTH from 32 to 16 and to 24 but I get the same results.

On the same machine I am able to run the demo using SDL2.

I've attached the output of wayland-info.

wayland-info.txt

@csujq
Copy link

csujq commented Jan 16, 2025

Have you solved your issue?

@jefftranter
Copy link
Author

No, I am still seeing the issue with the latest LVGL code under the last Raspberry Pi OS.

@csujq
Copy link

csujq commented Jan 16, 2025

No, I am still seeing the issue with the latest LVGL code under the last Raspberry Pi OS.

you can try this commandexport WAYLAND_DISPLAY=wayland-1 or export WAYLAND_DISPLAY=wayland-0

@jefftranter
Copy link
Author

That didn't help. The OS was already setting WAYLAND_DISPLAY=wayland-0.
When set to wayland-1 it cannot connect to the Wayland server.

@csujq
Copy link

csujq commented Jan 16, 2025

That didn't help. The OS was already setting WAYLAND_DISPLAY=wayland-0. When set to wayland-1 it cannot connect to the Wayland server.

I had this problem before, but I solved it by typing this command.

@etag4048
Copy link
Contributor

@jefftranter Hello, this is because the wayland driver uses version 4 of the xdg-shell protocol. More specifically it sets up a listener for theconfigure_bounds event which requires version 4 - but it's not even used... Apparently, the wayland compositor on the RaspberryPI OS still uses version 2 of the xdg-shell. So you will have to patch out some lines and this seems to work on my machine

diff --git a/src/drivers/wayland/lv_wayland.c b/src/drivers/wayland/lv_wayland.c
index 8b85ae5a0..08bdf8799 100644
--- a/src/drivers/wayland/lv_wayland.c
+++ b/src/drivers/wayland/lv_wayland.c
@@ -1227,24 +1227,9 @@ static void xdg_toplevel_handle_close(void * data, struct xdg_toplevel * xdg_top
     LV_UNUSED(xdg_toplevel);
 }
 
-static void xdg_toplevel_handle_configure_bounds(void * data, struct xdg_toplevel * xdg_toplevel,
-                                                 int32_t width, int32_t height)
-{
-
-    LV_UNUSED(width);
-    LV_UNUSED(height);
-    LV_UNUSED(data);
-    LV_UNUSED(xdg_toplevel);
-
-    /* Optional: Could set window width/height upper bounds, however, currently
-     *           we'll honor the set width/height.
-     */
-}
-
 static const struct xdg_toplevel_listener xdg_toplevel_listener = {
     .configure = xdg_toplevel_handle_configure,
     .close = xdg_toplevel_handle_close,
-    .configure_bounds = xdg_toplevel_handle_configure_bounds
 };
 
 static void xdg_wm_base_ping(void * data, struct xdg_wm_base * xdg_wm_base, uint32_t serial)
@@ -1292,8 +1277,8 @@ static void handle_global(void * data, struct wl_registry * registry,
 #endif
 #if LV_WAYLAND_XDG_SHELL
     else if(strcmp(interface, xdg_wm_base_interface.name) == 0) {
-        /* Explicitly support version 4 of the xdg protocol */
-        app->xdg_wm = wl_registry_bind(app->registry, name, &xdg_wm_base_interface, 4);
+        /* The compositor on Raspberry Pi OS still uses version 2 */
+        app->xdg_wm = wl_registry_bind(app->registry, name, &xdg_wm_base_interface, 2);
         xdg_wm_base_add_listener(app->xdg_wm, &xdg_wm_base_listener, app);
     }
 #endif

Can you confirm ?

@jefftranter
Copy link
Author

I can confirm that it works with this patch!
It would be good to document this somewhere or handle it with #ifdefs in the code or similar.
Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants