Ensure renderer-api-driven frame wait is only invoked when a frame is actually drawn #5846
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed very long pauses when loading song select on my windows PC. Tracking this down, the game was getting stuck on the D3D11Swapchain wait handle until the full one second timeout.
It turns out that the wait handle will not be set unless a frame finishes rendering. The fail case is where the update thread takes over 100ms to prepare a frame, causing
TripleBuffer.GetForRead
to timeout and returnnull
, which early exits the draw frame method.This would happen anywhere the game takes slightly too long to render an update frame. I could reproduce:
To confirm / reproduce this issue, remove the 1000ms timeout from
WaitOne
in veldrid and add a singleThread.Sleep(150)
in any update thread code, and watch the game deadlock indefinitely.For good measure, here's a visual example of this happening: