Skip to content

fix(linux): select PipeWire converters from negotiated buffers - #6118

Merged
ReenigneArcher merged 4 commits into
masterfrom
fix/pipewire-negotiated-memory
Nov 27, 2026
Merged

ReenigneArcher merged 4 commits into
masterfrom
fix/pipewire-negotiated-memory

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Description

When portal/KWin capture negotiates memory buffers, locally available DMA-BUF formats can still make VA-API select its VRAM converter. That sends an image without valid DMA-BUF descriptors to EGL import.

Record the buffer type selected by format negotiation and use it when creating the converter. Startup waits for both dimensions and a buffer type. If the format is still pending at the deadline, VA-API and CUDA can start provisionally with memory. Vulkan can still probe when local DMA-BUF formats are available, so Portal can retry a failed first negotiation without maxFramerate. Vulkan still rejects confirmed memory. Under the existing frame locks, an actual frame that requires a different converter requests capture reinitialization before it can reach that converter.

Modifier advertising is unchanged, and no permanent acceleration-failure flag is added. This addresses the shared-memory/converter mismatch, not genuine EGL import failures for valid DMA-BUFs. #6011 provides a separate manual DMA-BUF workaround; #5568 concerns pixel formats. The reporter validated the negotiated memory path on an RX 590 with KWin 6.8.3: three VA-API sessions on 9ecb05e showed video without EGL_BAD_PARAMETER. That retest did not exercise live DMA-BUF or renegotiation.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

  • Follow-up at 74b5014: GCC 14 built test_sunshine with VA-API, Vulkan, KWin, and Portal enabled. All 17 PipeWire* tests passed. The new tests exercise the format callback logic, the actual converter selection with recording factories (including CUDA's selection logic), late DMA-BUF and memory frames, and the Portal pre-stream retry. No live GPU or CUDA runtime test was run. Repository formatting and git diff --check passed.

Earlier validation at 9ecb05e:

  • Added synthetic SPA-format/frame regressions for pending negotiation, memory versus DMA-BUF, both storage-change directions, descriptor copying, empty/unsupported buffers, and resetting storage state on a new connection.
  • uv sync --locked, uv run --locked lb-update-clang-format, and git diff --check: passed.
  • GCC 14 native targets sunshine and test_sunshine built with BUILD_WERROR=ON, VA-API, Vulkan, KWin and portal enabled; CUDA and tray disabled. Command: cmake --build cmake-build-6114 --target test_sunshine sunshine -j 3.
  • test_sunshine --gtest_filter='PipeWire*': 11/11 passed. Temporarily disabling the storage-change guard makes PipeWireBufferTest.StorageChangesAreRejectedBeforeCopyingFrame fail; restored the fix before final validation.
  • Complete final native run: 962 tests, 938 passed, 20 skipped, 4 failed, plus 4 suite setup/teardown failures. The four test failures are PortalRequestTest.* and EmptyStartResponses/PortalRequestStaleTokenTest.*: their D-Bus daemon cannot open a socket (Operation not permitted). The failed suite setups are X11GrabTest, Configurations/AudioTest, MouseInputs/MouseHIDTest, and EncoderVariants/EncoderTest; platform initialization fails without DISPLAY/WAYLAND_DISPLAY. All 11 PipeWire tests passed again in this run. Xvfb also could not create listening sockets in this container.
  • gcovr: the format-classification and frame-copy helper executable lines were exercised (4/4 and 17/17 respectively); added executable-line coverage is 19/48, not 100%. Live callback/startup and encoder-factory paths remain a coverage gap.
  • Local build setup initially hit extracted headers shadowing the compiler/CPM/vendored dependencies (math/Boost/GoogleTest). The unmodified upstream PipeWire test reproduced the math-header failure. Corrected local include paths and rebuilt successfully, without repository workarounds. The version smoke check passed with an isolated config and repository apps file after the first uninstalled-build attempt could not find installed assets.
  • No real KDE/AMD streaming test was possible: this container has no /dev/dri device or graphical session. Genuine DMA-BUF EGL imports, real renegotiation during streaming, and CUDA are untested. The tests use synthetic buffers and an ordinary duplicated fd, not GPU DMA-BUF imports. Packaging, Web UI, and documentation builds were not run.

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. The exact model variant and configured thinking level were not exposed in this delegated session.

Copy link
Copy Markdown
Member Author

This pull request was generated by ChatGPT Codex, GPT-6. The exact model variant and configured thinking level were not exposed in this delegated session.

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.50420% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.44%. Comparing base (d00a82f) to head (c014275).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/linux/pipewire.cpp 60.50% 37 Missing and 10 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6118      +/-   ##
==========================================
+ Coverage   51.93%   52.44%   +0.51%     
==========================================
  Files         150      150              
  Lines       32862    32955      +93     
  Branches    13858    13870      +12     
==========================================
+ Hits        17066    17283     +217     
+ Misses      13738    13207     -531     
- Partials     2058     2465     +407     
Flag Coverage Δ
Alpine-aarch64 36.43% <44.70%> (+0.75%) ⬆️
Alpine-x86_64 36.54% <44.70%> (+0.75%) ⬆️
Archlinux 37.29% <42.69%> (+0.76%) ⬆️
FreeBSD-amd64 37.15% <61.40%> (+0.94%) ⬆️
Homebrew-macos-15 50.00% <ø> (ø)
Homebrew-macos-26 50.41% <ø> (ø)
Homebrew-ubuntu-24.04 38.55% <0.00%> (-0.13%) ⬇️
Linux-AppImage-aarch64 42.35% <42.69%> (+0.70%) ⬆️
Linux-AppImage-x86_64 42.59% <42.69%> (+0.70%) ⬆️
PowerShell 100.00% <ø> (ø)
Web-UI 58.14% <ø> (ø)
Windows-AMD64 42.53% <ø> (ø)
Windows-ARM64 36.11% <ø> (-0.07%) ⬇️
macOS-arm64 42.53% <ø> (+<0.01%) ⬆️
macOS-x86_64 41.44% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/linux/pipewire.cpp 39.44% <60.50%> (+23.20%) ⬆️

... and 27 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d00a82f...c014275. Read the comment docs.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Last Updated 2026-11-27 22:47:25 UTC
Source Run CI Run #7021
Commit c01427535d70e95693b73e20378c71bbf18dea14

Screenshot Comparison

PR #6118 screenshots vs screenshots baseline.

Matrix: AppImage-aarch64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: AppImage-x86_64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-AMD64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-ARM64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-arm64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-x86_64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

@ReenigneArcher ReenigneArcher left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still applicable, but I recommend holding the merge for the two findings below.

I checked head 9ecb05ebfe1827eae3b2ea1a6b85db282aad04f2 against current master (d00a82f1e874722af75afddfc4bb1d88f77d0cad). The two affected files on current master are unchanged from this PR's base, and the patch applies cleanly. #6011 and #5568 remain unmerged and do not supersede this fix.

The original hardware-validation gap has been addressed: the reporter tested this exact head on RX 590/KWin 6.8.3, confirming visible VA-API video over memory buffers across three connections in one process, with zero EGL_BAD_PARAMETER occurrences. The PR description still says hardware confirmation is pending and should be brought up to date.

Verification: git diff --check and applying the patch with git apply --check against current master passed. An isolated C++ harness using the actual timeout and factory bodies with stubbed backend factories reproduced the Vulkan pending-negotiation failure; this was a control-flow check, not a native/GPU integration test. I inspected the FreeBSD CI log and verified all 11 PipeWire tests passed. I could not rerun the Linux tests on this macOS host; its Docker daemon is unavailable.

Checks remain separate merge/verification concerns: Codecov patch coverage fails at 44.23% (29 changed lines missing or partial); FreeBSD fails X11GrabTest.DisplaySucceedsForFirstMonitor with Could not open X11 display; AppImage aarch64 hangs in the pre-existing PipeWireDisplayTest.TeardownDoesNotCloseFdThatPipeWireClosed and is cancelled, leaving its coverage upload without an artifact. These logs do not establish additional defects introduced by this patch. GitHub reports the PR mergeable and behind master, with no confirmed conflicts; it is still a draft.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Comment thread src/platform/linux/pipewire.cpp Resolved
@ReenigneArcher
ReenigneArcher marked this pull request as ready for review November 27, 2026 20:32
Keep unnegotiated storage distinct from confirmed memory so the Vulkan probe and Portal startup retry remain reachable. Guard real frames against the converter's expected storage and regression-test the format, converter, and capture paths.
@ReenigneArcher
ReenigneArcher force-pushed the fix/pipewire-negotiated-memory branch from 74b5014 to 80f1f23 Compare November 27, 2026 20:56

@ReenigneArcher ReenigneArcher left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rereviewed e3d8f9d against master at d00a82f. Both previous findings remain resolved, and I found no new functional defects. The production PipeWire code is identical to 74b5014. The original VA-API fix still applies to master.

The revised test fixture addresses the five PipeWire test failures from the previous AppImage and Ubuntu 22.04 runs. I compiled both fixture versions against PipeWire 0.3.48's actual SPA headers. The old parser rejected both formats without a frame rate and accepted both revised formats. git diff --check also passed. I did not rerun the full Linux suite. The previous Flatpak x86_64 and Ubuntu 26.04 runs failed in X11 tests, separately from the fixture failure. Previous CI run

The required SonarCloud quality gate has now failed on e3d8f9d with the same two findings. It flagged cpp:S1172 and cpp:S5213 on the existing snapshot() declaration at line 1200. To clear the gate, document PullFreeImageCb with @tparam and use the following declaration in src/platform/linux/pipewire.cpp. The callers and method body can stay as they are. I compiled the proposed declaration and method body with both caller types in an isolated harness with stubbed frame methods. SonarCloud findings

    template<typename PullFreeImageCb>
    platf::capture_e snapshot(const PullFreeImageCb &pull_free_image_cb, std::shared_ptr<platf::img_t> &img_out, std::chrono::milliseconds timeout, [[maybe_unused]] bool show_cursor) {

GitHub reports no merge conflicts. I recommend holding the merge until the required checks complete on e3d8f9d and a code owner approves. SonarCloud Code Analysis is failing, and the current native build and patch coverage results are still pending. Current checks

Review completed by Codex | Model: gpt-6.2-sol | Thinking: xhigh

@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher
ReenigneArcher merged commit 9724212 into master Nov 27, 2026
83 checks passed
@ReenigneArcher
ReenigneArcher deleted the fix/pipewire-negotiated-memory branch November 27, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant