[vlc-devel] [PATCH] wayland: xdg-shell: use roundtrip instead of dispatch

Alexandre Janniaux ajanni at videolabs.io
Mon Apr 6 18:50:52 CEST 2020


When using wl_display_dispatch, there is a race condition with the main
loop, in which the condition `(!sys->wm.configured)` would have been
checked as true, but the event dispatched from the main thread after
that so wl_display_dispatch would block indefinitely.

Said differently, wl_display_dispatch should not be called from a
different thread than the main thread (in wayland terms).

By using wl_display_roundtrip, we let the main thread unblock the
vout_window_Enable and prevent this deadlock.

Fixes #24586
---
 modules/video_output/wayland/xdg-shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c
index 765ffb2a2f..ab89931a4c 100644
--- a/modules/video_output/wayland/xdg-shell.c
+++ b/modules/video_output/wayland/xdg-shell.c
@@ -263,7 +263,7 @@ static int Enable(vout_window_t *wnd, const vout_window_cfg_t *restrict cfg)
 
 #ifdef XDG_SHELL
     while (!sys->wm.configured)
-        wl_display_dispatch(display);
+        wl_display_roundtrip(display);
 #endif
 
     return VLC_SUCCESS;
-- 
2.26.0



More information about the vlc-devel mailing list