From c8787015f1e0c66d2f0d731d33a357a747088e3a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 2 Oct 2026 07:35:10 -0700 Subject: [PATCH 1/2] quest: claim publish audio clock test Co-Authored-By: GPT-6 From 71d3f4e5c75dc7904d9d5a4fa87c565c29a99f20 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 2 Oct 2026 07:42:11 -0700 Subject: [PATCH 2/2] test(publish): mock the audio delay clock Co-Authored-By: GPT-6 --- js/publish/src/audio/encoder.test.ts | 37 ++++++++++++------- quest/m1/test-flakes-2/README.md | 1 - quest/m1/test-flakes-2/publish-audio-clock.md | 11 ------ 3 files changed, 23 insertions(+), 26 deletions(-) delete mode 100644 quest/m1/test-flakes-2/publish-audio-clock.md diff --git a/js/publish/src/audio/encoder.test.ts b/js/publish/src/audio/encoder.test.ts index bf4a47b968..1abb22aa67 100644 --- a/js/publish/src/audio/encoder.test.ts +++ b/js/publish/src/audio/encoder.test.ts @@ -305,24 +305,33 @@ test("a push completing several frames keeps the encoder running", async () => { // it, which the catalog advertises as `delay`. test("a rendition trailing the broadcast's earliest advertises delay", async () => { using _webcodecs = installFakeWebCodecs(); - const baseline = new Baseline(); - using env = await setup(baseline); - const { encoder, feed } = env; + const clock = spyOn(performance, "now").mockReturnValue(200); - expect(encoder.out.catalog.peek()?.delay).toBeUndefined(); + try { + const baseline = new Baseline(); + using env = await setup(baseline); + const { encoder, feed } = env; - // A sibling that flushes each frame the instant it is captured. - baseline.observe(0, performance.now() * 1000); + expect(encoder.out.catalog.peek()?.delay).toBeUndefined(); - // Captured 100ms ago, so this rendition flushes at least that late. - const start = performance.now() * 1000 - 100_000; - for (let index = 0; index < 4; index++) { - await feed.push({ timestamp: Time.Micro(start + index * 20_000), channels: [new Float32Array(960)] }); - } - await feed.drain(); + // A sibling that flushes each frame the instant it is captured. + baseline.observe(0, performance.now() * 1000); + + // Captured 100ms ago, with a clock origin that keeps timestamps nonnegative. + const start = performance.now() * 1000 - 100_000; + for (let index = 0; index < 4; index++) { + await feed.push({ timestamp: Time.Micro(start + index * 20_000), channels: [new Float32Array(960)] }); + } + await feed.drain(); - expect(env.written.length).toBe(2); - expect(encoder.out.catalog.peek()?.delay).toBeGreaterThanOrEqual(100); + expect(env.written).toEqual([ + [100_000, 1], + [120_000, 1], + ]); + expect(encoder.out.catalog.peek()).toMatchObject({ delay: 100 }); + } finally { + clock.mockRestore(); + } }); // Regression: codec settings that can't resolve left the encoder unsettled, so `` never diff --git a/quest/m1/test-flakes-2/README.md b/quest/m1/test-flakes-2/README.md index 2d3287bbfb..67f3ff8b71 100644 --- a/quest/m1/test-flakes-2/README.md +++ b/quest/m1/test-flakes-2/README.md @@ -33,7 +33,6 @@ Public API: none. Wire: none. - [moq-cli tests on a paused clock](/quest/m1/test-flakes-2/cli-paused-clock.md) - the fetch timeout and completion tests stop racing wall-clock budgets - [Subscription cut by disconnect](/quest/m1/test-flakes-2/subscription-cut.md) - a publisher disconnect never ends a subscription clean - [Media late join](/quest/m1/test-flakes-2/media-late-join.md) - `just test media` late join stays within one GOP, or the regression is fixed -- [js/publish audio clock](/quest/m1/test-flakes-2/publish-audio-clock.md) - the audio encoder delay test runs on mock time - [WebSocket paused TLS dial](/quest/m1/test-flakes-2/websocket-paused-tls.md) - the fixed-address WebSocket tests stop pausing the clock over a real dial - [moq-mux live import clock](/quest/m1/test-flakes-2/mux-live-import-clock.md) - the live import restart tests advance a paused clock instead of sleeping - [Tracing capture audit](/quest/m1/test-flakes-2/trace-capture-audit.md) - no test misses tracing events because a parallel test silenced the call site diff --git a/quest/m1/test-flakes-2/publish-audio-clock.md b/quest/m1/test-flakes-2/publish-audio-clock.md deleted file mode 100644 index ccc4becaad..0000000000 --- a/quest/m1/test-flakes-2/publish-audio-clock.md +++ /dev/null @@ -1,11 +0,0 @@ -# [XS] js/publish audio delay test on mock time - -## Goal - -The js/publish audio encoder test "a rendition trailing the broadcast's -earliest advertises delay" passes when its file runs alone. - -## Plan - -It reads the real clock, so timestamps go negative early in the process and -it fails when run alone (#4414). Run it on mock time.