Skip to content

linux-pipewire: Keep the Properties window when a camera control changes - #829

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/pw-camera-control-refresh
Oct 15, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/pw-camera-control-refresh

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Fixes #827

What and why

Camera control sliders (Brightness, Contrast, ...) in the Properties window of the "Video Capture Device (PipeWire)" source can be dragged again. The mouse wheel over a focused slider moves it again too.

  • control_changed() in plugins/linux-pipewire/camera-portal.c is the modified callback of every camera control. It always returned true, which tells OBSPropertiesView to rebuild all its widgets (properties-view.cpp, WidgetInfo::ControlChanged queues RefreshProperties()).
  • Drag: the first value change of a drag destroyed the slider that held the mouse, so the handle "dropped" after one step.
  • Wheel: after the rebuild, focus went to the control's new spin box. SliderIgnoreScroll ignores the wheel unless it has focus, so the wheel also moved the slider by one step only.
  • Why false is safe: a new control value changes nothing in the properties. The rebuild only re-read the same PropInfo list, so the callback now returns false.
  • Locking: control_changed() also looked up the device and called pw_node_set_param() on the UI thread without the PipeWire loop lock, while the PipeWire thread adds and removes devices and their node proxies. PipeWire printed impl_ext_end_proxy called from wrong context, check thread and locking on every change. The lookup and the call now run under obs_pipewire_lock(), like the plugin's other UI-thread paths (obs_pipewire_stream_set_framerate(), pw_portal_connection_free()).
  • No deadlock: the PipeWire thread never waits for the UI thread. Its only path into the UI, obs_source_update_properties(), reaches the Properties and Filters windows as a queued ReloadProperties().
  • Origin: the return true came from upstream (obsproject/obs-studio, "linux-pipewire: Handle property changes", 2022), not from a change in this fork.
  • V4L2 source: the native V4L2 source returns true only when VIDIOC_S_CTRL fails, so it is not affected. The reporter's device, "Laptop Webcam Module (2nd Gen) (V4L2)", is PipeWire's node for a V4L2 webcam, shown by the PipeWire source.

Reproduced in release v0.1.0-beta.20261014 (AppImage, headless). Setup:

  • private Xvfb, dbus-run-session, private PipeWire daemon and a fake camera portal;
  • a PipeWire camera node with Brightness (Int 0-255) and Contrast controls;
  • Properties opened over obs-websocket; XTest drags the Brightness handle 120 px (20 moves, 50 ms apart), or scrolls 6 wheel notches over the focused slider.
Build Drag (values the camera received) Wheel, 6 notches
v0.1.0-beta.20261014 1 (128 → 125), then the handle drops 1 (128 → 129)
master plugin in that AppImage 1 (128 → 125), then the handle drops
This branch's plugin in that AppImage 20 (128 → 59), follows the mouse 6 (128 → 134)

On the release, every change logged obs_property_modified(Brightness) -> true (logged by an LD_PRELOAD shim) and the wrong context warning. On this branch: false, and no warning.

RED → GREEN

  • RED commit: 94126e8 test/cmocka: Add a failing test for PipeWire camera control sliders.
    • test_pipewire_camera_control_refresh runs the real camera portal against a fake org.freedesktop.portal.Camera on a private D-Bus bus (GTestDBus) and a private PipeWire daemon (test_pipewire_cursor_hdr.sh), like test_pipewire_camera_renegotiate.
    • A stream node plays a camera with a Brightness control, published as PropInfo and Props params the way PipeWire's V4L2 node does.
    • The test moves the slider the way the Properties window does for each step of a drag: obs_property_modified() with the new value.
    • 1 of 2 fails in both lanes: control_change_does_not_rebuild_properties ("8 of 8 Brightness changes asked to rebuild the Properties window").
    • control_change_reaches_the_camera (guard: the camera receives brightness 100) passes.
  • GREEN: d72ae26, 2 of 2 with ENABLE_RUST_LIBOBS OFF and ON, and no wrong context warning.
    • Related camera tests: the other five test_pipewire_camera_* tests (nv12, registry_race, renegotiate, unload, unplug) pass in both lanes.
    • Full ctest (private Xvfb, system libobs-opengl masked, TMPDIR unset): 248/248 in both lanes. Every PipeWire/PulseAudio test ran; the only skipped case was open_crashes_without_obs_core (in test_audio_io and test_video_io), as on master here. With DISPLAY unset, the new test's cases skip.
    • clang-format, gersemi, ci/test_registration.py and ci/test_cmocka_sanitize.py clean.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not a port

AI note: Claude Code (Claude Opus 5.5) wrote the code, the test, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner October 15, 2026 15:47
@zackees zackees added the ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak label Oct 15, 2026
rdoupe and others added 2 commits October 15, 2026 08:50
Dragging a camera control slider (Brightness, Contrast, ...) in the
Properties window of the "Video Capture Device (PipeWire)" source drops
the handle after one step, and the mouse wheel over the focused slider
moves it by one step only. Every control's modified callback,
control_changed() in camera-portal.c, returns true, which tells the
Properties window to rebuild all its widgets: the first value change of
a drag destroys the slider that holds the mouse, and focus moves to the
rebuilt spin box, so the slider ignores further wheel events.

test_pipewire_camera_control_refresh runs the real camera portal
against a fake org.freedesktop.portal.Camera on a private D-Bus bus
(GTestDBus) and a private PipeWire daemon (test_pipewire_cursor_hdr.sh).
A stream node in the test plays a camera with one control, Brightness
0-255, published as PropInfo and Props params like PipeWire's V4L2 node
does, and records the Props the source sets on it. The test moves the
slider the way the Properties window does for each step of a drag
(obs_property_modified() with the new value).

control_change_reaches_the_camera passes (guard: the camera receives
brightness 100). control_change_does_not_rebuild_properties fails: 8 of
8 changes ask for a rebuild.

Needs an X display for obs_startup(), dbus-daemon and pipewire; skips
without them.

Refs obs-rust#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
control_changed(), the modified callback of every camera control of the
"Video Capture Device (PipeWire)" source, returned true. That tells the
Properties window to rebuild all its widgets. During a drag, the first
value change destroyed the slider that held the mouse, so the handle
dropped after one step. Focus then went to the rebuilt spin box, and the
slider ignores the mouse wheel unless it has focus, so the wheel also
moved it by one step only. A new control value changes nothing in the
properties, so the callback now returns false.

It also set the node's Props from the UI thread without the PipeWire
loop lock, while the PipeWire thread adds and removes devices and their
node proxies. PipeWire warned "impl_ext_end_proxy called from wrong
context" on every change. It now looks up the device and sets the Props
with the loop locked, like the other UI-thread paths in this plugin. The
PipeWire thread never waits for the UI thread (property reloads are
queued to it), so this cannot deadlock.

test_pipewire_camera_control_refresh: 2 of 2 pass. The warning is gone.

Fixes obs-rust#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=e3f864d87d62476e8180c8715735e0c8845be84f secs=1576 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1792080999,"gate":"rust/all/fmt","host":"linux-x86_64","key":"449bc1cfa2feb39ffb194d118d092db65759befb63090ca61fd623454617ab06","lane":"lint","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":61,"stamp":"e02b8deace7d4d792ff95e1ff670e8fe","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"449bc1cfa2feb39ffb194d118d092db65759befb63090ca61fd623454617ab06","lane":"lint","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":61,"stamp":"417b68b7b45629850f8f1ea937113785","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"22bca62d0a0ba259f0884c1ceb26a952a8a8e795b1459542dd0249a64684f255","lane":"rust-test","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":129,"stamp":"9b64d219ce8b9d8402c465140a9cf97d","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"99be3df63a55f11e3866c11014ea517c71e830a36d62ab3790b1f0cfbdc3b589","lane":"cross","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":118,"stamp":"727c1bda4f332cc5c55b37606a18c242","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"99be3df63a55f11e3866c11014ea517c71e830a36d62ab3790b1f0cfbdc3b589","lane":"cross","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":118,"stamp":"82148c0c461161a42f1273fac84fc9de","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"99be3df63a55f11e3866c11014ea517c71e830a36d62ab3790b1f0cfbdc3b589","lane":"cross","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":118,"stamp":"96b72a95fb2236ce4563e9ad689cbff4","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"99be3df63a55f11e3866c11014ea517c71e830a36d62ab3790b1f0cfbdc3b589","lane":"cross","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":118,"stamp":"3326f8fbe000f3763094bef1177b62ed","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"99be3df63a55f11e3866c11014ea517c71e830a36d62ab3790b1f0cfbdc3b589","lane":"cross","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":118,"stamp":"9eb973496cb91b1a0456489217603d5f","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"99be3df63a55f11e3866c11014ea517c71e830a36d62ab3790b1f0cfbdc3b589","lane":"cross","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":118,"stamp":"cb2b94d669ba84bbbf87ec1bc9fe2254","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
Ci-Attestation: {"at":1792080999,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5a35aadfc5cdb4f13376360e70e446517e006d2af19653deee104b7c66d0059f","lane":"tier2-linux","parents":["785cfb00ae5780652a64728141c59b4608de8464"],"secs":1268,"stamp":"9ff7b973d5dee3c75aa994b642c3478a","tree":"e3f864d87d62476e8180c8715735e0c8845be84f","v":1,"via":"run"}
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member

Rebased onto master, set ci-full (plugin change), and ran the stamped local gate (Tier 2 runs the PipeWire tests). Your RED (94126e8a6: 8 of 8 Brightness changes rebuild Properties) / GREEN (d72ae261e: 2/2, both lanes) evidence stands.

  • Rebased on master, local gate passed; pushed as e47216b.

@zackees
zackees force-pushed the fix/pw-camera-control-refresh branch from d72ae26 to e47216b Compare October 15, 2026 16:16
@zackees
zackees added this pull request to the merge queue Oct 15, 2026
Merged via the queue into obs-rust:master with commit 5d09a2e Oct 15, 2026
25 checks passed
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 16, 2026
…mode is on (obs-rust#1054)

* test/cmocka: Add failing tests for PipeWire camera automatic controls

In the Properties window of the "Video Capture Device (PipeWire)" source,
ticking "Focus, Automatic Continuous" leaves "Focus, Absolute" enabled:
the slider drags, and the camera ignores it. The same for Exposure Time,
Absolute in Auto Mode, White Balance Temperature with White Balance,
Automatic on, and Hue with Hue, Automatic on. The V4L2 driver flags these
controls inactive (V4L2_CTRL_FLAG_INACTIVE), and the V4L2 source greys
them out since obs-rust#895, but PipeWire's V4L2 node does not pass the flag on:
its PropInfo params only carry each control's id, name and range.
Menu controls (Auto Exposure, Power Line Frequency) are missing from the
window altogether: the node publishes a menu as a plain Int with labels,
and the source only reads a choice, so Auto Exposure cannot be switched
to Manual Mode from OBS.

test_pipewire_camera_control_refresh now plays two cameras the way
PipeWire's V4L2 node publishes them (the same prop ids, menus, and the
"device.api" and "object.path" node properties):
- the "UHD Camera" of obs-rust#827, with the control list its driver reports
  (uvcvideo, kernel 7.2.9): Focus, Absolute comes before Focus,
  Automatic Continuous, Auto Exposure starts in Auto Mode, and Iris,
  Absolute has a step of 0;
- a webcam with White Balance, Automatic (listed before its controls)
  and Hue, Automatic (listed after Hue), in Aperture Priority Mode.
Brightness of the existing cases now uses the UHD Camera's range (0-14).

Cases. Guards that pass:
- control_change_reaches_the_camera, control_change_does_not_rebuild_
  properties (obs-rust#829): unchanged apart from the range.
- saved_manual_modes_enable_the_controls_on_load: saved settings with
  the automatic modes off leave the manual controls enabled.
Failing:
- manual_controls_are_disabled_on_load: Focus, Absolute and Exposure
  Time, Absolute of the UHD Camera, and the webcam's white balance, hue,
  exposure and focus controls are enabled while their automatic modes
  are on. Iris, Absolute and the controls after it must stay enabled.
- toggling_autofocus_disables_and_enables_the_focus: unticking and
  ticking the checkbox, three times, asks for no rebuild and changes
  nothing.
- switching_auto_exposure_disables_and_enables_the_exposure: no Auto
  Exposure list to switch.
- toggling_white_balance_and_hue_automatic: the same for White Balance,
  Automatic and Hue, Automatic.
- menu_controls_are_shown: Auto Exposure and Power Line Frequency are
  missing. The node's device path, name and fd must not show up.
- moving_a_manual_control_keeps_the_properties: drags of Focus,
  Absolute with autofocus off and of Iris, Absolute pass; moving the
  overridden Focus, Absolute (from a script) sends it to the camera 8 of
  8 times.

6 of 9 fail, in both lanes.

Refs obs-rust#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* linux-pipewire: Disable manual camera controls while their automatic mode is on

With "Focus, Automatic Continuous" ticked in the Properties window of
the "Video Capture Device (PipeWire)" source, "Focus, Absolute" stayed
enabled: the slider dragged, and the camera ignored it (uvcvideo flags
the control inactive and refuses it with EACCES). The same for Exposure
Time, Absolute outside Manual Mode, White Balance Temperature, Red and
Blue Balance with White Balance, Automatic on, and Hue with Hue,
Automatic on. obs-rust#895 greys these out in the V4L2 source from the driver's
V4L2_CTRL_FLAG_INACTIVE, but PipeWire's V4L2 node does not pass that
flag on.

For a V4L2 camera node ("device.api" v4l2, or an "object.path" starting
with "v4l2:"), the source now knows the automatic/manual pairs the V4L2
spec defines, as uvcvideo implements them, by V4L2 control id: the node
gives a control the prop id SPA_PROP_START_CUSTOM + its V4L2 id, or
SPA_PROP_hue / SPA_PROP_exposure. A manual control is shown disabled
while its automatic control, as the window shows it, is not in its
manual mode (0, or Manual Mode for Auto Exposure), whatever the order
the camera lists them in. When the window opens, and after each change,
the states are worked out again; the window is rebuilt only when one of
them changed, so dragging a slider still never rebuilds it (obs-rust#829). An
overridden manual control is not sent to the camera; it keeps its value.

Menu controls are shown again: the node publishes a menu (Auto
Exposure, Power Line Frequency) as a plain Int with labels, not as a
choice, so the source skipped it, and Auto Exposure could not be set to
Manual Mode from OBS. A plain Int with labels is now a list. The node's
other plain values (the device's path, name and fd) are still not
shown.

test_pipewire_camera_control_refresh: 9 of 9 pass, in both lanes.

Refs obs-rust#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: gui: source property sliders practically unusable

2 participants