Skip to content

test: Fix PipeWire teardown hang before 0.3.77 - #3602

Merged
rdoupe merged 3 commits into
masterfrom
fix/3596-bug-test-pipewire-teardown-wait
Nov 4, 2026
Merged

rdoupe merged 3 commits into
masterfrom
fix/3596-bug-test-pipewire-teardown-wait

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3596

What and why

test_pipewire_teardown_wait (since #3593) asks for thread-loop.start-signal and then waits unconditionally for that signal, so it knows the loop thread has entered the loop before teardown stops it (the #3577 hang). PipeWire reads that property only from 0.3.77 on, but the test builds for 0.3.60 and newer (find_package(PipeWire 0.3.60)). On 0.3.60 to 0.3.76 (Debian 12 ships 0.3.65) nothing sends the signal, and the test blocks in pw_thread_loop_wait() until the ctest timeout. CI's runners have PipeWire 1.x, so CI doesn't see it.

The test now waits for an event source's callback instead: the source is added to the loop before the start, signalled after it, and its callback (which only runs on the loop thread, from inside the loop, with the loop lock held) sets a flag and signals. The test waits under the lock until the flag is set, with a bounded wait so a regression fails rather than hangs. The lock is held from before the start, so the signal can't come before the wait, and the loop thread has set its thread id before it dispatches the event, so the later pw_thread_loop_stop() still takes the cross-thread path #3593 needed. This works on every version the test builds for, so the 0.3.60 minimum stays.

A second case, teardown_waits_only_under_the_lock_without_start_signal, builds the loop without the property. That is how PipeWire before 0.3.77 runs, so CI's 1.x runners now cover the older versions' behaviour too. Neither case's assertion changes: unlocked_waits must still be 0 after teardown. This test is our own regression test for #2431, not one of the upstream C tests the port keeps unchanged; the fix is to its setup, which was itself broken.

The last commit updates docs/knowledge/pipewire-stop-after-start.md, which recommended the start signal, to show this wait and say the start signal is only safe where the build requires 0.3.77.

No upstream issue (the test is ours).

RED → GREEN

  • RED commit: 0b0513d adds the case without the start signal and bounds the wait. On PipeWire 1.6.9 teardown_waits_only_under_the_lock_without_start_signal fails (start_and_wait_until_entered(obs_pw->thread_loop) is not true, 1 of 2 failed) after the 5 s bound; against PipeWire 0.3.65 built from its source tag, both cases fail. Before this branch, master's test against 0.3.65 hangs after [ RUN ] teardown_waits_only_under_the_lock until timeout 20 kills it, with the main thread in pw_thread_loop_wait (thread-loop.c:380) from the test's line 72.
  • GREEN: runs were on 61dd50ab2. Both cases pass against 0.3.65 and 1.6.9; 2000 runs on 1.6.9 and 500 on 0.3.65, 8 at a time, with no failure or hang. The test also compiles cleanly against 0.3.65's own headers. Under ctest (TMPDIR unset): 1/1 passed, 0 skipped. Full Tier 2 (./unittest): 716/716 against hybrid libobs and against libobs-c-reference, 3 skipped on each (the Pulse default-device and two v4l2 vivid tests, no such devices in the container); Rust tests passed; runs were on e9dc68d8e.
  • Real app (UI, protocol output or logging changes): not applicable (test-only change).

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • 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 (N/A for docs-only; a focused CI fix may push RED and GREEN together)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (not applicable: not a port)

test_pipewire_teardown_wait waits for thread-loop.start-signal before
stopping the loop (#3577), but PipeWire reads that property only from
0.3.77 on, and the test builds for 0.3.60 and newer. On 0.3.60 to
0.3.76 (Debian 12 ships 0.3.65) nothing signals and the test hangs.

Add a case that builds the loop without the property, which is how
older versions run, and bound the wait so it fails instead of hanging.
It fails on every PipeWire version until the wait stops depending on
the start signal.

Refs #3596.
The teardown test waited for thread-loop.start-signal to know the loop
thread had entered the loop, which PipeWire before 0.3.77 never sends.

Wait for an event source's callback instead. It is added before the
start, signalled after it, and runs only on the loop thread from inside
the loop, so seeing it gives the same guarantee on every version the
test builds for. The lock is held from before the start, so the signal
cannot come before the wait.

Refs #3596.
The stop-after-start note recommended thread-loop.start-signal, which
PipeWire ignores before 0.3.77. Show the event-source wait the teardown
test now uses, and say where the start signal is safe.

Fixes #3596.
@rdoupe
rdoupe requested a review from zackees as a code owner November 4, 2026 02:05
@rdoupe
rdoupe added this pull request to the merge queue Nov 4, 2026
Merged via the queue into master with commit a5218b2 Nov 4, 2026
42 checks passed
@rdoupe
rdoupe deleted the fix/3596-bug-test-pipewire-teardown-wait branch November 4, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: test_pipewire_teardown_wait: hangs on PipeWire 0.3.60 to 0.3.76

1 participant