Skip to content

Editor: the thumbnail device outlives the running thumbnail command (crashes on Vulkan) - #3465

Merged
xen2 merged 2 commits into
stride3d:masterfrom
xen2:fix/editor-thumbnail-shutdown-race
Sep 22, 2026
Merged

xen2 merged 2 commits into
stride3d:masterfrom
xen2:fix/editor-thumbnail-shutdown-race

Conversation

@xen2

@xen2 xen2 commented Sep 22, 2026

Copy link
Copy Markdown
Member

PR Details

Closing a session disposed the thumbnail GraphicsDevice while a build thread was still inside a thumbnail command.

On Vulkan this is a use-after-free (access violation in vkCreateImage on a destroyed VkDevice, seen on CI in the editor tests on Vulkan). Direct3D11 hides it because the native device is COM ref-counted.

Fix

  • ThumbnailGenerator counts the running commands. Dispose() never blocks: if a command still runs, the resources are destroyed when the last one ends.
  • IThumbnailService.StopAsync() refuses new commands and returns a task that completes when no command runs.
  • GameStudioWindow.SaveAndClose() awaits it (10 s max) before Session.Destroy(), without blocking the UI thread.
  • Editor test harness: awaits the async close of Game Studio before Shutdown(), so the tests exercise the real close path.

Verification

  • Editor tests on Direct3D11: 5/5 (same duration as before).
  • Vulkan canary that closes Game Studio 1 to 8 s after opening TopDownRPG: 6/6, no hang.
  • Local run with forced timing (each command sleeps 2 s, Game Studio stays alive 5 s after Destroy()): without the fix, 18 commands fail and 6 never end after Destroy(); with the fix, all commands succeed.

Note: IThumbnailService gets a new member.

Closing a session disposed the thumbnail graphics device while a build thread
was still inside a thumbnail command. On Vulkan that was an access violation
in vkCreateImage on a destroyed device.

The close path now awaits the running command without blocking the UI thread.
Dispose never blocks: if a command still runs, the resources are destroyed
when it ends.
@xen2 xen2 added the ci-editor Run the GameStudio editor screenshot suite on this PR label Sep 22, 2026
@xen2
xen2 merged commit ca26cb1 into stride3d:master Sep 22, 2026
32 checks passed
@xen2
xen2 deleted the fix/editor-thumbnail-shutdown-race branch September 22, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-editor Run the GameStudio editor screenshot suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant