Repository navigation
linux-pipewire: Restart a camera stream for a new resolution - #934
Merged
zackees merged 2 commits intoOct 16, 2026
Merged
Conversation
zackees
approved these changes
Oct 16, 2026
zackees
enabled auto-merge
October 16, 2026 00:54
This was referenced Oct 16, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 16, 2026
Picking another resolution in the format list of a streaming "Video
Capture Device (PipeWire)" source renegotiates the running stream in
place: format_selected() calls obs_pipewire_stream_set_resolution(). A
camera behind libcamera cannot be reconfigured while it delivers, and
PipeWire's libcamera plugin before 1.4.9 does not stop it first, so the
stream dies ("Broken pipe", then "unconnected"; with PipeWire 1.0.5 the
whole daemon crashes). Reported on a Surface Pro 5 with an IPU3 camera
in obs-rust#390, upstream obsproject/obs-studio#10399.
The same happens when the format list drops a framerate kept from
before (the camera lists none for the format): format_selected() then
calls obs_pipewire_stream_set_framerate(NULL) on the running stream.
test_pipewire_camera_resolution_restart runs camera-portal.c against a
fake camera portal on a private D-Bus bus and a camera node on a
private PipeWire daemon. The node plays a libcamera camera: YUY2 at
64x48 or 32x24, one EnumFormat per size, no framerates, and it refuses
a second format without a clear in between, like the old plugin. Two of
three cases fail: opening Properties with a kept framerate asks the
running camera for a new format, and picking 32x24 renegotiates the
running stream instead of starting a new one.
Needs an X display for obs_startup(), dbus-daemon and pipewire; skips
without them.
Refs obs-rust#933.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
format_selected() restarted the camera stream (stream_camera()) for a
new subtype or pixel format, but renegotiated a running stream in place
for a new resolution. Cameras behind libcamera cannot be reconfigured
while they deliver; with PipeWire's libcamera plugin before 1.4.9 the
stream then dies ("Broken pipe", then "unconnected"), and with PipeWire
1.0.5 the daemon crashes. A new resolution now restarts the stream like
a new pixel format does.
When the camera lists no framerates for the selected format, a
framerate kept from before was dropped with
obs_pipewire_stream_set_framerate(NULL), which renegotiated the running
stream in the same way. It is now dropped as part of the restart.
The framerate list is filled before the restart decision.
framerate_selected() is unchanged: PipeWire's libcamera plugin lists no
framerates (1.0.5 and 1.4.11 checked), so it is not reached for these
cameras.
The resolution change and its hardware test on an IPU3 camera come from
the reporter of obs-rust#390.
test_pipewire_camera_resolution_restart: 3 of 3 pass.
Refs obs-rust#933.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
force-pushed
the
fix/pw-camera-resolution-restart
branch
from
October 16, 2026 03:24
fc16f3b to
800df7f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #933
What and why
This says Refs, not Fixes: #933 stays open after merge until the change is confirmed on real libcamera hardware (the reporter's Surface). Our check used libcamera's virtual camera.
Picking another resolution for a streaming "Video Capture Device (PipeWire)" source now restarts the camera stream at the new size. It no longer renegotiates the running stream.
-EPIPE. This PR takes their resolution change as is and adds a test and the framerate part below.format_selected()inplugins/linux-pipewire/camera-portal.crestarted the stream (stream_camera(), destroy + create) for a new subtype or pixel format. For a new resolution it calledobs_pipewire_stream_set_resolution(), which renegotiates the running stream.Camera::configure()on the running camera anyway. libcamera refuses (Camera in Running state trying configure()), and the stream ends inres:-32 (Broken pipe)andunconnected. With PipeWire 1.0.5 (Ubuntu 24.04 and derivatives) the PipeWire daemon itself crashed in our setup. PipeWire 1.4.9 and later stop the camera first.stream_camera()path as a pixel-format change. Theset_resolutionbranch is gone.format_selected()dropped a framerate kept from before withobs_pipewire_stream_set_framerate(NULL)on the running stream. On the old plugin that crashed the daemon the same way (reproduced with the release and a saved framerate, by only opening Properties). The framerate is now dropped as part of the restart. The framerate list is filled before the restart decision, so a format change and a dropped framerate give one restart, not two.framerate_selected()is unchanged. PipeWire's libcamera plugin lists no framerates (1.0.5 and 1.4.11 checked; also what the reporter measured), so that callback is never reached for these cameras. On cameras that list framerates (V4L2 behind PipeWire), a picked framerate still renegotiates in place, as before.pipewire.cis unchanged, so screen and window capture keep their in-place renegotiation.Release check (AppImage v0.1.0-beta.20261014, headless: private Xvfb,
dbus-run-session, fake camera portal on the private bus). Server side: a private PipeWire 1.0.5 daemon with its own libcamera SPA plugin and libcamera 0.5.2's softwarevirtualcamera (NV12, 640x480 and 320x240), both built from upstream tags. libcamera's buffer allocator was patched locally to use plain memfds, because this host gives no access to dma-heaps or udmabuf. That changes where frame memory comes from, not the camera state machine or the plugin. Client side: the AppImage's libpipewire 1.6.2. A script links each new capture port once, as a session manager would. The resolution is picked by setting the format to 320x240 (SetInputSettings) and opening Properties (OpenInputPropertiesDialog), which runsformat_selected()like a click in the list.Renegotiating stream→res:-32 (Broken pipe)→unconnected. libcamera:Camera in Running state trying configure(). The daemon segfaults in the plugin'srequestComplete(). The preview freezes.unconnected(no error) → new stream →Size: 320x240→streaming, preview live. Two more switches (→ 640x480 → 320x240) the same. No libcamera error, daemon up.Renegotiating stream→Broken pipe→ daemon crashOn the host's PipeWire 1.6.8 with a fake camera that renegotiates cleanly (V4L2-like), this branch also changes resolution, with the restart gap above. We showed this with a software camera only. It still has to be confirmed on real libcamera hardware.
RED → GREEN
test/cmocka: Add failing test for a PipeWire camera resolution change.test_pipewire_camera_resolution_restartruns the real camera portal against a fakeorg.freedesktop.portal.Cameraon a private D-Bus bus (GTestDBus) and a private PipeWire daemon (test_pipewire_cursor_hdr.sh), liketest_pipewire_camera_renegotiate.pw_stream_set_error), likeCamera::configure()on a running camera.resolution_change_restarts_the_stream: "the streaming camera was asked for 32x24 in place 1 time(s)".dropped_framerate_does_not_reconfigure: "opening Properties asked the streaming camera for a new format 1 time(s) in place".camera_streams(guard) passes.ENABLE_RUST_LIBOBSOFF and ON.Renegotiating stream, and the camera streaming at the new size.test_pipewire_camera_*tests (control_refresh,nv12,registry_race,renegotiate,unload,unplug) pass in both lanes. 15 repeats of the new test: all passed. WithDISPLAYunset, its cases skip.libobs-openglmasked, TMPDIR unset): 250/250 withENABLE_RUST_LIBOBSOFF and 250/250 ON. Every PipeWire/PulseAudio test ran. Skipped cases:open_crashes_without_obs_core(test_audio_io,test_video_io), andtest_startup_alloc_stable/test_startup_cycle_stress, which skip with the system GL module masked.ci/test_registration.pyandci/test_cmocka_sanitize.pyclean.Checklist
master-W..., ratchets): noneAI note: Claude Code (Claude Opus 5.5) wrote the test, the commit messages and this text under the submitter's direction, applied the reporter's fix, and ran the tests above on the submitter's machines.
🤖 Generated with Claude Code