#6011

fix(linux): allow PipeWire memory buffers for DMA-BUF import failures

OpenTomblaromwants to merge intofrom

Description

KWin/portal capture can negotiate DMA-BUF successfully, then repeatedly fail to import captured frames into the VA-API EGL context. The encoder restarts while the client receives black video.

Add the Linux pipewire_use_dmabuf setting (default enabled). Setting it to disabled before restarting Sunshine skips modifier enumeration, negotiates PipeWire memory buffers and selects the existing VA-API RAM conversion path. DMA-BUF remains preferred by default. The Web UI exposes the setting under Advanced on Linux.

The import failure occurs in egl::import_source() after capture negotiation. The current conversion API reports a generic failure to the video pipeline; it does not provide a safe capture/encoder renegotiation transaction. This patch therefore provides an explicit workaround rather than introducing shared cross-layer fallback state. Vulkan is rejected early when memory buffers are explicitly selected because it has no RAM conversion path. Memory copies may increase CPU/bandwidth use and latency; this does not promise 4K60 or fix the underlying driver import incompatibility.

Screenshot

Actual parent/current Linux Advanced UI, built from source with synthetic API data:

BeforeAfter

Issues Fixed or Closed

Related: #5316 and #6009. Both report the same RGB DMA-BUF import error and a successful VA-API RAM workaround. #5316 also contains separate FFmpeg teardown/display-switch failures; this setting does not claim to resolve every crash in that discussion. #6009 is the RX 6700 XT black-screen reproduction. No automatic issue closure is requested.

Roadmap Issues

Testing

  • Added regression tests for default/enabled/disabled configuration, bypassing modifier enumeration without touching Wayland/EGL, retaining the default query, and rejecting Vulkan before capture while allowing VA-API/software/CUDA with memory buffers.
  • uv sync --locked, uv run --locked lb-update-clang-format, JSON parsing and git diff --check: passed.
  • Full GCC 14 Linux build with BUILD_WERROR=ON, VA-API, KWin/portal and Vulkan enabled, CUDA disabled: passed. Complete native suite under Xvfb: 869 tests, 864 passed, 5 skipped (Windows-only, native tray and GPU-dependent checks unavailable in the build VM).
  • npm test -- --maxWorkers=2: 212 tests passed (12 files). Built UI checked in Chromium with synthetic API data: default enabled, saves disabled, omits the enabled default on save. Parent/current screenshots are shown above.
  • Stable-backport AppImage on the affected AMD hardware: installer, running binary/version, host-libva loading and rollback to the previous executable were verified. The final distributed bytes were tested directly with a Linux Moonlight client: visible Steam Big Picture over H.264 and HEVC at 3840×2160, basic mouse/keyboard navigation and repeated clean disconnect/reconnect. No repeated RGB import/conversion errors or service restart appeared in the inspected intervals. Measured incoming/decoded/rendered rates were 31.17 FPS for HEVC and 35.16 FPS for H.264; this is not a 60 FPS claim. Audio and physical input/display latency remain separate client-local investigations with no established connection to this patch. Live DMA-BUF import on other hardware and switching displays during streaming remain unverified; the hardware tests cover the stable backport, not the PR-head binary.
  • No synthetic test claims to reproduce the GPU driver's EGL failure. Mutation check: removing the bypass makes DisabledDmabufSkipsModifierQuery fail; restoring it passes. All seven PipeWire tests also passed 20 repetitions (140 test executions). These are object/FD/selection tests, not real streaming sessions.
  • Strict documentation build using Doxygen 1.12.0 through the pinned Dockle source: passed, 1,091 HTML pages generated.
  • gcovr reports 8/8 newly added executable C++ lines covered (line coverage, not a claim of GPU integration coverage).
  • The separate stable custom AppImage fork build passed full build, packaging, appimagelint, native tests (604 total: 599 passed, 5 environment/hardware skips) and signed provenance generation. All seven PipeWire tests passed there. Custom package, QA matrix and provenance; packaging/backports are outside this source PR.
  • Final verification on 2026-10-29 at PR head 9e33c086: GCC 14 build with BUILD_WERROR=ON passed; native tests under Xvfb passed again (864 passed, 5 environment/hardware skips); Web UI tests passed again (212 tests). The installed stable-backport AppImage checksum/version and single active service process were reverified. No new live client streaming test was performed during this final pass.
  • SonarCloud and the Sunshine Read the Docs build passed. Upstream CI, lint, CodeQL and GitHub Pages require maintainer approval. The secondary GitHub Pages Read the Docs check timed out waiting for the unavailable call-jekyll-build / Build Jekyll check; its log did not report a source documentation failure. These upstream results remain a verification limit.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

This pull request was generated by ChatGPT Codex, GPT-6.1-Sol, high thinking level, with Muse 1.3 Contributor, max thinking level.

Activity

4
Tomblarom1d ago

Final validation at 9e33c086: GCC 14 build with BUILD_WERROR=ON passed; the native suite under Xvfb passed with 864 tests passed and 5 environment/hardware skips; all 212 Web UI tests passed. The installed stable-backport AppImage checksum and running version were reverified. No additional live streaming session was performed in this final pass.

This pull request was generated by ChatGPT Codex, GPT-6.1-Sol, high thinking level, with Muse 1.3 Contributor, max thinking level.