Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

Rendering artifact on VA-API HEVC AMD Linux

Open Gitez-Spaghetti opened this issue 2 months ago • 32 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Is your issue described in the documentation?

  • [x] I have read the documentation

Is your issue present in the latest beta/pre-release?

This issue is present in the latest pre-release

Describe the Bug

On both the latest version and the pre-release version, using HEVC hardware encoding on my AMD GPU (with VA-API) causes the display to be slightly scaled down, showing a green line at the bottom and black bars on the side of the screen. This happened after updating sunshine to 2025.924.154138 from the official LizardByte repo.

Image

This issue does not occur when using software encoding, or when using H264 on VA-API.

Downgrading to an older version of sunshine (2025.628.4510-7 in the screenshot) instantly solves the issue:

Image

Running Sunshine on my laptop (also running Arch Linux) shows the exact same issue.

Expected Behavior

Correct encoding.

Additional Context

No response

Host Operating System

Linux

Operating System Version

Latest Arch Linux

Architecture

amd64/x86_64

Sunshine commit or version

2025.929.5023 commit: c16f0add0fe28ee1d77d2364bd9eb582e8991b2b

Package

Linux - pkg.tar.zst

GPU Type

AMD

GPU Model

XFX AMD Radeon RX 580 8GB

GPU Driver/Mesa Version

1:25.2.3-2

Capture Method

KMS (Linux)

Config

encoder = vaapi
hevc_mode = 0
upnp = enabled

Apps


Relevant log output

[2025-09-30 10:27:58.151]: Info: Found H.264 encoder: h264_vaapi [vaapi]
[2025-09-30 10:27:58.151]: Info: Found HEVC encoder: hevc_vaapi [vaapi]
[2025-09-30 10:27:58.427]: Info: Video encryption enabled
[2025-09-30 10:27:58.427]: Info: New streaming session started [active sessions: 1]
[2025-09-30 10:27:58.535]: Info: CLIENT CONNECTED
[2025-09-30 10:27:58.536]: Info: /dev/dri/card1 -> amdgpu
[2025-09-30 10:27:58.537]: Info: Screencasting with KMS
[2025-09-30 10:27:58.537]: Info: /dev/dri/card1 -> amdgpu
[2025-09-30 10:27:58.537]: Info: Found monitor for DRM screencasting
[2025-09-30 10:27:58.537]: Info: Found connector ID [97]
[2025-09-30 10:27:58.538]: Info: Found cursor plane [59]
[2025-09-30 10:27:58.545]: Info: Creating encoder [hevc_vaapi]
[2025-09-30 10:27:58.545]: Info: Color coding: SDR (Rec. 601)
[2025-09-30 10:27:58.545]: Info: Color depth: 8-bit
[2025-09-30 10:27:58.545]: Info: Color range: MPEG
[2025-09-30 10:27:58.563]: Info: vaapi vendor: Mesa Gallium driver 25.2.3-arch1.2 for AMD Radeon RX 580 Series (radeonsi, polaris10, ACO, DRM 3.64, 6.16.8-zen3-1-zen)
[2025-09-30 10:27:58.563]: Info: Streaming bitrate is 24588000
[2025-09-30 10:27:58.563]: Info: Using normal encoding mode
[2025-09-30 10:27:58.563]: Info: Using default rate control
[2025-09-30 10:27:58.577]: Info: Minimum FPS target set to ~30fps (33.3333ms)
[2025-09-30 10:27:58.834]: Info: Setting default sink to: [sink-sunshine-stereo]
[2025-09-30 10:27:58.835]: Info: Found default monitor by name: sink-sunshine-stereo.monitor
[2025-09-30 10:27:58.877]: Info: Opus initialized: 48 kHz, 2 channels, 512 kbps (total), LOWDELAY

Gitez-Spaghetti avatar Sep 30 '25 08:09 Gitez-Spaghetti

Likely due to a change in ffmpeg

ReenigneArcher avatar Sep 30 '25 12:09 ReenigneArcher

For me even the posted version causes the same issue on AMD.

javierfurus avatar Oct 01 '25 09:10 javierfurus

I can confirm that this started happening to me after upgrading to 2025.924.154138, built from source through the AUR package. Arch Linux with AMD GPU.

[2025-09-30 22:37:30.473]: Info: vaapi vendor: Mesa Gallium driver 25.2.3-arch1.2 for AMD Radeon RX 9070 XT (radeonsi, gfx1201, LLVM 20.1.8, DRM 3.64, 6.16.8-arch3-1)

jyggen avatar Oct 01 '25 09:10 jyggen

Likely due to a change in ffmpeg

Unlikely, ffmpeg version n7.1.1 does not show this issue, at least not in the nv12 format using the exact same GPU. ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i Video_2025-09-25_11-43-00.mp4 -vf 'format=nv12,hwupload' -c:v hevc_vaapi output.mkv

Gitez-Spaghetti avatar Oct 01 '25 11:10 Gitez-Spaghetti

We're using FFmpeg 8.x now and don't use the system provided FFmpeg.

ReenigneArcher avatar Oct 01 '25 13:10 ReenigneArcher

Experiencing the same green line here, also with AMD GPU, in the following situations:

  • Streaming at 1080p to moonlight-android
  • Streaming at 1080p to Moonlight Flatpak (screenshot)
Image

The artifact does not show up for me in the following situations:

  • ~~Streaming at 1080p to moonlight-qt v6.1.0-1~~ EDIT: I've observed it is now showing the artifact when using HEVC on an AMD iGPU
  • Streaming at 720p to moonlight-android
  • Streaming at 720p to Moonlight Flatpak (screenshot)
Image

askpng avatar Oct 02 '25 14:10 askpng

hi, I'm also experiencing this artifact when streaming to my steamdeck(running cachyos/arch) or my raspberry pi.

the PC i'm streaming from is also running Arch(EndevourOS) with a Ryzen 9 3900X and a Radeon RX 9070.

D0IP avatar Oct 05 '25 03:10 D0IP

Confirming I've got the same issue for 1080p only on multiple clients. Host is amd 6700xt on Nobara OS.

polo817 avatar Oct 05 '25 09:10 polo817

Experiencing the same with AMD 780m on Fedora 42 for specifically 1080p

ThisIsQasim avatar Oct 10 '25 05:10 ThisIsQasim

Same here with 7900XT, Arch and 1080p, fine on 4K

hanneshoch3 avatar Oct 11 '25 10:10 hanneshoch3

Also having this issue on Bazzite at 1080p. Rolling back package did work for the time being. 6900XT for video card

stompysan avatar Oct 11 '25 18:10 stompysan

Same here with 9070 XT with CachyOS. Streaming in 1080p to Moonlight running on AppleTV. Sunshine 2025.628.4510-7 works. Sunshine 2025.924.154138-1 shows the green line at the bottom.

shelterx avatar Oct 13 '25 09:10 shelterx

Can reproduce with RX580, Ultramarine Linux with Terra Mesa.

korewaChino avatar Oct 19 '25 07:10 korewaChino

I can also confirm: Used moonlight on pixel 7 and dell insprion 7300 intel i5 gen 12, both using HVEC encoding no matter hardware or software encoded (1080p 60).

Host computer is running garuda linux (arch based) with 9070xt and 5700x3D on sunshine versions 2025.924.154138-1 and 2025.1025.34515-1 and seeing this green bar on the bottom. Never seen this before.

iescobar1 avatar Oct 26 '25 16:10 iescobar1

I can confirm the green line with my RX6650 on Ubuntu 24.04.3 (kernel 6.14, mesa 25.0.7, no kisak PPA) when encoding 1080p in h265.

I couldn't find an unaffected version. I tried the most recent stable and pre-releases.

These kinds of alignment issues (where ffmpeg made assumptions about block sizes that differed from what AMD is actually using) seem to have plagued the platform for years: https://fftrac-bg.ffmpeg.org/ticket/8506

They are supposed to have been fixed in Sunshine (including changes in libva and ffmpeg): https://github.com/LizardByte/Sunshine/issues/2636 https://github.com/LizardByte/build-deps/pull/363

Since some libva change in x.21 is also involved and Ubuntu 24.04 ships with x.20 I also tried install Intel's graphics PPA for 24.04 in order to have x.22 but this didn't help. I tried a build from before ffmpeg8 and a recent one. No combination fixed it on my system.

See also the interesting comment here: https://github.com/LizardByte/build-deps/pull/482#issuecomment-3223439576 It clearly singles out the move to ffmpeg8 as source of the regression (but I can't confirm that for Ubuntu 24.04 where all versions seem to be affected). That comment has a link to a pre-ffmpeg8-build of sunshine that is still available for download.

If I remember correctly h265 on my system has been affected for a long time but it was not immediately obvious because the additional 8 px were black in older versions but at some point they got their obnoxious green colour.

gschintgen avatar Oct 31 '25 08:10 gschintgen

AMD requires 64x16 blocks for hardware encoding if I'm not mistaken. Does changing the horizontal resolution add a vertical green bar too or not? To discern whether the cropping through HEVC metadata is only partially or fully broken.

ns6089 avatar Nov 06 '25 00:11 ns6089

I can confirm this green bar happened at bottom on 1920x1080 resolution with FFmpeg VAAPI HEVC. If the weight and height both not multiples of 64x16, like 1936x1080 it looks like this:

Image from OBS output Image

I'm on Fedora 42, ffmpeg 7.1.2, mesa-vulkan-drivers-freeworld 25.1.9-1.fc42, AMD RX 5700

SourLemonJuice avatar Nov 07 '25 01:11 SourLemonJuice

ffmpeg in sunshine now needs to be build with libva-1.21+, but I don't know if it is relevant. https://github.com/FFmpeg/FFmpeg/commit/bcfbf2bac8f9eeeedc407b40596f5c7aaa0d5b47

ns6089 avatar Nov 07 '25 02:11 ns6089

ffmpeg in sunshine now needs to be build with libva-1.21+, but I don't know if it is relevant. FFmpeg/FFmpeg@bcfbf2b

Our pre-compiled version is using 2.14.0: https://packages.ubuntu.com/search?keywords=libva-dev&searchon=names&suite=jammy&section=all

ReenigneArcher avatar Nov 07 '25 03:11 ReenigneArcher

@ReenigneArcher They have weird versioning. VAAPI-1.21+ translates to libva-2.21+, and that's likely what broke it. Maybe defining the symbol manually and removing version check like in https://github.com/LizardByte/build-deps/pull/363 will be enough to fix it.

ns6089 avatar Nov 07 '25 03:11 ns6089

@ns6089 That makes sense, thanks for clarifying that! I was planning to solve this by just compiling libva prior to ffmpeg in the build-deps repo, but I'm hitting an issue I don't know how to solve for the FreeBSD build on aarch64.

https://github.com/LizardByte/build-deps/pull/535

ReenigneArcher avatar Nov 12 '25 05:11 ReenigneArcher

I just noticed that in the logcat for Moonlight, it says the incoming stream is 1920 x 1088

XT-Martinez avatar Nov 20 '25 11:11 XT-Martinez

I can recreate this issue with latest sunshine from Pac-Man on cachyOS (arch) on both steamdeck and android with AYN Thor at 1080p. Issue goes away if I stream 720p but I don’t wanna do that

MadaoDev avatar Nov 20 '25 19:11 MadaoDev

I just noticed that in the logcat for Moonlight, it says the incoming stream is 1920 x 1088

I have been experiencing this green line issue at the bottom of my Sunshine stream for a while, saw your comment and adjusted my streaming resolution from 1920 x 1080 to 1920 x 1088 and the green stripe is gone! May not work for everyone but a handy workaround for me for the moment, thanks for the info @XT-Martinez

jaredhenderson avatar Nov 24 '25 09:11 jaredhenderson

How did you set your streaming resolution? Isn't it controlled by Moonlight? (You can't edit it arbitrarily in Moonlight)

daniele-athome avatar Nov 24 '25 09:11 daniele-athome

Image

jaredhenderson avatar Nov 24 '25 09:11 jaredhenderson

How did I not see that? Thank you.

daniele-athome avatar Nov 24 '25 09:11 daniele-athome

I didn't know that either. Thanks, @jaredhenderson, that' a nice workaround.

iguana31 avatar Nov 24 '25 14:11 iguana31

I confirm this issue on 6700 xt on opensuse tumbleweed (latest at the time of writing)

Michal-Szczepaniak avatar Dec 02 '25 21:12 Michal-Szczepaniak

It works for me if I force the codec to anything else that isn't HEVC.

I mention this because the android version of Moonlight does not allow to set custom resolutions.

johanbcn avatar Dec 06 '25 10:12 johanbcn