From ab6d10331fa1cf4639e2dc42818adebfca3bfb4a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 14 Nov 2026 09:24:21 -0800 Subject: [PATCH 1/2] fix(net): an END_OF_TRACK landing after a viewer's release keeps the session Co-Authored-By: Claude Opus 5.5 --- js/net/src/ietf/subscriber.test.ts | 35 ++++++++++++++++++++++-- js/net/src/track.ts | 6 ++-- quest/m0/nightly/README.md | 4 +++ quest/m0/nightly/firefox-resume-audio.md | 34 +++++++++++++++++++++++ 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 quest/m0/nightly/firefox-resume-audio.md diff --git a/js/net/src/ietf/subscriber.test.ts b/js/net/src/ietf/subscriber.test.ts index 4dcd964d106..3f3dce0be36 100644 --- a/js/net/src/ietf/subscriber.test.ts +++ b/js/net/src/ietf/subscriber.test.ts @@ -729,7 +729,7 @@ async function subscribeTrack({ version?: IetfVersion; properties?: Properties; subscription?: track.Subscription; -} = {}): Promise<{ subscriber: Subscriber; track: track.Subscriber }> { +} = {}): Promise<{ subscriber: Subscriber; track: track.Subscriber; transport: WebTransport }> { const pair = createMockTransportPair(ALPN.DRAFT_18); const session = new NativeSession(pair.server, version, true); const subscriber = new Subscriber({ session }); @@ -748,7 +748,7 @@ async function subscribeTrack({ await peer.writer.u53(SubscribeOk.id); await new SubscribeOk({ trackAlias: ALIAS, properties }).encode(peer.writer, version); - return { subscriber, track: consumer }; + return { subscriber, track: consumer, transport: pair.server }; } // A refusal already ended the request: a reset back would tell the publisher we failed. The @@ -1387,6 +1387,37 @@ test.each([ stop.mockRestore(); }); +/** + * A viewer can release a track while the publisher's END_OF_TRACK is already in flight: the + * stream waits for its FIN after the marker, and the release lands first. The marker then has + * nothing left to end, which is no violation of the peer's, so the session stays open. + */ +test("an END_OF_TRACK that lands after the track's release keeps the session", async () => { + const { subscriber, track, transport } = await subscribeTrack(); + + // Object 0, then END_OF_TRACK at object 1, with the stream's FIN still to come. + const readable = new ReadableStream({ + start(controller) { + controller.enqueue(new Uint8Array([...encodeObjects([0]), 0, 0, 0x4])); + }, + }); + const header = new GroupMessage({ + trackAlias: ALIAS, + groupId: 3n, + subGroupId: 0n, + publisherPriority: 0, + flags: groupFlags(true), + }); + const handled = subscriber.handleGroup(header, new Reader(readable, undefined, VERSION)); + await yieldNow(); + + track.close(); + await handled; + + using clock = manual(); + expect(await settlesWithin(transport.closed, clock)).toBe(false); +}); + /** * A clear FIRST_OBJECT whose first ID is not 0 still has a hole at the front, so the * stream is dropped and the track resumes at the next group. diff --git a/js/net/src/track.ts b/js/net/src/track.ts index 83e7e9071db..52f44a684ee 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -2277,13 +2277,15 @@ export class Producer { // The wire's end: repeating it is a no-op, and a mid-group end may refine the group // boundary it falls just before. Either must carry the same error code. Mirrors the Rust // `finish_at` on a `received()` copy. Only a wire subscription owes a tail below the end: a - // FETCH's end leaves nothing in flight, as the Rust `set_end` a fill declares. + // FETCH's end leaves nothing in flight, as the Rust `set_end` a fill declares. An end that + // lands after the track closed, such as a viewer releasing it while the marker was in + // flight, has nothing left to end. #endPending(end: Position, error?: Error): void { const declared = this.#state.end.peek(); const code = (err?: Error) => (err === undefined ? undefined : toStreamCode(err)); const tail = this.#wire !== undefined; if (declared === undefined) { - if (this.#state.closed.peek() !== undefined) throw new Error("track is closed"); + if (this.#state.closed.peek() !== undefined) return; this.#declareEnd(end, error, tail); } else if (code(declared.error) !== code(error)) { throw new ProtocolViolation(`conflicting track end error: ${error}`); diff --git a/quest/m0/nightly/README.md b/quest/m0/nightly/README.md index 95fe8762473..3dcfee3b74b 100644 --- a/quest/m0/nightly/README.md +++ b/quest/m0/nightly/README.md @@ -57,4 +57,8 @@ report's output ([moq-dev/moq#8654](https://github.com/moq-dev/moq/pull/8654)), the firefox resume ([moq-dev/moq#8635](https://github.com/moq-dev/moq/pull/8635)), and the chromium `av_lag` rows ([output latency](/quest/m2/audio-playout/output-latency.md)). +After #8635 landed, run +[43601796176](https://github.com/moq-dev/moq/actions/runs/43601796176) still +failed the firefox resume, now on audio arriving late rather than trailing: +[Firefox resume audio](/quest/m0/nightly/firefox-resume-audio.md) owns it. diff --git a/quest/m0/nightly/firefox-resume-audio.md b/quest/m0/nightly/firefox-resume-audio.md new file mode 100644 index 00000000000..fc81f3f4068 --- /dev/null +++ b/quest/m0/nightly/firefox-resume-audio.md @@ -0,0 +1,34 @@ +# [M] Firefox audio resumes with the picture + +## Goal + +Nightly's `Media (firefox player)` job passes its `after resume` window: after +a pause, audio is audible within the window's first samples, as in Chromium, +instead of staying silent for about half a second after the picture resumes. + +## Plan + +[moq-dev/moq#8635](https://github.com/moq-dev/moq/pull/8635) removed the +1.7 s trail behind the picture, but Nightly +[43601796176](https://github.com/moq-dev/moq/actions/runs/43601796176) (at +4fec611d4, after it and the [lag rule](https://github.com/moq-dev/moq/pull/8722)) +still failed with `68/79 samples carried the fixture tone` (11-13: 60/78). The +window's first 11 samples are silent with the audio byte counter flat +(`audio=94041B`) while video presents live frames; then about 1.8 KB of +audio lands in one burst, `[player] skipping missing groups: track=audio +1165 -> 1258` fires, and audio plays in sync. So the audio subscription's +first groups reach the Firefox player about 0.4 s after video's. + +Not reproduced locally: `just test media --media-engines firefox +--media-cases rename,pause` passed 4 of 4 on an idle host (2026-11-14). The +CI host was 14 to 60% idle during the window, and Firefox dials the relay +over WebSocket, so the difference is likely in that path under load. + +Recommended: reproduce under load first (the job's own +`busiest host processes` table shows the shape), with the relay's and +player's logs kept (`HARNESS_KEEP=1`), and find which hop holds audio's +first groups after the resubscribe: the relay's upstream re-subscribe and +gap backfill (the fixture logs a fetch of audio group 1156 that the relay +aborts), the WebSocket session's stream scheduling, or the consumer's hole +wait from its pre-pause cursor (1165). Fix that hop; do not widen the test's +window or agreement. From 0cf6e2e09da31efb508d70c657e541a54454cc6a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 14 Nov 2026 09:24:53 -0800 Subject: [PATCH 2/2] quest: interop-green waits on the END_OF_TRACK race fix Co-Authored-By: Claude Opus 5.5 --- quest/m0/interop-green/README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/quest/m0/interop-green/README.md b/quest/m0/interop-green/README.md index 26b163b9ade..75b47dbffbf 100644 --- a/quest/m0/interop-green/README.md +++ b/quest/m0/interop-green/README.md @@ -11,9 +11,10 @@ so it only needs to stay green. ## Waiting - moq-dev/moq: the next scheduled Interop run on `main` passes, once the - [resumed-audio fix](https://github.com/moq-dev/moq/pull/8635) lands - ([moq-dev/moq#8572](https://github.com/moq-dev/moq/pull/8572), the max-age - fix, merged 2026-11-12). Check + [END_OF_TRACK race fix](https://github.com/moq-dev/moq/pull/8754) lands + (the [resumed-audio fix](https://github.com/moq-dev/moq/pull/8635) merged + 2026-11-14, and [moq-dev/moq#8572](https://github.com/moq-dev/moq/pull/8572), + the max-age fix, 2026-11-12). Check with `gh run list --repo moq-dev/moq --workflow interop.yml --event schedule`, then the run's STEPS summary. The JS route port that [moq-dev/moq#8290](https://github.com/moq-dev/moq/pull/8290) waited on landed in [moq-dev/moq#8443](https://github.com/moq-dev/moq/pull/8443), @@ -190,5 +191,15 @@ Scheduled run The 11-11 run, before #8507, passed all three steps. +Scheduled run +[43606836954](https://github.com/moq-dev/moq/actions/runs/43606836954) +(2026-11-14, at bd617cc1e, after #8635) passed the pause case and failed only +Media output and lifecycle, on chromium's `replacement` case: the +`moq-transport-22` incumbent fallback stalled audio. The pause case had masked +it since 11-12. The JS subscriber closed its session when an END_OF_TRACK +crossed the viewer's release of the track; +[moq-dev/moq#8754](https://github.com/moq-dev/moq/pull/8754) ignores that late +end. + Public API: none. Wire: none.