Skip to content

test: test_async_delay_audio's tone breaks under load in the asan job #3368

Closed

Description

@vpacher

What happens

tone_continuous_with_3s_video_delay fails now and then in the asan job at test/cmocka/test_async_delay_audio.c:466:

video delay 3000 ms: the tone was broken up 1 times in 4000 ms

It happened in a serial nightly too (41203573843), so it isn't only other tests competing for the CPU. ASan's slowdown is enough. The test has the timing resource lock since #3290.

What to do

The same class as #838 (real-time audio tests lose audio under load). Make the test independent of real time where it can be: drive the audio clock instead of sleeping, or measure the break from timestamps, not from wall-clock gaps. If a break is a real audio dropout in OBS, fix that.

Then its entry goes from the sanitizer harness's known list (kind flaky, #3290).

Activity

  1. added
    quality
    P3
    size:M
    on Nov 1, 2026
  2. vpacher commented on Nov 1, 2026

    @vpacher
    MemberAuthor

    /ready

  3. added
    ready
    on Nov 1, 2026
  4. vpacher commented on Nov 1, 2026

    @vpacher
    MemberAuthor

    Claiming: make test_async_delay_audio independent of real time

    Plan (one PR, after #3290):

    1. Find where the break comes from: a real dropout or a wall-clock gap in the measurement (with Flaky: real-time audio cmocka tests lose audio under machine load (test_vlc_playlist_gap, test_group_hide_transition_audio) #838).
    2. RED/GREEN: measure from timestamps or drive the audio clock; fix a real dropout if there is one.
    3. Drop its flaky entry from the known list.

    First PR: after #3290 merges.

  5. vpacher commented on Nov 1, 2026

    @vpacher
    MemberAuthor

    Blocked: waiting on #3290

  6. added
    claim-blocked
    on Nov 1, 2026
  7. removed
    claim-blocked
    on Nov 1, 2026
  8. moved this from Blocked to In progress in obs-rust Multiviewon Nov 1, 2026
  9. vpacher commented on Nov 1, 2026

    @vpacher
    MemberAuthor

    Findings so far: this looks like a real audio dropout in libobs, not a test that runs out of real time.

    Reproduced with the asan build through the sanitizer harness (run_one_test, so ASAN_OPTIONS=...:fast_unwind_on_malloc=0), pinned to 4 cores with load: 2 of 8 runs fail, both in the first case, tone_continuous_with_3s_video_delay, as in CI.

    An instrumented copy of the test (local only) recorded how late av_thread hands each packet to obs_source_output_audio():

    Run Producer late, at most Samples heard Loud samples Breaks
    failing 0.0 ms during the 4 s window (0.8 ms at most in the run) 191488 102602 1
    failing same 191488 105011 2
    passing (6 runs) same 191488 to 192512 119683 to 120323 0

    So every packet arrives on time and the mix keeps producing samples, but in a failing run about 15000 to 18000 fewer samples are loud: roughly 300 to 370 ms of the tone is missing from the mix. The log shows OBS's INFO lines but no "adding ... audio buffering" and no timestamp message in that case.

    That points at the audio timing path that upstream obsproject/obs-studio#13830 is about (placing the source's audio by the delayed video's timing, timing_adjust against MAX_TS_VAR), which a slow run (the harness option makes this build about 4 times slower) seems to reach again, only right after startup with the 3 s delay. Next step is to instrument that path (timing resets, timing_adjust, the audio placement) in a run that fails. The test keeps its flaky entry until then.

  10. 5 remaining items

  11. zackees commented on Nov 2, 2026

    @zackees
    Member

    Reproduced on current master C rollback under ASAN/UBSAN, slow allocation unwinder, four CPUs with three competing CPU processes, cold Mesa shaders. The unchanged first case reports 192512 samples, 111319 loud samples, two tone breaks.

    Temporary tracing identifies the placement discontinuity: at 7.472 s the displayed video timestamp is 4.100 s and timing_adjust jumps forward 300 ms. At 7.487 s the next audio packet is placed rather than appended, inserting the corresponding silence. At 9.793 s the video adjustment drops 133 ms and audio repositions again. The initial idle run passes all six assertions with no such shifts.

    Investigating the Video Delay filter queue: after initial buffering it pops exactly one old frame per graphics-selected incoming frame. A graphics stall changes that cadence, so it can later return frames too old or too new for the configured delay. I am testing a timestamp-based selection (newest eligible frame, hold when none is old enough) with a deterministic synthetic timestamp sequence before changing audio timing thresholds.

  12. zackees commented on Nov 2, 2026

    @zackees
    Member

    Update: #3515 contains a scoped partial fix, not a resolution of this audio failure. Two deterministic cases expose independent Video Delay queue errors after skipped input ticks and historical timestamp gaps; the new timestamp-based selector fixes both (plus zero-delay and timestamp-reset guards pass under ASAN/UBSAN with leak detection).

    Crucially, the same four-CPU/three-load/cold-shader/slow-unwinder audio reproduction still fails with the corrected filter (191488 samples, 109680 loud, two breaks). Another traced run passes. The exemption therefore stays, and the PR uses Refs, not Fixes. The video reanchor discontinuity is established, but attributing the remaining dropout entirely to the filter queue would be wrong; the upstream async frame pacing/graphics timing still needs investigation.

  13. zackees commented on Nov 2, 2026

    @zackees
    Member

    Additional trace for the remaining investigation: the first delayed frame (timestamp 0) is rendered at roughly 3.08 s; the following graphics pacing call has a 1.1 s system-time gap. The filter receives a selected timestamp near 4.1 s, and its existing is_timestamp_jump rule treats a forward gap over one second as a new timeline, flushing/refilling the delay queue. The next delayed picture does not render until about 7.2 s. This can change the video-derived audio anchor again.

    #3515 intentionally preserves that forward-jump/rewind reset behavior and tests it. Relaxing the jump rule merely because a delay is long would need to distinguish graphics-dropped input timestamps from an actual media seek; otherwise it risks replaying pre-seek pictures. That is a focused next investigation, separate from the proven queue-selection cases.

  14. moved this from Ready to In progress in obs-rust Multiviewon Nov 3, 2026
  15. moved this from In progress to Ready in obs-rust Multiviewon Nov 4, 2026
  16. zackees commented on Nov 5, 2026

    @zackees
    Member

    Continuing #3368 from the earlier #3515 investigation. I will reproduce the remaining dropout on current master, trace the video-derived audio anchor across a delayed startup and graphics stall, and add a deterministic RED regression before changing the timing logic. The existing audio test and sanitizer exemption stay unchanged until the real dropout is resolved.

  17. zackees commented on Nov 5, 2026

    @zackees
    Member

    Claiming: continuing my earlier #3368 investigation. Current master reproduces two tone breaks under four-CPU, three-process load with slow ASan unwinding and cold Mesa. The trace identifies a 30-frame queue overflow resetting last_frame_ts to zero during first-texture shader compilation; the next frame seeds a clock 166.7 ms behind. RED commit 4d7a88c exercises the actual libobs overflow and fails (clock becomes zero); the explicit-stop reset guard passes. One draft PR follows now, with the existing test and exemption unchanged until runtime GREEN is established.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3qualityreadysize:M

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions