Repository navigation
fix(studio): start the sources with the engine, so the cue test stops flaking - #225
Conversation
Quest-Claim: 8d6fbcbbe1175ac2
…first frame The engine synced its sources only on the program thread's first tick, so a caller of Engine::start could find none running when that thread was slow to be scheduled, as a_cue_waits_for_take did on a loaded runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. Moving the first source sync into Engine::start fixes the cause for every holder of a fresh engine, not just the test, and it keeps the existing order: recording line, then audio clock, then sources.
Reviewed changes: I reviewed the extraction of the stale-tick body into Engine::sync, its new call site in start, and the test that now asserts instead of polling.
Engine::sync: holds the program thread's former stale-tick body unchanged (sources.sync,recorder.set_sources, spawn drivers intorunning,pick_audio), with the same state → running lock order.Engine::start: syncs once before spawning the program thread, andstalenow startsfalse. If a laterclockedspawn fails,Starting::drop→stop()→state.sources.stop()still ends the newly spawned source threads. The first tick'ssyncedno longer beingtrueis harmless, sinceairisNoneat start and going live sets each line's audio throughstarted.a_lost_picture_is_reported_once: now asserts that theredsource runs as soon asstartreturns. This holds becauseSources::syncinserts the feeds synchronously.- Quest file:
quest/m0/cue-test-flake.mdis deleted on completion, as the repo convention expects.
ℹ️ One neighbouring comment still says the program clock starts the sources
rs/moq-studio/src/engine.rs:1316-1318 still says the recording line is "opened before the program clock starts the sources". start now does that itself. The order still holds, so only the wording is stale. The PR already rewrote the audio-clock comment a few lines below for the same reason.
claude-opus-5-5 | 𝕏

Finishes
quest/m0/cue-test-flake.md:engine::tests::a_cue_waits_for_takeno longer flakes on a loaded runner.Root cause
Engine::startreturned with no source running:State::stalestartedtrue, and only the program thread's first tick synced the sources. The test runs in about 150 ms, so when the host starves that thread for longer,controls::soundsfinds no runninghostfeed (so no strip) and the palette refusesMute("host")with "hosthas no sound". The same race reached any caller, such as the window's first frames or a phone remote.Changes
Engine::syncholds what the program thread did on a stale tick: sync the sources, spawn their drivers, update the recorder, pick the audio.Engine::startcalls it once the audio clock runs and before spawning the program thread, andstalestartsfalse. Ordering is unchanged otherwise: the recording line opens and the audio clock starts before the sources do, as before.a_lost_picture_is_reported_onceno longer polls for its source to start; it asserts it runs asstartreturns.Decisions
Validation
left: Some("\host` has no sound")). With the fix and the same sleep, it anda_lost_picture_is_reported_once` both pass.nprocbusy loops and--stress-count 30on lavapipe. Before the fix, 18 passed and 12 failed with the CI message. After the fix, 30 of 30 passed.just render-sw's engine/watch/setup filter: 22 of 22 passed.just cipassed.Public API
None:
Engine::syncis private. No wire impact.Caused by
Mute("host")assertion, which assumed the sources were already running before the program thread's first sync (found by check)Follow-ups
None.
Models
Size: S
Implementer: Claude, claude-opus-5-5, unknown effort (arm A)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: 5b1a73c
Base: origin/main at 9291483
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1fd96-ab6d-7d13-bbc4-edd5ce9d79ff, round 1Score: 9/10,
Source initialization completes before Engine::start returns, removing the scheduling race while preserving subsequent synchronization; no actionable defects were found, though builds and tests were not run.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none
Reviewer: Codex, gpt-6.1-sol, low effort, shadow
Session:
01a1fd96-ab6c-7961-a7ca-bcd4d3f41416, round 1Score: 9/10,
The focused source-initialization fix addresses the startup race while preserving frame-driven synchronization, with no actionable defect identified by source inspection; builds and tests were not run.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none