Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Vulkan: editor freezes in vkWaitForFences on Windows + NVIDIA after a sub-window closes

Open
#1,550 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp

Research direction

Start with the Vulkan swap chain teardown in drivers/vulkan/rendering_device_driver_vulkan.{h,cpp} and the linked workaround in dominicbytes/redot-engine#10, which changes only those files. Reproduce with the attached MRP on Windows with an NVIDIA GPU, then trace how screen_free() handles an in-flight present. Done means repeated window open and close cycles no longer stall in vkWaitForFences; the workaround reports zero stalls in the runs described.

Written by the indexing model from the issue text.

Description

bug topic:editor topic:rendering
Tested versions
  • Reproducible in: v26.3.stable.official [85e520394] (the MRP below stalled on 1 of 3 runs).
  • Reproducible in local builds of the same commit, used for the counts below (see Issue description).
  • Not reproducible with D3D12, OpenGL (Compatibility), or Vulkan on an AMD GPU on the same machine.
  • Upstream Godot master has the same swap chain teardown code; not tested there.
System information

Windows 10 Pro 22H2 (build 19045), x86-64. Forward+ / Vulkan. NVIDIA driver 616.56; RTX 4080 SUPER (primary monitor) + RTX 5060 Ti (two side monitors), AMD integrated GPU (no monitor).

Issue description

The editor sometimes freezes for good right after a sub-window (popup, tooltip, dialog or plugin window) closes. It stops drawing and never recovers. The main thread is blocked forever in vkWaitForFences:

vkWaitForFences (NVIDIA driver)
RenderingDeviceDriverVulkan::fence_wait
RenderingDevice::_stall_for_frame
RenderingDevice::_begin_frame                <- swap_buffers
   or _flush_and_stall_for_all_frames         <- screen_prepare_for_drawing (resize_required)

What happens. A local instrumented build logged every acquire, submit, present, fence wait and swap chain event. Every captured stall had the same shape:

  1. A sub-window and the main window are presented in the same frame.
  2. The sub-window closes. RenderingDevice::screen_free() waits for the frame fences, then destroys the swap chain, followed by the surface and the window. This happens a few milliseconds after that swap chain's last vkQueuePresentKHR. The fences only cover rendering, so that present is still in flight.
  3. From then on the presentation engine never gives back the main window's images. vkAcquireNextImageKHR returns VK_SUCCESS, but the image's semaphore (and a test acquire fence) is never signaled, still pending 35 s later. The next submission waits on that semaphore, so its fence never signals.

When it stalls, an empty fence-only submission on every other queue completes; only the main queue is blocked. The GPU is not hung.

Whose bug. Redot's call sequence is valid. The Khronos validation layer (1.4.363) reports nothing, in stalled runs too. A deliberate-error canary confirmed its messages reach the log. Only NVIDIA's Vulkan driver shows it, so this is a driver bug. It is much more likely when the window's monitor is driven by a different GPU than the one rendering, but it also happens on a single GPU's own monitor.

Workaround available. dominicbytes/redot-engine#10 (single commit, against 26.3-stable) changes only drivers/vulkan/rendering_device_driver_vulkan.{h,cpp}:

  • On NVIDIA on Windows, it enables VK_KHR_present_id and VK_KHR_present_wait when supported.
  • It numbers every present.
  • swap_chain_free() waits for the swap chain's last present with vkWaitForPresentKHR before freeing it, for at most 200 ms.

Only window close changes; resizing, other vendors and other platforms keep the current behavior. Each close waited a median of 10 ms and at most 67 ms, measured over 179 closes.

Stalled runs, each opening and closing a window 40 times. A run counts as stalled when output stops for 45 s. These used local builds of 26.3-stable plus the WorldScape shutdown fix and test-only off-desktop window placement, with and without the workaround:

Setup Without the workaround With it
5060 Ti renders, windows on the 4080's monitor (worst case) 14/30 0/30
4080 renders, windows on a 5060 Ti monitor (default GPU) 11/50 0/30
4080 renders, windows on its own monitor 1/20 0/10
5060 Ti renders, windows on its own monitor 3/35 0/10
Validation layer on 2/15, 0 messages 0/6, 0 messages
D3D12 / OpenGL / Vulkan on the AMD GPU 0/15 each 0/10 each

Tried before the swap chain teardown, and still stalled: vkQueueWaitIdle on the present queue, presenting each swap chain separately, and keeping the present semaphores alive. A fixed 100 ms delay stopped the stalls, which confirms the cause is the present still being in flight.

Steps to reproduce
  1. Download and extract the attached MRP. Its editor plugin waits until the editor has loaded, then creates, shows, hides and frees a plain 512x512 Window 40 times, and quits.
  2. Run the editor with the console executable: redot --editor --audio-driver Dummy --path <mrp>. Add --gpu-index <n> to pick the rendering GPU.
  3. A normal run prints WINCYCLE_COUNT 0 to 39, then WINCYCLE_DONE, and exits. In a stalled run the counts stop (in our runs always within the first 5 cycles), the editor stops redrawing, and the process never exits.
  4. It is intermittent, so repeat the run a few times. It is most likely when the editor and the cycle window are on a monitor driven by a different NVIDIA GPU than the rendering one.

On the official build, the editor may crash at exit after WINCYCLE_DONE. That is the separate WorldScape shutdown crash (#1402), not this issue.

Minimal reproduction project (MRP)

vulkan-window-close-stall-mrp.zip

Dominant language
C++
Stars
6.1k
Forks
337
Avg merge
1d 51m
Merged PRs (30d)
41

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Redot-Engine/redot-engine

All issues in Redot-Engine/redot-engine

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.