Repository navigation
fix(media-use): wait-bgm looks for the track before it reports a timeout - #8856
miguel-heygen wants to merge 2 commits into
Conversation
terencecho
left a comment
There was a problem hiding this comment.
P2 · Keep a zero timeout to one check even if the system clock moves backward. At skills/media-use/audio/scripts/wait-bgm.mjs:183, a backward step makes waited negative, so --timeout-ms 0 can schedule a timer. With an absent track and a 1,000 ms simulated rollback, the base returned timeout without a timer and this head scheduled a 1,000 ms wait. Use a monotonic elapsed clock or retain the explicit zero-timeout exit after the first check. The final-wait test could also assert the timer delay. It still passes if the sleep is changed to the full polling interval.
Both named regressions fail on the base and pass here. All 59 targeted audio tests passed in three runs, and the skills manifest is in sync.
— tai (automated review)
|
Addressed at
Red checks for the three cases:
With the fix, |
terencecho
left a comment
There was a problem hiding this comment.
Verified that monotonic elapsed time keeps a zero timeout from scheduling a timer after a wall-clock rollback. The final-wait test also fails if the sleep cap is removed. Both original deadline tests fail on the base, and all 60 targeted audio tests passed on this head.
— tai (automated review)
What
wait-bgmnow always looks for the music track at least once, and looks once more after its last wait, before it reportstimeout. A finished track is reportedreadyhowever busy the machine is.Why
The wait loop checked the deadline before it looked:
With
--timeout-ms 0the loop body runs only if the clock has not moved sincestartedwas read. On a busy machine one millisecond passes between those two reads, the loop never runs, and the script reportstimeoutwithout having looked at the track. For a positive timeout the same shape skips the look after the last wait: a track that landed during that wait was reported as a timeout.The flake in
bgm.launch.test.mjs, "a musicgen job replaces the engine's earlier private track and keeps it private", is this case. In the failing CI run the track had been written with the right mode and bytes, the assertion just before passed, andbgm_status.jsonstill saidtimeout. Every test inwait-bgm.test.mjsandbgm.launch.test.mjsthat runswait-bgm --timeout-ms 0shares it.How
The loop looks first, then decides whether time is up, then waits only for the time left:
The
timeoutMs === 0special case goes away: it is the firstwaited >= timeoutMs.Test plan
fails without the fix: the two new cases in
skills/media-use/audio/scripts/wait-bgm.test.mjs. Both run the real script under a preloaded clock that moves on every read and by the full length of every wait, as time does on a loaded machine.a finished track is ready with --timeout-ms 0 even when the clock moves before the first looka track that lands during the last wait is readyOn main both report
timeoutwherereadyis due. With the fix both pass.Twenty runs of the flaky test under four CPU-bound processes passed on main too. The machine I used has enough cores that those processes caused no contention, so the moving clock, not load, is what makes the failure repeatable.
With the fix,
wait-bgm.test.mjs,bgm.launch.test.mjs,bgm.test.mjsandaudio.test.mjspass three runs in a row (59 tests).bun run test:skillspasses 933, skips 5 and has no failures once the parsers package is built.