Skip to content

test: Retry a scene audio toggle when a tone's audio came late for a tick - #1835

Merged
zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:fix/scene-audio-test-no-audio-tick
Oct 22, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
rdoupe:fix/scene-audio-test-no-audio-tick

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1834

What and why

test_scene_audio_actions (#1815) no longer fails on a loaded machine. On master it failed 3 of 64 and 3 of 96 runs under load, for example hide_only_item seeing the hide on sample 0 instead of the sample of the call.

  • Each case brackets obs_sceneitem_set_visible() with os_gettime_ns() and requires the captured mix to read the old level up to the sample of the call and the new level from it on, in every captured tick. That requires every tone of the scene to have its audio in each of those ticks.
  • On a loaded machine, a tone's thread can wake too late for a tick. libobs then marks the tone's audio pending (process_audio_source_tick()) and leaves it out of the tick. If it is the scene's only audible source, the scene has no audio in that tick, and scene_audio_render() applies every queued action at once (process_all_audio_actions(), characterized in libobs: Move the scene item visibility audio ramp into obs-scene-audio-actions.c #1815, not endorsed), so a hide lands on sample 0. Otherwise the tick's mix is just missing that tone. Neither says where the action would have landed.
  • A local diagnostic (not committed) recorded each tone's and the scene's audio_pending per captured tick. In each of the 3 failures it caught, one per case, libobs had left a tone out of a captured tick. In the hide_only_item one, the call fell on sample 470, and in that tick the tone and the scene were both pending: the apply-all path. The tone's audio reached 19 ms past the tick's end by the time of the callback, so it came late, not never. Details in the issue.
  • The capture now records, in the raw audio callback, which tones of the scene libobs left out of each tick. The callback runs on the audio thread right after the tick is rendered, so it reads that tick's audio_pending. That flag comes from the tone's own buffer, not from the ramp code under test. A toggle whose capture has such a tick is undone (the item toggled back, the mix back at its level) and tried again, up to the test's existing 20 s deadline, which only bounds the wait. There is no wall-clock bound in any check. Each retry is logged ("tick N has no audio from tone a (it came late), trying again").
  • show_over_other_item now shows through toggle() too, so its show is retried the same way. Its first hide only sets the case up, so it is a plain hide and wait.

Test expectation change (maintainer sign-off): a toggle whose capture has a tick with a tone of the scene left out (pending) is no longer checked, and the case toggles back and tries again. Before, the test checked that capture and failed. Nothing else changes: every check (each sample, contiguous ticks, the sample the call maps to, the references) is the same, and runs on the try whose ticks all had their tones' audio. The test can't pass without such a try: if every try until the deadline has a late tone, it fails, and says so.

Headless (private Xvfb with -noreset, private D-Bus, fresh HOME). "Under load" is 8 runs at a time with 16 busy loops pinned one per CPU:

Build Library Under load Idle
master 1751566 libobs-c-reference 3 of 64 failed; 3 of 96 failed with the diagnostic
This branch libobs-c-reference 0 of 160 failed (17 retries), then 0 of 64 after the rebase (2 retries) 0 of 8
This branch hybrid libobs 0 of 64 (11 retries), then 0 of 64 (2) 0 of 8
This branch libobs, C backend 0 of 64 (13 retries), then 0 of 64 (1) 0 of 8

Mutants: I ran both mutant sets from #1815 against this test. Each mutant was built into libobs (C backend) and the test was run once:

RED → GREEN

  • RED commit: N/A, a focused flaky-test fix with RED and GREEN together. The flake can't be made deterministic, so its RED is master's runs under load above (3 of 64, and 3 of 96), with the libobs state of each failure from the diagnostic.
  • GREEN: 95226ee. test_scene_audio_actions 4/4 in every run above, in both lanes and against all three libraries: 0 failures in 480 runs under load. Full ctest -j4 (HYBRID, OBS_BUILD_C_REFERENCE=ON) against libobs-c-reference: 376 of 376, none skipped. uv run ci/local_gate.py --lane lint: ok.
  • Real app (UI, protocol output or logging changes): N/A, 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
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

…tick

test_scene_audio_actions (obs-rust#1815) failed now and then on a loaded machine,
for example hide_only_item seeing the hide on sample 0 instead of 833.
Each case requires every tone of the scene to have its audio in each tick
it captures. When a tone's thread wakes too late for a tick, libobs marks
the tone's audio pending and leaves it out of that tick. If that tone is
the scene's only audible source, the scene has no audio in the tick and
libobs applies every queued action at once (process_all_audio_actions(),
characterized in obs-rust#1815), so a hide lands on sample 0. Otherwise the tick's
mix is missing that tone. Neither says where the action would have landed.

The capture now records, in the raw audio callback, which tones of the
scene libobs left out of each tick. The callback runs on the audio thread
right after the tick is rendered, so it reads that tick's audio_pending,
which comes from the tone's buffer, not from the ramp code under test. A
toggle whose capture has such a tick is undone (toggled back, the mix
back at its level) and tried again, up to the test's existing deadline.
The checks are unchanged, on the try whose ticks all had their tones'
audio. show_over_other_item now shows through toggle() too, so its show
is retried the same way; its first hide only sets up the case.

Fixes obs-rust#1834
@rdoupe
rdoupe requested a review from zackees as a code owner October 22, 2026 21:46
@zackees
zackees added this pull request to the merge queue Oct 22, 2026
Merged via the queue into obs-rust:master with commit 34b8813 Oct 22, 2026
30 checks passed
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 23, 2026
)

test_scene_audio_actions still failed now and then on a loaded machine
after obs-rust#1835, with a change on sample 0 and no tone left out of any
captured tick.

The audio thread renders a tick one tick plus the audio buffering after
the tick's time. libobs adds buffering when a source's audio comes late,
so after a late tone the ticks rendered right after the call can have
times well before it. The capture only took ticks from four ticks before
the call, so it did not see them. If a tone was left out of one of them,
the scene had no audio and libobs applied the action at once there, and
every captured tick read the new level from sample 0.

The capture now takes every tick rendered after it starts, whatever its
time, and also records whether the scene itself had no audio in a tick:
a toggle is tried again when a tone was left out of any of them, or the
scene was while it still had audio to play. libobs also renders ticks it
adds as buffering without delivering them, which the raw callback can't
see, so the test sets fixed buffering (about 200 ms): libobs adds all of
it on the first tick, before any case, and never again.

Refs obs-rust#1834
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: test_scene_audio_actions fails on a loaded machine when a tone's audio comes late for a tick

2 participants