Repository navigation
Open the window on COSMIC's Wayland with SDL2 - #1839
Merged
Merged
Conversation
…#992) On COSMIC the game never opened its window: the bundled SDL2 2.32 asks for the compositor's decorations before the window's first configure, COSMIC answers that the client draws them, and SDL's switch to libdecor inside that wait leaves it waiting on a field the switch cleared. SDL2 now takes libdecor from the start (SDL_VIDEO_WAYLAND_PREFER_LIBDECOR), which still uses the compositor's decorations where they are offered. SDL3 is left alone, and the variable still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hang # Conflicts: # tests/run_all.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a COSMIC desktop (Pop!_OS) the game never opens its window on Wayland: it hangs at start-up with nothing drawn, and the only way in today is
SDL_VIDEODRIVER=x11, which gives up the Wayland mailbox present that the game prefers. This makes it start on Wayland with no setting.Reported in #992 and listed under Wayland in #1000.
Why it hangs
The hang is in the bundled SDL2 (2.32.10), before Hookshot touches the GPU: a small program that only opens an SDL2 window with these libraries hangs the same way, and
HOS_HEADLESS=1starts fine. The log stops afterCountAddOnContent, with novk:line, and the main thread waits inpoll()on the Wayland socket forever.xdg-decoration) before the window's firstconfigure, then waits for that configure inWayland_ShowWindowonshell_surface.xdg.initial_configure_seen.CLIENT_SIDEbefore the configure. SDL's handler (handle_configure_zxdg_decoration) then hides the window, clearsshell_surfaceand shows it again with libdecor, all inside that wait.shell_surfaceis a union: the outer loop still reads thexdgmember'sinitial_configure_seen, which the switch cleared and which libdecor never sets. The outer loop dispatches forever.SDL2 2.30 asked for decorations only after that wait, so the same switch did not hang. The SDL2 branch still has this code. SDL3 waits on one
shell_surface_statusinstead and is not affected.GNOME and weston do not offer
xdg-decoration, and sway, KDE and Hyprland answer server-side, so none of them reaches the switch. That is why the reports so far are COSMIC only: a GNOME + NVIDIA laptop in #1000 opens directly. Hybrid GPUs are not the cause.What changed
host/posix/display_sdl.c: with SDL2,hos_display_initsetsSDL_VIDEO_WAYLAND_PREFER_LIBDECOR=1beforeSDL_Init, so SDL uses libdecor from the start and never makes the switch. libdecor still takes the compositor's decorations where they are offered. Without libdecor, SDL keeps its own path. SDL3 is left alone, and the environment variable still wins (SDL2 does not let a hint at normal priority override it), soSDL_VIDEO_WAYLAND_PREFER_LIBDECOR=0restores the old behaviour.tests/test_wayland_libdecor_hint.py(RUN_ALL_ARGSnames the compiler fortests/run_all.py): compiles the actualhos_display_initwith SDL stubs and checks that the hint is set beforeSDL_Initfor SDL2, and not for SDL3 or a headless start. It fails onmainand passes here.How it was tested
Pop!_OS 24.04, COSMIC (cosmic-comp 0.1, Wayland), Intel Raptor Lake iGPU + RTX 3050 6 GB Laptop, NVIDIA 595.104.02, libdecor 0.2.2 with its GTK plugin.
In the game: I rebuilt v2.0.13 with only this change (the v2.0.13 AppImage's tools plus this patch,
--update), with no variables set.rx: renderer: VulkanSDL_VIDEO_WAYLAND_PREFER_LIBDECOR=0On other compositors: I opened a window with the same flags as the game (
SHOWN \| RESIZABLE \| ALLOW_HIGHDPI \| VULKAN) through the bundledlibSDL2-2.0.so.0, with each compositor nested in COSMIC, and read the decoration handshake withWAYLAND_DEBUG=client.xdg-decoration)configure(2), no client frame)xdg-decoration)Only COSMIC changes. On the others the window and who draws its frame are the same before and after.
python -I -B tests/run_all.py: the window checks pass (test_wayland_libdecor_hint,test_display_startup_failure,test_windows_display_startup). Ten checks fail on this machine onmaintoo, because it has noclang++. They do not touch this code.Screenshot
The title screen on COSMIC's Wayland after the change (before it, the window never drew anything):
🤖 Generated with Claude Code