Igalia / cog

WPE launcher and webapp container
MIT License
241 stars 61 forks source link

Wayland platform issue when using WAYLAND_SOCKET #728

Open colin-pm opened 2 months ago

colin-pm commented 2 months ago

I noticed in the cog 0.11.1 that using cog with a Wayland socket specified via the environment variable WAYLAND_SOCKET, cog no longer displays the loaded page. Using WAYLAND_SOCKET was confirmed to be working in 0.10.1. I've also verified that this problem exists up to cog 0.18.2.

I did some investigation into this and tracked down the regression to #320, specifically commit a7a65f1873345009c43b6d54cc1d71f46fca9076. My understanding is check_supported, added to platform/fdo/cog-platform-fdo.c, will call init_wayland, which will bind to the socket passed via environment variable. I believe the problem is when clear_wayland, or wl_registry_destroy/wl_display_disconnect, is called, the socket is closed when the display is destroyed/disconnected.

I've patched this issue downstream for now by adding a simple check at the beginning of check_supported to return true if WAYLAND_SOCKET is in the environment. This is probably not the most elegant fix, so I was hoping to report this issue upstream to see if anyone has any better ideas how to solve this problem.

aperezdc commented 2 months ago

@colin-pm Good find! I have to check if there's some way of avoiding that wl_display_destroy() would close the socket, but I am afraid it may not possible. Maybe calling dup() on the socket when WAYLAND_SOCKET is defined, and using the duplicated descriptor for the connection test would be a reasonable workaround.