Skip to content

Wayland resize keeps up with the pointer - #2141

Draft
raphamorim wants to merge 3 commits into
mainfrom
wayland-resize-lag
Draft

raphamorim wants to merge 3 commits into
mainfrom
wayland-resize-lag

Conversation

@raphamorim

@raphamorim raphamorim commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1921.

A Wayland resize drag sends a configure every few milliseconds. For each one Rio called screen.resize, which rebuilt the Vulkan swapchain behind a device_wait_idle, laid out every tab and pane, and sent each PTY a TIOCSWINSZ. Nothing paced frames to the compositor, so Rio fell behind and kept catching up after the pointer stopped.

Changes

  • Lazy swapchain rebuild (sugarloaf, Vulkan): resize only records the size; the swapchain is rebuilt at the next acquire, at most once per frame, and not at all when the size didn't change.
  • No idle on rebuild, within the spec: when the driver has VK_EXT_swapchain_maintenance1 (with VK_EXT_surface_maintenance1), every present carries a VkSwapchainPresentFenceInfoEXT fence. A retired swapchain and its views are destroyed once its frames' command buffers are done and every present to it has signalled its fence (VUID-vkDestroySwapchainKHR-swapchain-01282). Fences are recycled. Without the extension it idles the device before destroying, as main does today.
  • Frame-callback pacing (rio-window + sugarloaf): new WindowExtWayland::frame_notifier(); sugarloaf calls a pre-present hook right before the Vulkan or wgpu present, so a callback is only requested when a commit follows.
  • One resize per frame on Wayland (rioterm): Resized stores the size and it is applied at the next RedrawRequested, so layout and TIOCSWINSZ happen at most once per frame, with no delay. A hidden window gets no frame callbacks, so a one-frame (vblank_interval) timer applies a size no frame picked up.
  • Scale dedupe (rio-window, Wayland): a scale event with the same scale is ignored.

How other projects do it

  • alacritty records the size and resizes the surface right before drawing; zed applies at most one resize per frame; all pace with wl_surface.frame requested right before commit.
  • foot, kitty and zed dedupe unchanged scale events.
  • wgpu idles the device on every surface configure; kitty does vkQueueWaitIdle. The present-fence path follows the Khronos swapchain_recreation sample.

Known caveats

  • Already there before this PR: render_finished semaphores are per frame slot, not per swapchain image (VUID-vkQueueSubmit-pSignalSemaphores-00067).
  • On Wayland, input between a configure and the next frame is hit-tested against the layout on screen (the previous size).

Testing

  • cargo test -p rioterm (311 pass), rio-window tests, clippy.
  • rio-window checked and clippy-clean for x86_64-unknown-linux-gnu. The Linux sugarloaf build can't run on macOS here (freetype/fontconfig), so the new Vulkan code was type-checked against ash 0.38 in a standalone crate; CI is the first full compile. Not yet tried on a real Wayland session; testing from the reporters (ideally with RIO_VULKAN_VALIDATION=1) would help.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window resizing is laggy on wayland

1 participant