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(nvenc): Enable opt-in client refresh by client #3415

Merged

Conversation

TheElixZammuto
Copy link
Contributor

@TheElixZammuto TheElixZammuto commented Nov 24, 2024

Description

Context in TheElixZammuto/moonlight-xbox#117

This type of degradation can be fixed on nvidia cards by implementing intra-refresh.
I do not have an nvidia card so I wasn't be able to test, but this change has been validated by the commenters in the issue above using a custom Sunshine build made by me and by other forks of Sunshine made by other people, and it seems to fix the issue.

This change is completely opt-in by the client, so this change should only apply to the Xbox/UWP Client

Related to:

moonlight-xbox: TheElixZammuto/moonlight-xbox#155
moonlight-common-c: moonlight-stream/moonlight-common-c#97

Screenshot

Issues Fixed or Closed

TheElixZammuto/moonlight-xbox#117

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

@TheElixZammuto TheElixZammuto changed the title [nvenc] Enable opt-in client refresh by client fix(nvenc): Enable opt-in client refresh by client Nov 24, 2024
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Project coverage is 7.88%. Comparing base (129abd8) to head (574fdb8).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/nvenc/nvenc_base.cpp 0.00% 5 Missing and 4 partials ⚠️
src/rtsp.cpp 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3415      +/-   ##
=========================================
- Coverage   11.17%   7.88%   -3.29%     
=========================================
  Files         100      90      -10     
  Lines       17310   15803    -1507     
  Branches     8069    7487     -582     
=========================================
- Hits         1934    1246     -688     
+ Misses      12671   12131     -540     
+ Partials     2705    2426     -279     
Flag Coverage Δ
Linux 8.42% <0.00%> (-0.01%) ⬇️
Windows 5.38% <0.00%> (-0.01%) ⬇️
macOS-13 ?
macOS-14 ?

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

Files with missing lines Coverage Δ
src/video.h 48.83% <ø> (-6.11%) ⬇️
src/rtsp.cpp 1.59% <0.00%> (-1.18%) ⬇️
src/nvenc/nvenc_base.cpp 0.00% <0.00%> (-1.98%) ⬇️

... and 41 files with indirect coverage changes

@ReenigneArcher
Copy link
Member

Do we need to wait for the moonlight-common-c PR to be merged for this?

@cgutman
Copy link
Collaborator

cgutman commented Nov 26, 2024

Do we need to wait for the moonlight-common-c PR to be merged for this?

Not really. The SDP attribute looks fine and that's the only part of the network protocol that's affected by this change.

If we wanted to do this for real, I would suggest allowing the client to specify the parameters of the intra-refresh period, but since this is basically a hack, I'm fine just having a single flag to indicate it.

I'm pretty convinced we (or FFmpeg) probably have a bug here though because I've seen this "artifacting on mostly static images" pop up on other clients too. It's just really tricky to catch in a way that can actually be analyzed. We would need to write the whole video stream to disk, so we could run it through a bitstream analyzer it after the fact. Maybe it's feasible to do on Xbox where it occurs relatively soon, but in other cases it can take hours of streaming for it to happen.

src/nvenc/nvenc_base.cpp Outdated Show resolved Hide resolved
@TheElixZammuto TheElixZammuto force-pushed the nvenc-add-intra-refresh branch from 98e2462 to 115aa6b Compare December 23, 2024 13:06
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ReenigneArcher ReenigneArcher merged commit 60bfcfe into LizardByte:master Dec 23, 2024
33 of 37 checks passed
qiin2333 pushed a commit to qiin2333/Sunshine-Foundation that referenced this pull request Dec 24, 2024
@TheElixZammuto
Copy link
Contributor Author

I'm pretty convinced we (or FFmpeg) probably have a bug here though because I've seen this "artifacting on mostly static images" pop up on other clients too. It's just really tricky to catch in a way that can actually be analyzed. We would need to write the whole video stream to disk, so we could run it through a bitstream analyzer it after the fact. Maybe it's feasible to do on Xbox where it occurs relatively soon, but in other cases it can take hours of streaming for it to happen.

@cgutman @ns6089 Could it be enough to save the last 300 NAL units onto a flash drive when the user presses an hotkey so that they can upload it to us and can analyse this further?

@ns6089
Copy link
Contributor

ns6089 commented Dec 27, 2024

In my opinion, no.
TheElixZammuto/moonlight-xbox#117 (comment)

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.

4 participants