Repository navigation
test: Retry a scene audio toggle when a tone's audio came late for a tick - #1835
Merged
zackees merged 1 commit intoOct 22, 2026
Merged
Conversation
…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
4 of 7 tasks
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
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 #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_itemseeing the hide on sample 0 instead of the sample of the call.obs_sceneitem_set_visible()withos_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.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, andscene_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.audio_pendingper captured tick. In each of the 3 failures it caught, one per case, libobs had left a tone out of a captured tick. In thehide_only_itemone, 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.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_itemnow shows throughtoggle()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.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: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:
obs-scene-audio-actions.c.hon master: the test fails or hangs on the same 14 of 22 mutants as before. The one where the span includes the change frame (one frame late) survived 1 of 7 runs. With the test on master it was caught in 6 of 6 runs. A one-frame-late change is caught only when the call's time maps to one sample, not two, so this is chance, and the retry doesn't change it: a mutant doesn't make a tone's audio late.test_scene_audio_action_stepscatches that mutant every time.process_all_audio_actions()applying once only), and the rest are boundary or ordering mutants that only the steps test reaches, as in libobs: Move the scene item visibility audio ramp into obs-scene-audio-actions.c #1815.RED → GREEN
test_scene_audio_actions4/4 in every run above, in both lanes and against all three libraries: 0 failures in 480 runs under load. Fullctest -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.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