Wayland: a Vulkan error at a resize ends the consumer's process: the swapchain is rebuilt inside the configure listener #200
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#200
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
Window::xdg_surface_handle_configureapplies a configure's new size at once:ResizecallsRebuildSwapchain, and every Vulkan call in there goes throughDevice::CheckVkResult, which throws for any result butVK_SUCCESS. That throw starts inside a Wayland listener. A consumer can put atryaroundWindow::Updateand around a window's making, but not around this, so a device that is lost when a configure arrives ends the process. Line numbers refer toc006519.Details
implementations/Crafter.Graphics-Window.cpp:1921-1927: for a configured window whose toplevel configure carried a size,xdg_surface_handle_configurecallswindow->Resize(newWidth, newHeight).:753-771:Resizeholds a new size back only while a frame is being recorded (deferredWidth,deferredHeight). Otherwise it setswidthandheightand callsRebuildSwapchain.:774-793:RebuildSwapchainbegins withDevice::CheckVkResult(vkQueueWaitIdle(Device::queue))and goes on toRecreateSwapchainAndImages, whoseCreateSwapchain(:1620) checksvkCreateSwapchainKHR,vkGetSwapchainImagesKHR,vkCreateSemaphoreandvkCreateImageViewthe same way.implementations/Crafter.Graphics-Device.cpp:83:CheckVkResultthrowsstd::runtime_error.The listener is called from
wl_display_dispatch*, so libwayland's own frames lie between the throw and the consumer's code: C, with nothing in it for an exception passing through. Atryaround the consumer's dispatch call would have to count on unwinding through them. After the throw,widthandheighthold the new size and the swapchain still has the old one.Win32's
WM_SIZE(:181-191) reaches the sameResizefrom the window procedure. Not tried there.Concrete case
imsd-messages 0.0.0 (ca5cd72, the library at
c006519) on its bench: a nested KWin 6.8.0 and a Vulkan layer that answersVK_ERROR_DEVICE_LOSTfrom a set moment on. The device is lost while the window is idle, and the compositor then resizes the window before any frame is drawn. From the run's record:Where a frame meets the loss first, the same build's
tryaroundWindow::Updatecatches it and the process ends in order with exit 1. On a phone the on-screen keyboard resizes the window each time it comes or goes, so there a configure is as likely to meet a lost device as a frame is.Suggested fix
Keep only the size in the listener and rebuild at the start of the next
Render, where thetrya consumer has aroundWindow::Updatecovers it.Renderdoes both halves of that already: it rebuilds afterVK_ERROR_OUT_OF_DATE_KHR(:1319-1326), and after the present it applies aResizethat came while the frame was being recorded (:1523-1534).Two things change for consumers and want a line in
AGENTS.consumer.md.onResizethen fires from thatRender, not from the dispatch. And a consumer that draws on demand has to learn at the configure that a frame is owed, because today itsonResizelistener is what asks for one: an event at the configure would do.#199 asks for the same move for another reason.
Found by imsd-messages' pre-push review (rounds 69 and 70, 2026-11-17) and shown on its bench. Waived for the app's 0.0.0 with this issue as the follow-up.