WLR capture: black frames on NVIDIA with wlroots Vulkan renderer
Nadie ha tomado este issue todavía.
- #5988 de @arkheya — cerrado sin fusionar
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 28/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- cpp, linux
- Área
- backend, performance
Línea de trabajo
Start in src/platform/linux/wayland.cpp at the WLR capture ready callback and trace how dmabuf_t::ready() obtains and uses the next frame. Check the current Wayland capture flow and synchronization behavior against wlroots’ Vulkan renderer and NVIDIA imports; the report’s proof of concept is untested outside one setup. Done means reproducing the black frames and validating a reliable synchronization fix without introducing unacceptable latency across relevant configurations.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Is there an existing issue for this?
- I have searched the existing issues
Is your issue described in the documentation?
- I have read the documentation
Is your issue present in the latest beta/pre-release?
I didn't read the issue template
Describe the Bug
Disclaimer: I have fixed this issue for myself using LLM that wrote a patch. The issue is gone, and it completely satisfies me, I'm going to apply this patch going forward after every Sunshine update. However, sharing the issue here in case anyone had the same issue or someone might want to take a look at it. This patch is probably unoptimal, it makes CPU thread wait, introduces latency/delays, untested on other hardware or other software configuration, and might not even be applicable to future versions of wlr / renderers. Or maybe even unrelated to Sunshine and should be fixed on wlr/vulkan/nvidia side.
The problem is: I'm having severe flickering when streaming something with Vulkan renderer from Sway.
Environment
- Arch Linux, kernel 7.2.11
- RTX 5070 Ti, nvidia-open 615.78.08
- sway 1.12 / wlroots 0.20.2,
WLR_RENDERER=vulkan - Sunshine v2026.914.233613 (AUR, built with CUDA 13.4.3, but without CUDA same issue),
capture = wlr, hevc_nvenc - Capturing headless outputs (1340x800@60), Artemis on Android
Problem
Streams flash black frames. It looks like severe flickering, especially during heavy gameplay: XPlane12, Minecraft. I'm trying to stream instrument panels of XPlane from HEADLESS outputs but I think it's irrelevant which ones to stream. Rate scales with GPU load: occasional at idle, tens per second while a game is running, especially with an XWayland game focused and the cursor over it (though might be unrelated to cursor).
WLR_RENDERER=gles2: no flicker (the gles2 renderer stalls on the GPU instead, which is unusable under load). This only happens withWLR_RENDERER=vulkan.- Non-CUDA build (GPU -> RAM -> GPU) flickers too.
Cause (likely) (written by LLM)
dmabuf_t::ready() uses the buffer as soon as ready arrives. The wlroots Vulkan renderer sends ready after submitting the copy and relies on the implicit fence on the dma-buf. NVIDIA's import doesn't wait on implicit fences, so Sunshine reads a freshly allocated, not-yet-written GBM buffer, which shows up as black.
Proof of concept (written by LLM)
Wait for the dma-buf write fence (poll(POLLIN)) in ready(). On timeout, repeat the previous frame. This fixes it for me. It's a CPU-side wait; a proper fix would probably export the fence (DMA_BUF_IOCTL_EXPORT_SYNC_FILE) and have the GPU wait on it via EGL. The patch is against v2026.914.233613; wayland.cpp has been refactored on master since.
Patch
--- a/src/platform/linux/wayland.cpp
+++ b/src/platform/linux/wayland.cpp
@@ -536,15 +536,35 @@
std::uint32_t tv_sec_lo,
std::uint32_t tv_nsec
) {
- // Frame is ready for use, GBM buffer now contains screen content
- current_frame->destroy();
- current_frame = get_next_frame();
+ // The compositor may send `ready` before its GPU copy has finished, relying
+ // on the implicit fence attached to the dma-buf. NVIDIA's EGL/CUDA import
+ // ignores implicit fences, so wait for the write fence (POLLIN on a dma-buf
+ // fd blocks until pending writes are done). If the copy still isn't done,
+ // drop the new frame and keep the previous one instead of sending a
+ // half-copied (usually black) frame.
+ auto next_frame = get_next_frame();
+ bool copy_done = true;
+ if (next_frame->sd.fds[0] >= 0) {
+ struct pollfd pfd = {};
+ pfd.fd = next_frame->sd.fds[0];
+ pfd.events = POLLIN;
+ copy_done = poll(&pfd, 1, 100) == 1;
+ }
- std::uint64_t sec = (std::uint64_t(tv_sec_hi) << 32) | tv_sec_lo;
- auto ready_ts = std::chrono::seconds(sec) + std::chrono::nanoseconds(tv_nsec);
- current_frame->frame_timestamp = std::chrono::steady_clock::time_point {
- std::chrono::duration_cast<std::chrono::steady_clock::duration>(ready_ts)
- };
+ if (!copy_done && current_frame->sd.fds[0] >= 0) {
+ BOOST_LOG(debug) << "[wayland] Screencopy not finished in time, repeating previous frame"sv;
+ next_frame->destroy();
+ } else {
+ // Frame is ready for use, GBM buffer now contains screen content
+ current_frame->destroy();
+ current_frame = next_frame;
+
+ std::uint64_t sec = (std::uint64_t(tv_sec_hi) << 32) | tv_sec_lo;
+ auto ready_ts = std::chrono::seconds(sec) + std::chrono::nanoseconds(tv_nsec);
+ current_frame->frame_timestamp = std::chrono::steady_clock::time_point {
+ std::chrono::duration_cast<std::chrono::steady_clock::duration>(ready_ts)
+ };
+ }
// Keep the GBM buffer alive but destroy the Wayland objects
if (current_wl_buffer) {
Expected Behavior
No response
Additional Context
No response
Host Operating System
Linux
Operating System Version
Arch Linux
Architecture
amd64/x86_64
Package
Linux - AUR (Third Party)
GPU Type
NVIDIA
GPU Model
5070Ti
GPU Driver/Mesa Version
615.78.08
Capture Method
No response
Apps
Log output
Online logs
No response
- Lenguaje dominante
- C++
- Estrellas
- 43k
- Forks
- 2.4k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de LizardByte/Sunshine
-
Linux keyboard backend has no mapping for VK_ABNT_C1 (ABNT2 dedicated `/ ?` key) — key is silently droppedPosiblemente ocupada @NestorBrasileiro la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
LizardByte/Sunshine#6051 · 2 comentarios ·
-
PIN pairing fails with "Missing CSRF token" - web UI never fetches/attaches the tokenQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
LizardByte/Sunshine#5467 · 2 comentarios ·
-
Virtual HID Driver License notifications appearing even though Enable Gamepad Input is uncheckedAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
LizardByte/Sunshine#6222 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 47/100
LizardByte/Sunshine#6208 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
LizardByte/Sunshine#6202 · 1 comentario ·
Todos los issues de LizardByte/Sunshine
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 2 días
-
bug data-types
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ClickHouse/clickhouse-cpp#645 ·
Los mantenedores suelen responder en 1 día
-
bug compatibility difficulty:easy prio:normal
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
NatronGitHub/openfx-misc#524 ·
Los mantenedores suelen responder en 1 día
-
[内容提案] 现在C++模块的CMake支持有更新,需要进行同步Abiertodocumentation enhancement help wanted P0
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Awesome-Embedded-Learning-Studio/Tutorial_AwesomeModernCPP#359 ·
Los mantenedores suelen responder en 1 día
-
Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
openscad/openscad#7360 · 2 comentarios ·
Los mantenedores suelen responder en 1 día