Wayland: a resize sends the viewport's destination before a buffer of the new size exists, so the old frame is shown scaled to the new size until the next one #199
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#199
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
At a resize
RebuildSwapchainsendswp_viewport.set_destinationfor the new size from inside the configure listener, and the first buffer of that size reaches the compositor only with the consumer's next frame. The destination is double-buffered surface state: the nextwl_surface.commitapplies it, and that is the listener's own commit or a consumer's request for a frame callback, made while the surface still holds the old buffer. From that commit until the next frame's, the old picture is shown stretched or squashed to the new size. Line numbers refer toc006519.Details
implementations/Crafter.Graphics-Window.cpp:784-788:RebuildSwapchaincallswp_viewport_set_destinationwith the new size, beforeRecreateSwapchainAndImages.:792:onResizefires at the end ofRebuildSwapchain. A consumer that draws on demand asks for a frame there (wl_surface.frame,wl_surface.commit), and that is the first commit after the new destination.:1929:xdg_surface_handle_configurecommits the surface itself onceResizehas returned.Window::Update.viewporter says of the destination: "it causes the surface size to become dst_width, dst_height. The source (rectangle) is scaled to exactly this size."
Concrete case
A Fairphone 6 with Plasma Mobile 6.8.2 (KWin 6.8.2, plasma-keyboard 6.8.2), scale 2.85, running imsd-messages 0.0.0's tree (ca5cd72, the library at
c006519) underWAYLAND_DEBUG=1. The on-screen keyboard resizes the maximized window between 392 x 796 and 392 x 534 each time it comes or goes. One of those resizes, with the time since the configure (the lines between are left out):Over the 22 keyboard resizes of that trace, 11 each way, in ms from the configure:
set_destinationBetween the last two the old picture is at the new size: 15 to 36 ms, median 27 ms. That is by the trace and the protocol's rule. The screen was not filmed.
The table also shows what the rebuild costs. The first commit is the app's, made from its
onResizelistener, soRebuildSwapchainhas taken a median 85 ms by then, and for that time the consumer's loop is inside the listener and handles nothing else. The second of the two listings of the globals comes a median 25 ms in. How the rest divides betweenvkCreateSwapchainKHR, the old swapchain's destruction and theonResizelisteners that run before the app's was not measured.Suggested fix
Renderand not in the listener, as #200 asks for a lost device. The loop is then not held in the dispatch, and configures that arrive before a frame cost one rebuild between them.Found tracing the on-screen keyboard's coming and going in imsd-messages on the phone, 2026-11-18. The app's side is Catcrafts/imsd-messages#1. #201 is about the destination's value in the same lines.