Window constructor crashes on compositors without fractional-scale, xdg-decoration or viewporter (null globals) #162
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#162
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The
Windowconstructor uses three optional Wayland globals without checking that the compositor advertised them. On a compositor that lacks any one of them the constructor passes a null proxy to libwayland and crashes. Line numbers refer to6aa0338.Details
Device::handle_globalbinds these when they are advertised (implementations/Crafter.Graphics-Device.cpp:277-282), andDevice::Initializeonly verifieswl_shm,wl_compositorandxdg_wm_base(:527):wp_fractional_scale_manager_v1implementations/Crafter.Graphics-Window.cpp:295zxdg_decoration_manager_v1:302wp_viewporter:305The rest of the code half-anticipates this:
Resizealready guardsif (wpViewport)(:544).Found by reading the code. Not reproduced: the compositors at hand (phoc on the Fairphone 6, and the desktop session) advertise all three. The likely first victim is a compositor without xdg-decoration; to my knowledge GNOME's Mutter does not implement it.
Suggested fix
Guard each use and degrade:
wl_output/wl_surface.preferred_buffer_scale, or 1.0;Fixed in
670df31. The constructor makes the fractional scale, the decoration and the viewport only when the compositor advertised their globals, and the fractional scale only alongside a viewport, since the preferred scale is applied through it: without one,scalestays 1 and the compositor scales the window up on a HiDPI output. Without xdg-decoration the window has no title bar.tests/WindowOptionalGlobalshides each global, and all three, and renders, resizes and closes a window each time; it crashed on the window without xdg-decoration before the fix. Checked as well through a socket proxy that drops the three globals from KWin's registry, so the library never sees them.Not done: the integer-scale fallback (
wl_surface.preferred_buffer_scale,wl_output.scale). It needswl_compositorv6 (the library binds v3) and awl_surfacelistener, or output tracking for compositors too old for v6, and would run into #165 (a scale that changes after construction is only applied by the next resize).