Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

fix(nvenc): Enable opt-in client refresh by client

Open TheElixZammuto opened this issue 1 year ago • 4 comments

Description

Context in https://github.com/TheElixZammuto/moonlight-xbox/issues/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: https://github.com/TheElixZammuto/moonlight-xbox/pull/155 moonlight-common-c: https://github.com/moonlight-stream/moonlight-common-c/pull/97

Screenshot

Issues Fixed or Closed

https://github.com/TheElixZammuto/moonlight-xbox/issues/117

Type of Change

  • [x] 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

  • [x] My code follows the style guidelines of this project
  • [x] 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 avatar Nov 24 '24 22:11 TheElixZammuto

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 99 commits behind head on master.

Files with missing lines Patch % Lines
src/nvenc/nvenc_base.cpp 0.00% 5 Missing and 4 partials :warning:
src/rtsp.cpp 0.00% 1 Missing and 1 partial :warning:
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%) :arrow_down:
Windows 5.42% <0.00%> (-0.01%) :arrow_down:
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%) :arrow_down:
src/rtsp.cpp 1.59% <0.00%> (-1.18%) :arrow_down:
src/nvenc/nvenc_base.cpp 0.00% <0.00%> (-1.98%) :arrow_down:

... and 41 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 26 '24 20:11 codecov[bot]

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

ReenigneArcher avatar Nov 26 '24 22:11 ReenigneArcher

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.

cgutman avatar Nov 26 '24 23:11 cgutman

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

sonarqubecloud[bot] avatar Dec 23 '24 13:12 sonarqubecloud[bot]

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?

TheElixZammuto avatar Dec 27 '24 15:12 TheElixZammuto

In my opinion, no. https://github.com/TheElixZammuto/moonlight-xbox/issues/117#issuecomment-2503358667

ns6089 avatar Dec 27 '24 15:12 ns6089