LizardByte / LizardByte/Sunshine

Periodic 3-frame RGBA_to_NV12 cudaErrorInvalidPitchValue bursts (every 16.0s) on NVIDIA Wayland portal capture

Open
#5,640 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
41.3k
Forks
2.1k
Avg merge
23h 47m
Merged PRs (30d)
124

Description

### 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

Environment - Host: Ubuntu 25.10, kernel 6.17.0-41-generic, GNOME Wayland (mutter) on NVIDIA - GPU: RTX 3070 Ti Laptop, driver 610.57.04
(also reproduced on 595.71.05 — driver-independent) - Display: 3440x1440 ultrawide (Xorg 6144x3456 supersample rig config is a separate X
server; the streamed desktop is the GNOME Wayland session) - Sunshine: v2026.906.222525 (x86_64 AppImage), capture via xdg-desktop-portal
PipeWire path ([portalgrab]), encoder h264_nvenc, SDR 8-bit, 45.5 Mbps - Client: Moonlight (Android) — bursts reproduce with a video playing
in continuous screen motion and with a static desktop
Symptom ~1 s black blip on the client every ~16 s, plus brief latency spikes. Between bursts the stream is clean.
Host log evidence (timestamps from one continuous session, no disconnect between bursts; [pipewire] stream state stays streaming
throughout — no renegotiation at burst times):
11:07:03.862 Error: RGBA_to_NV12 failed: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:04.825 Error: Couldn't copy to cuda array: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:04.825 Error: Could not convert image
11:07:04.848 Info: Creating encoder [h264_nvenc]
11:07:04.881 Error: RGBA_to_NV12 failed: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:05.825 Error: Couldn't copy to cuda array: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:05.826 Error: Could not convert image
11:07:05.845 Info: Creating encoder [h264_nvenc]
11:07:05.872 Error: RGBA_to_NV12 failed: cudaErrorInvalidPitchValue:invalid pitch argument
-- 14 s of clean video --
11:07:19.848 Error: Couldn't copy to cuda array: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:19.867 Info: Creating encoder [h264_nvenc]
11:07:19.895 Error: RGBA_to_NV12 failed: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:20.858 Error: Couldn't copy to cuda array: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:20.877 Info: Creating encoder [h264_nvenc]
11:07:20.906 Error: RGBA_to_NV12 failed: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:21.859 Error: Couldn't copy to cuda array: cudaErrorInvalidPitchValue:invalid pitch argument
11:07:21.878 Info: Creating encoder [h264_nvenc]
11:07:21.906 Error: RGBA_to_NV12 failed: cudaErrorInvalidPitchValue:invalid pitch argument
-- 14 s of clean video --
11:07:35.901 ... same 3-frame pattern ...
-- 14 s of clean video --
11:07:51.975 ... same 3-frame pattern ...

Burst start times: 11:07:03.86, 11:07:19.85, 11:07:35.90, 11:07:51.9x — period 16.05 s, clockwork, across sessions and independent of on-screen
content.
Pattern per burst: exactly 3 frames fail ~1 s apart. Each failure: Couldn't copy to cuda array: cudaErrorInvalidPitchValue → Could
not convert image → encoder re-creation (Creating encoder [h264_nvenc]) → the re-created encoder’s first conversion also fails
(RGBA_to_NV12 failed). Frame 4+ succeeds until the next burst.
History / what was ruled out - Same error class on Sunshine 2026.516.143833 was constant (thousands of failures, hundreds of encoder re
creations per minute) on this same capture. - Upgraded NVIDIA driver 595.71.05 → 610.57.04 (required for nvenc API 13.1 on newer builds): burst
frequency dropped from constant to every 16 s, i.e. the bug is not driver-API-version related and persists on current driver + current Sunshine. -
Not network: host-side, clockwork period, no pipewire/portal renegotiation at burst times. - Not client-resolution: capture is always 3440x1440
(monitor native); bursts occur at any client res.
Question: what re-negotiates or cycles with a ~16 s period in the NVIDIA Wayland capture path? My hypothesis: mutter-on-NVIDIA delivers most
buffers with a padded/modifier-carrying layout but periodically hands over frames on differently-laid-out buffers (pool rotation), and the CUDA
conversion was initialized for the first buffer’s pitch, so the copy fails with invalid pitch until the encoder is re-created and re-syncs.
Happy to provide the full log, sunshine.conf, and run debug builds or capture-side experiments

### Expected Behavior

_No response_

### Additional Context

_No response_

### Host Operating System

Linux

### Operating System Version

Ubuntu 25.10, kernel 6.17.0-41-generic

### Architecture

amd64/x86_64

### Package

FreeBSD

### GPU Type

AMD

### GPU Model

NVIDIA RTX 3070 Ti

### GPU Driver/Mesa Version

driver 610.57.04, also reproduced on 595.71.05

### Capture Method

X11 (FreeBSD/Linux)

### Apps

```json

```

### Log output

```shell

```

### Online logs

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the RGBA_to_NV12 conversion and encoder-recreation path used by the xdg-desktop-portal PipeWire capture ([portalgrab]) and h264_nvenc. Reproduce the reported three-frame, roughly 16-second burst on NVIDIA Wayland and trace buffer layout or pitch changes around each failure. Done means identifying the cycling input or state and preventing the invalid-pitch conversion failures, with the periodic reproduction no longer occurring.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
audio-video-rtc, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.