Repository navigation
Description
Follow-up of our #393 and #513, which both listed this under "Not fixed here" (upstream obsproject/obs-studio#13971): OBS can crash at startup when the scene collection has a "Video Capture Device (PipeWire)" source. The crash is a SIGSEGV on the PipeWire thread right after [pipewire] Created registry is logged, before any [camera-portal] Found device line. The camera tests from #393 and #513 hold the registry events until the first roundtrip to avoid this race.
Location
plugins/linux-pipewire/pipewire.cobs_pipewire_connect_fd()adds the camera portal's registry listener (line 1341) and unlocks the PipeWire thread loop (line 1345) before it returns.plugins/linux-pipewire/camera-portal.con_pipewire_remote_opened_cb()stores the returned connection inconnection->obs_pwonly after that (line 1081).- A registry global the PipeWire thread delivers in between reaches
on_registry_global_cb(), which callsobs_pipewire_get_registry(connection->obs_pw)with a NULL connection (line 1000). For a source set to that camera it also passes the NULL connection toobs_pipewire_connect_stream()(line 287).
The code is upstream's camera portal. This fork changed nothing here.
Class
Crash at startup (NULL dereference on the PipeWire thread, SIGSEGV). It is a timing race: it happens more often on a busy machine.
How it is reached
Start OBS with a scene collection that has a PipeWire camera source. The camera portal connects to PipeWire as the collection loads, and the race is lost when the PipeWire thread delivers the first registry global before the main thread has stored the connection.
Reproduced in the current release
Release v0.1.0-beta.20261014 (AppImage), headless: private Xvfb, a private D-Bus session with a fake camera portal, and a private PipeWire daemon (WirePlumber, no device monitors) with 8 producers posing as 640x480 NV12 cameras. The saved scene collection has 8 PipeWire camera sources. Each run is a cold start of OBS: it starts, all 8 cameras negotiate, then OBS gets SIGTERM. The machine is busy (one busy loop per core and 30 more PipeWire nodes), and the two builds of each pair ran side by side.
| Build | Starts | Crashed at startup |
|---|---|---|
| release | 200 | 4 |
same AppImage with the fixed linux-pipewire.so (below) |
200 | 0 |
| release (earlier pair) | 200 | 6 |
same AppImage with the fixed linux-pipewire.so (earlier pair) |
200 | 0 |
In total, 10 of 400 starts crashed with the release and 0 of 400 with the fix. Each crash was a SIGSEGV on the PipeWire thread: the log ended right after [pipewire] Created registry, and no Found device line had been logged. That matches the upstream report: two cores in 10 starts, obs_pipewire_get_registry(NULL) in on_registry_global_cb.
Proposed fix and failing test
Fix: add the registry listener in a separate step, obs_pipewire_add_registry_listener(), which the camera portal calls after it has stored connection->obs_pw. No registry event can then arrive before the connection is set. The upstream reporter proposed and tested this fix. obs_pipewire_connect_fd() no longer takes registry events (the screencast portal never passed any).
RED test (cmocka, test_pipewire_camera_registry_race): the real camera portal against a fake camera portal on a private D-Bus bus and a camera node on a private PipeWire daemon, like test_pipewire_camera_unplug. A source is set to the camera before the camera portal connects, as when a saved collection loads. The test links with --wrap. It holds the camera portal right after obs_pipewire_connect_fd() returns, until a roundtrip shows that the registry has delivered its globals. It counts the calls made with a NULL connection instead of letting them crash. Today 3 obs_pipewire_get_registry() calls and 1 obs_pipewire_connect_stream() call get a NULL connection, and the source never connects a stream. That happens in every run, in both libobs lanes. If the NULL is passed through, the test process segfaults.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 14, 2026
Claiming: this issue.
test_pipewire_camera_registry_raceruns the real camera portal against a fake portal and a private PipeWire daemon, with a source set to the camera before the camera portal connects. It holds the camera portal right afterobs_pipewire_connect_fd()returns, until the registry has delivered its globals. Today 3 registry reads and 1 stream connect get a NULL connection, and the source never streams.obs_pipewire_add_registry_listener()). The upstream reporter proposed this fix. The unplug and unload tests no longer hold registry events.PR today.
test/cmocka: Add a failing test for the camera portal registry race
linux-pipewire: Listen to the camera registry once the connection is set
rdoupe commentedon Oct 14, 2026
@TheMorpheus407 you reported this in obsproject/obs-studio#13971 (OBS crashes at startup with a PipeWire camera source,
obs_pipewire_get_registry(NULL)inon_registry_global_cb), so a heads-up: it's fixed here in obs-rust by #775, merged today with a regression test, using the fix you proposed. You're credited as co-author on the fix commit.Cause, as you found: the camera portal's registry listener was added, and the PipeWire thread loop unlocked, before the camera portal had stored its connection, so a registry global arriving in between used a NULL connection. Now the listener is added only after the connection is stored. In our release, 10 of 400 cold starts with 8 PipeWire cameras on a busy machine crashed at startup; with the fix, 0 of 400.
It will be in the next obs-rust daily release after 0.1.0-beta.20261014: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's
obs-studio-rust-gitin the AUR). obs-rust is an AI-assisted fork of OBS.If you get a chance to try it, a reply here on whether the startup crash is gone for you would really help.
linux-pipewire: Listen to the camera registry once the connection is …