Files
piik/native/capture/linux/README.md
T
Matt Van Horn 4ae3619f87 fix(linux): retry KDE remote control with a temporary session
## Problem and outcome / 问题与结果

Enabling remote control on KDE Plasma Wayland stops native capture even though screen and system-audio sharing were already working. The capture process exits with status 2, and the remote-control request fails because the capture profile never becomes ready. The remote-desktop open asks for transient persistence and passes a restore token. KDE's portal answers with InvalidArgument because remote desktop sessions cannot persist, and that error is treated as a failed capture open.

When a remote-input create fails with that persistence error and has not already been retried, the error is freed and session creation runs again with persist mode none and a null restore token. The retry flag allows only one attempt, so a second rejection still fails the request.

The Linux native check compiles and runs a headless portal regression that rejects the first remote-desktop create with that error and expects the second create to use persist mode none and no token, and the README lists that regression with the other headless checks.

Refs #549

## Release notes

### English

On KDE Plasma Wayland, enabling remote control now retries with a temporary session when the desktop rejects permission persistence.

### 中文

在 KDE Plasma Wayland 中开启远程控制时,如果桌面环境拒绝记住授权,Piik 会改用临时会话重试。

## Verification / 验证

npx --no-install vitest run tests/release-automation.test.ts finished with 6 passing tests in 1 file.
The tests passed with the Piik change applied; a run with it reverted gave no clear result, so no test is shown to catch this bug.
The new test native/capture/linux/portal.test.c did not run here: no test runner for it was available.

Maintainer verification on Alpine Linux with libportal 0.9.1 and GStreamer 1.28.3 passed the Linux capture build and headless Portal tests.

## Impact / 影响

Scoped to the files listed above; no other caller or consumer changes.
2026-11-21 03:35:16 -04:00

3.4 KiB

Linux Capture Process

The Linux sidecar keeps the shared Native App contract while delegating desktop integration to the standard Linux media stack. XDG Desktop Portal owns the screen/window choice, PipeWire supplies the selected stream, and GStreamer selects an installed element classified as a hardware H.264 video encoder. Piik adds only the current product profile, Annex-B access-unit framing, key-frame requests, and the bounded SMED output protocol.

The Portal restore token remains in the active share process and lets a live quality change reacquire the same selected source without inventing a second source picker. System playback audio uses the PipeWire PulseAudio compatibility service when its GStreamer source is installed. Per-process audio is not advertised.

Build on a Linux desktop with development packages for libportal and GStreamer:

sh native/capture/linux/build.sh /outside/repository/build

Run npm run check:native on Linux to compile the sidecar, run the headless output-profile, source-geometry, segment-timestamp, retirement and remote-desktop persist-retry regressions, and validate its probe/source list. The same check runs when the Linux CI job packages an App candidate. For the native build and regression alone, add --check to the command above. The test uses synthetic input and GStreamer's core/base elements and needs no display, Portal session, capture device or hardware encoder; physical capture remains a separate check.

Input ticks, output activation and encoded frames use GStreamer running time, not raw buffer timestamps: encoders may offset PTS and the segment together. Keyframe events retain raw PTS for their timestamp field and normalized running time for their running-time field. The Portal stream uses the pipeline clock so unchanged content does not stop output keepalives.

GStreamer fits each source within the output's even-dimension ceilings while preserving presentation aspect. It renegotiates those dimensions on source resize; the encoded sample's caps supply the actual frame size. Requested profile dimensions remain configuration facts, not measured output.

Each output bin contains its downstream flow failures before they reach the shared tee. The main-context bus handler reports that output as unavailable and closes its valve before stopping the branch. Failed outputs remain retired for the source generation; healthy siblings continue. Shared source, decoder and protocol-output failures still end the capture run. Streaming callbacks report errors through the bus and never stop their own branch.

Runtime requirements are the desktop Portal/PipeWire services, a GStreamer PipeWire source, and an installed GStreamer hardware H.264 encoder. If any part is unavailable, the App reports no Linux Native path and the same Browser capture choice remains available. These system libraries and services are not bundled; their distribution-provided license notices remain applicable. Linux App packages repeat the dependency and source links in THIRD-PARTY-NOTICES.txt.

Primary references: