Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(video): encode at least one frame before capture reinit #3300

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

cgutman
Copy link
Collaborator

@cgutman cgutman commented Oct 13, 2024

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) then ReleaseFrame() will fail with DXGI_ERROR_ACCESS_LOST immediately afterwards (which is turned into capture_e::reinit). DDA is left in a strange state after this happens, where further calls to both AcquireNextFrame() and ReleaseFrame() fail with DXGI_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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 11.12%. Comparing base (7352e72) to head (d044897).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/video.cpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3300      +/-   ##
==========================================
- Coverage   11.13%   11.12%   -0.01%     
==========================================
  Files          99       99              
  Lines       17211    17211              
  Branches     8023     8023              
==========================================
- Hits         1916     1915       -1     
- Misses      12594    12737     +143     
+ Partials     2701     2559     -142     
Flag Coverage Δ
Linux 8.42% <0.00%> (ø)
Windows 5.19% <0.00%> (ø)
macOS-13 13.60% <0.00%> (+0.01%) ⬆️
macOS-14 12.59% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/video.cpp 30.32% <0.00%> (ø)

... and 22 files with indirect coverage changes

@cgutman cgutman changed the title fix(video): encode pending frames before capture reinit fix(video): encode at least one frame before capture reinit Oct 14, 2024
@ReenigneArcher ReenigneArcher added this to the stable release milestone Oct 14, 2024
@cathyjf
Copy link
Contributor

cathyjf commented Oct 15, 2024

I can confirm that this works well for me.

Copy link

sonarcloud bot commented Oct 15, 2024

@cgutman cgutman merged commit bd2e1dc into LizardByte:master Oct 15, 2024
35 of 36 checks passed
qiin2333 pushed a commit to qiin2333/Sunshine-Foundation that referenced this pull request Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants