Repository navigation
Description
Our test, from the scene item visibility audio ramp characterization (#1815, tracked in #1814). In a full ctest -j4 against libobs-c-reference (with test_pulse_monitor_device failing in the same run, so the machine was loaded), hide_only_item failed:
hiding the only item: changed at sample 0 of the tick at -17366501 ns from the call (19156 ns long), allowed 833-834
hiding the only item: the change is not on the sample of the call
[ FAILED ] hide_only_item
The rerun passed, and so did 20 runs alone and 24 runs 8 at a time. It is the test that is wrong here, not libobs: it assumes every tone of the scene has its audio in each tick it captures, and on a loaded machine that isn't always true.
Location
test/cmocka/test_scene_audio_actions.c, toggle() and check_change(). The test's tone source pushes 10 ms of audio at a time from its own thread, timestamped on the wall clock, each block pushed at the time it starts. The case brackets obs_sceneitem_set_visible() with os_gettime_ns(), captures the program mix, and requires the mix to read the old level up to the sample of the call and the new level from it on, in every captured tick.
Class
Flaky test: a false failure. Not a product bug: libobs does what #1815 characterized.
How it is reached
When the tone thread wakes too late for a tick, libobs has rendered that tick without the tone's audio. process_audio_source_tick() marks the tone's audio pending (obs-audio.c.h) and leaves it out of the tick. Then:
- if it is the scene's only audible source,
scene_audio_render()finds no timestamp, so it applies every queued action at once (process_all_audio_actions(), pinned in libobs: Move the scene item visibility audio ramp into obs-scene-audio-actions.c #1815 as characterized, not endorsed) and outputs nothing for the tick. A hide then shows up on sample 0 of that tick: this is the failure above; - if it is the other tone, or the shown one, that tick's mix is missing that tone, and
check_change()fails on the first sample with the wrong level ("sample 0 is 0.500000, expected 0.750000").
Reproduced
master 1751566, headless (private Xvfb with -noreset, private D-Bus, fresh HOME), 8 runs at a time with 16 busy loops pinned one per CPU. The test was built with a local diagnostic (not committed) that records, in the raw audio callback, each tone's and the scene's audio_pending for each captured tick:
| Library | Runs | Failed |
|---|---|---|
| libobs-c-reference | 64 | 3 (all three hide_over_other_item) |
| libobs-c-reference, with the diagnostic | 96 | 3 (one in each of hide_only_item, hide_over_other_item, show_over_other_item) |
In every failure, libobs had left a tone out of a captured tick. The hide_only_item one is the failure above. The call fell on sample 470 of tick 0, and in that tick tone a's audio was pending and so was the scene's (it had no audio, and took the apply-all path). The whole tick and every tick after it were silent:
hiding the only item: changed at sample 0 of the tick at -9812019 ns from the call (14577 ns long), allowed 470-471
DIAG tick 0 ts-9812019 first 0.000 last 0.000 a_pending 1 b_pending 0 scene_pending 1 lead_after_tick_ns 19416666
DIAG tick 1 ts+11521314 first 0.000 last 0.000 a_pending 0 b_pending 0 scene_pending 1 ...
At the callback, tone a's buffer already reached 19 ms past the end of the tick, so its audio came after the tick was rendered, not never. In the other two: tone b was pending in the hide's tick (the mix read 0.5, not 0.75), and tone a was pending in the show's tick (the mix read 0.25 for the whole tick, then 0.75 from sample 0 of the next one). No failure was in a tick where every tone had its audio.
Fix
Have the capture record, from libobs, which tones of the scene were left out of each tick: the raw audio callback runs on the audio thread right after the tick is rendered, so it reads each tone's audio_pending for that tick. That flag comes from the tone's own buffer, not from the ramp code under test. When a capture has such a tick, the toggle can't show where the action landed, so the case toggles the item back, waits until the mix is back at its level, and toggles again. Every check stays the same, on the try whose ticks all had their tones' audio. No wall-clock bound: the wait for a good try uses the test's existing 20 s deadline. PR follows.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 22, 2026
Claiming: #1834. Fix ready (test-only); PR follows.
test: Retry a scene audio toggle when a tone's audio came late for a …
test: Capture every tick a scene audio toggle may land in (obs-rust#1852