Recover from Vulkan fence/acquire timeout + device-lost #13
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?
[claude 2026-04-18] Diagnosed during today's debugging — observed twice within a few hours of normal daily-driver use.
Observed symptom
Window visible and frozen on last-presented frame: keystrokes ignored, resize events ignored, no dispatch. Process stays alive indefinitely (first freeze was 11h52m at kill time; second occurred shortly after).
Root cause
Main thread wedged in
vkWaitForFences(..., timeout=UINT64_MAX)inside the NVIDIA 595.58.03 driver. Backtrace (identical on both occurrences, byte-for-byte in waystty frames):The NVIDIA driver drops a fence signal for
in_flight_fence— the GPU work likely completes but the kernel syncobj / sync fd the driver polls never gets notified. Since our wait has no timeout, the main loop blocks permanently: no input dispatch, no resize, no exit.Not a waystty logic bug in isolation — a Vulkan-tutorial antipattern (
UINT64_MAX) meeting a real-world driver flake.Offending sites (all
std.math.maxInt(u64))src/renderer.zig:1275—drawClearfence waitsrc/renderer.zig:1282—drawClearacquireNextImageKHRsrc/renderer.zig:1478— atlas transfer fence waitsrc/renderer.zig:1710—drawCellsfence wait (wedged in both freezes observed today)src/renderer.zig:1721—drawCellsacquireNextImageKHRsrc/renderer.zig:1818— capture path fence waitsrc/renderer.zig:1824— capture fence waitProposed scope — full device-lost recovery
VK_TIMEOUT,VK_ERROR_OUT_OF_DATE_KHR,VK_ERROR_DEVICE_LOST.VK_ERROR_DEVICE_LOST: tear down and recreate GPU resources —in_flight_fence,atlas_transfer_fence,capture_fence)VkDeviceitself on true device-lostvt.Terminalgrid + font atlas CPU cache live in RAM and must not be touched by recovery. After recovery, mark the terminal fully dirty and re-render.Non-goals (v1)
DEVICE_LOSTcases that match observed symptom.Related
7b6053b0— opt-in file logging for freeze/debug diagnosis. Complementary: logging diagnoses future wedges, this ticket survives them.Next step
Needs a design (brainstorm → spec → plan). Recovery touches renderer ownership + GPU-resource lifetime; not a one-file change.
Migrated from git-collab issue
ab6c92f0a65d60f5c919990eb9f73a94c98fcdf8.Original author: a73x dev@a73x.sh.
[claude 2026-04-18] Implementation complete on branch feat/vulkan-bounded-waits (worktree at .worktrees/vulkan-bounded-waits).
Spec: docs/superpowers/specs/2026-04-18-vulkan-bounded-waits-design.md
Plan: docs/superpowers/plans/2026-04-18-vulkan-bounded-waits.md
Eight commits (six implementation + two review-fix follow-ups):
zig build test passes; grep gate clean (16 files, no violations).
Follow-up filed:
0e342b6e— audit five mid-flight waitIdleForShutdown sites for bounded semantics (resize, scale, OutOfDateKHR, uploadAtlas init).