fix(video): encode at least one frame before capture reinit #3300
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.
Description
Hyper-V GPU Paravirtualization (with https://github.com/jamesstringerparsec/Easy-GPU-PV) causes some strange behavior in DXGI DDA where
AcquireNextFrame()
will succeed (giving us a black frame) thenReleaseFrame()
will fail withDXGI_ERROR_ACCESS_LOST
immediately afterwards (which is turned intocapture_e::reinit
). DDA is left in a strange state after this happens, where further calls to bothAcquireNextFrame()
andReleaseFrame()
fail withDXGI_ERROR_INVALID_CALL
(indicating both that there is and is not a pending frame to release).Capture does seem to eventually recover and stabilize (when DWM renders a fresh frame?), but this pattern of pushing a frame then immediately failing with
capture_e::reinit
causes the encode thread to break into the reinit loop without actually encoding the pending frame. As a result, Moonlight is left waiting for the first encoded frame for an extended period of time, which causes it to eventually give up and tell the user that something is wrong with the host or network.I'm still working to see if there is a way to avoid the extended delays when switching to the UAC Secure Desktop, but this at least allows the stream to start consistently.
Reported at: moonlight-stream/moonlight-common-c#93
Screenshot
Issues Fixed or Closed
Type of Change
.github/...
)Checklist