Skip to content

bug: linux-pipewire: picking another resolution for a running PipeWire camera renegotiates it in place (libcamera cameras on PipeWire before 1.4.9 lose the stream; upstream #10399) #933

Closed

Description

@rdoupe

Upstream OBS bug, still present in this fork after #820. On #390 the reporter (Surface Pro 5, Intel IPU3 behind libcamera 0.2.0, PipeWire 1.0.5, OBS 32.2.2) picks another resolution in the format list of a streaming "Video Capture Device (PipeWire)" source. OBS then logs [pipewire] Renegotiating stream, Error id:0 ... res:-32 (Broken pipe): connection error and unconnected, every time. #820 stopped renegotiations for a format the stream already has. A real resolution change still renegotiates. shetozz's upstream report obsproject/obs-studio#10399 (stream turns off and the picture freezes after a properties change; stephematician: libcamera logs Camera in Running state trying configure()) describes the same path. The reporter traced it, wrote a patch and tested it on that hardware (#390).

Location

  • plugins/linux-pipewire/camera-portal.c format_selected() (line 840) restarts the stream (stream_camera(), destroy + create) for a new subtype or pixel format. For a new resolution it renegotiates the running stream instead (line 865):

    } else if (camera_source->obs_pw_stream) {
    	obs_pipewire_stream_set_resolution(camera_source->obs_pw_stream, &camera_source->resolution.rect);
    }
  • Same function, line 881: when the camera lists no framerates for the selected format, a framerate kept from before is dropped with obs_pipewire_stream_set_framerate(camera_source->obs_pw_stream, NULL), which also renegotiates the running stream.

  • plugins/linux-pipewire/pipewire.c obs_pipewire_stream_set_resolution() (line 1763) and _set_framerate() (line 1728) signal renegotiate_format(), which calls pw_stream_update_params() on the running stream.

Class

Logic error: a running camera is renegotiated to a new format. On PipeWire's libcamera plugin before 1.4.9 that breaks the stream. With PipeWire 1.0.5 (Ubuntu 24.04 and derivatives) the whole PipeWire daemon crashed in our setup.

How it is reached

A PipeWire camera behind libcamera (IPU3 and other Intel IPU laptops/tablets, Raspberry Pi, ...) on PipeWire before 1.4.9, for example Ubuntu 24.04's 1.0.5 or Debian 13's 1.4.2. The user picks another resolution in the source's "Video Format" list while it streams.

What the old plugin does: port_set_format() in spa/plugins/libcamera calls Camera::configure() on a camera that is still running. libcamera refuses with Camera in Running state trying configure() requiring state between Acquired and Configured, and the plugin closes the camera while requests are still in flight. PipeWire 1.4.9 ("clear buffers when format is changed", "remove format config shortcut") stops the camera before it reconfigures it. On PipeWire 1.6 this does not reproduce.

Second path, same result: a source that kept a framerate setting for a camera that lists no framerates (PipeWire's libcamera plugin lists none, 1.0.5 and 1.4.11 checked). Opening its Properties window drops the framerate on the running stream.

Reproduced in the current release

AppImage v0.1.0-beta.20261014, headless: private Xvfb, dbus-run-session, private HOME, --multi, a fake camera portal on the private bus. Server side: a private PipeWire 1.0.5 daemon, built from the upstream tag, running its own libcamera SPA plugin, with libcamera 0.5.2 (upstream tag) and its software virtual pipeline handler as the camera (NV12, 640x480 and 320x240; no kernel modules). This host gives no access to dma-heaps or udmabuf, so a local test-only patch lets libcamera's buffer allocator hand out plain memfds. That changes where frame memory comes from, not libcamera's camera state machine or the PipeWire plugin. The OBS side uses the AppImage's bundled libpipewire 1.6.2. No session manager: a small script links the camera to each new OBS capture port once, as WirePlumber would.

Steps: the source streams NV12 640x480 from the virtual camera (color bars in the preview). obs-websocket SetInputSettings sets the format setting to 320x240. OpenInputPropertiesDialog then makes the Properties window apply it, which runs format_selected() like a click in the list does.

Build After picking 320x240
v0.1.0-beta.20261014 Renegotiating stream → Error id:0 seq:1100 res:-32 (Broken pipe): connection error → unconnected. Daemon log: Camera in Running state trying configure() requiring state between Acquired and Configured, then the daemon segfaults in the libcamera plugin's requestComplete() (backtrace under gdb). The preview stays on the last frame.
current master's plugin in that AppImage same: Broken pipe, unconnected, daemon crash
release, a saved 15 FPS framerate, only opening Properties (no resolution change) Renegotiating stream → negotiated 640x480 30/1 → Broken pipe → unconnected, daemon crash

The log lines match the reporter's. Whether their daemon also restarted is not known.

Proposed fix and failing test

Fix (the reporter's approach from #390): a resolution change restarts the stream through stream_camera(), like a subtype or pixel-format change. The obs_pipewire_stream_set_resolution() branch goes away. A framerate kept for a camera that lists none for the format is dropped as part of that restart, not with obs_pipewire_stream_set_framerate(NULL) on the running stream. pipewire.c (shared with screen capture) stays as it is. framerate_selected() stays too, because PipeWire's libcamera plugin lists no framerates and so never reaches it. Cost: a short gap while the new stream links, on every camera, including ones that renegotiated cleanly before.

RED test (cmocka, test_pipewire_camera_resolution_restart, Linux): runs camera-portal.c against a fake camera portal on a private D-Bus bus and a camera node on a private PipeWire daemon (test_pipewire_cursor_hdr.sh). The node plays the old libcamera plugin: YUY2 64x48 or 32x24, one EnumFormat per size, no framerates. It refuses a second format without a clear in between (the stream errors out). Two of three cases fail today: picking 32x24 asks the running camera for the new size in place and renegotiates the running stream, and opening Properties with a kept framerate asks the running camera for a new format. Needs an X display; skips without one.

This still needs confirming on real libcamera hardware.

Activity

  1. added
    bug
    on Oct 16, 2026
  2. rdoupe commented on Oct 16, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_pipewire_camera_resolution_restart runs the camera portal against a camera node that, like PipeWire's libcamera plugin before 1.4.9, can't take a new format while it streams. Today a resolution change, and a dropped framerate, renegotiate the running stream, so 2 of 3 cases fail.
    2. GREEN: the reporter's change from bug: linux-pipewire: cameras sending NV12 show green or crash (upstream #13823) #390. A new resolution restarts the stream through stream_camera(), and a dropped framerate is handled as part of that restart.
      PR follows today. The PR says Refs, so this stays open until it is confirmed on real libcamera hardware.
  3. added
    claimed
    on Oct 16, 2026
  4. github-actions commented on Oct 16, 2026

    @github-actions

    Claim bot: claimed by @rdoupe. It expires after 48 h (8 h on critical issues) without a progress comment here or a push, comment or review on a linked PR.

  5. reopened this on Oct 16, 2026
  6. EberhartLeberhart commented on Oct 17, 2026

    @EberhartLeberhart
    Contributor

    Tested #934 on the IPU3 hardware. It holds: no renegotiation, no -EPIPE, and no error from linux-pipewire in the whole session.

    Surface Pro 5 (Intel IPU3, ipu3-cio2 + ipu3-imgu), ov8865 rear and ov5693 front, libcamera 0.2.0, PipeWire 1.0.5, kernel 6.19.8, Linux Mint 22.3.

    What was exercised

    One source, resolution changed repeatedly from the properties dialog while the stream was running, on both cameras:

    • 14 stream rebuilds — 8 on the front camera, 6 on the rear
    • 10 distinct negotiated sizes: 160x120, 240x160, 480x320, 640x480 (x2), 720x576, 768x480, 800x600, 960x640, 1024x600, 1280x720 (x4)
    • 0 Renegotiating stream, 0 broken pipe, 0 connection error

    Every change goes paused -> unconnected -> new stream -> Negotiated format -> streaming, which is the path #934 intends. 160x120 and 240x160 are in there on purpose: those are the sizes that killed the stream every single time before.

    The only errors in the log are unrelated to this plugin — the v4l2 source probing devices at startup, a missing libnvidia-encode.so.1, the empty format JSON on a freshly added source, and the scratch config directory the test run throws away. The shutdown assertions are the 32.2.2 ones you already identified as fixed by #513.

    How it was built, so you can judge the result

    #934 touches only camera-portal.c, so rather than build the fork on this machine I applied it to the OBS 32.2.2 tree I already had: #934's format_selected() in full, plus #820's framerate_selected() hunk that it depends on, plus #391's NV12 frame layout.

    pipewire.c therefore does not carry #820's running_at_it guards. That is not reachable in this test: after #934 the camera source calls neither obs_pipewire_stream_set_resolution() nor obs_pipewire_stream_set_framerate() any more. Saying it anyway so the result is read for what it is.

    The second case you asked for cannot be reached here

    "A camera that had a framerate saved before" does not occur on this hardware, and I could not force it.

    camera_source->framerate.set only ever becomes true in framerate_selected(), which only runs when has_framerates is true. On these cameras it is false: I instrumented format_selected() and measured has_framerates == 0 on every call, for both cameras and every size. So framerate.set is never true, and #934's

    if (!has_framerates && camera_source->framerate.set) {
    

    never fires. The branch looks right to me by reading, but this hardware cannot witness it. That is the same gap as #1068: every format label advertises 30 FPS while framerate_list() finds no framerates for that format and size.

    Side observation, below OBS — one fault, three symptoms

    Not OBS and not #934, recorded so nobody chases it from this end. Below 768x600 the IPU3 pipeline handler picks the sensor's binned mode, and that mode runs three times too fast. Measured with cam, no OBS and no PipeWire, same scene back to back:

    requested sensor mode delivered exposure gain Y mean
    1280x720 native 29.9 fps 8279 us 16.0 8.0
    960x540 native 29.9 fps — — 7.4
    768x600 native 30.0 fps — — 6.9
    640x480 binned 90.1 fps 2743 us 16.0 1.1
    320x240 binned 90.9 fps — — 1.1
    160x120 binned 89.9 fps — — 1.1

    8279 / 2743 = 3.02, exactly the frame-rate factor: at 90 fps the exposure cannot exceed ~11 ms. Analogue gain is already pinned at its maximum 16.0 in both modes, so nothing compensates. Hence one fault with three faces: three times the frame rate, a capped exposure, and a picture dark enough to read as black at the small sizes. OBS receiving three times the frames it negotiated is the stutter I mentioned earlier.

    (Also: 800x600 does not exist on this sensor — libcamera adjusts it to 768x600.)

    From my side #933 can close.

  7. zackees commented on Oct 17, 2026

    @zackees
    Member

    Thank you @EberhartLeberhart, that's exactly the coverage we couldn't do without the hardware: 14 rebuilds across both IPU3 cameras, including 160x120 and 240x160, with no renegotiation or EPIPE. Closing as fixed by #934. If it comes back on a later build, reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugclaimed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions