Repository navigation
test: Fix PipeWire teardown hang before 0.3.77 - #3602
Merged
Merged
Conversation
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.
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.
Fixes #3596
What and why
test_pipewire_teardown_wait(since #3593) asks forthread-loop.start-signaland 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 inpw_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_waitsmust 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
teardown_waits_only_under_the_lock_without_start_signalfails (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_lockuntiltimeout 20kills it, with the main thread inpw_thread_loop_wait(thread-loop.c:380) from the test's line 72../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.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag changes)