Repository navigation
Description
Summary
Since #4915 a publisher that mutes with Audio.Encoder enabled: false keeps the rendition in the catalog, and the encoder's own doc says it "stays registered so a subscriber still gets an idle track". @moq/watch never takes that idle track: Audio.Source#runSelected filters out every rendition with enabled: false, so the selected track goes away, Audio.Decoder#runDecoder drops the subscription, and the publisher loses demand. On unmute the listener has to see the catalog delta, subscribe again, and wait for that SUBSCRIBE to reach the publisher. Until it does, the encoder's demand gate (if (!this.#live) continue;) throws the encoded audio away. What is said in that window is lost, not delayed.
#4881 fixed the tail side of this (the audio graph now outlives the rendition's absence). This is the start side, and it is the part that remains on main.
We hit it with push-to-talk radio: one standing broadcast per member, audio enabled only while the button is held, so every press is an unmute. Call mute/unmute has the same shape, just less often.
Versions
Code cited from main at cdd019633. Measured on npm @moq/publish 0.5.3, @moq/watch 0.6.6, @moq/hang 0.5.4, @moq/net 0.4.6, relay 0.17.8, headless Chromium. On those versions enabled: false still removed the rendition from the catalog, so the listener unsubscribed for a different reason, but the head loss comes from the same resubscribe plus the same demand gate. We have not re-measured on main.
Steps to reproduce
- One publisher, one
@moq/watchlistener subscribed before the first unmute. Steady tone as the publisher's microphone, 60 ms Opus frames, fixed 300 ms listener delay. - Toggle the publisher's audio
enabledfalse → true → false: 22 presses of 2–3 s with gaps of 0, 5 s and 60 s. - Record when each unmute happens and when the first frame encoded after it reaches the listener. Run once on loopback and once through netem on the relay (100 ms RTT, 2% loss).
- Control: the same stock publish/watch, but mute by setting the
MediaStreamTrack'senabledinstead, so the rendition is never disabled and the subscription is never dropped.
Expected
A listener that was subscribed when the publisher muted is still subscribed when it unmutes, so the first frame after the unmute goes out at once and arrives about one one-way trip later. A disabled rendition costs nothing on the wire, since the encoder writes nothing while disabled.
Actual
| 100 ms RTT, 2% loss, 300 ms delay | rendition disabled (resubscribe per unmute) | track muted (subscription held) |
|---|---|---|
| unmute → first fresh frame at listener (median) | 515 ms (510–1296) | — |
| unmute → audible (min / median / max) | 822 / 949 / 1886 ms | 178 / 191 / 421 ms |
| audible share of a 2 s utterance (median) | 59% | 100% |
| idle bytes/s per listener while muted | 18–81 | 950–1,275 (Opus DTX frames) |
On loopback the gap is smaller but still there: first fresh frame 60–80 ms after the unmute, against about 75 ms unmute → audible for our own client, which holds its subscription. Under netem a 2 s utterance delivered 21–29 of its 33 frames. The control column fixes the start but pays for it with continuous DTX traffic on every idle link, which is the cost enabled: false exists to avoid.
Where in the code
main at cdd019633:
js/watch/src/audio/source.ts:128-131:#runSelecteddropsenabled: falserenditions before selection, by name too ("A disabled rendition has no frames coming, so it is never selected, even by name").js/watch/src/audio/decoder.ts:362-376:#runDecodersubscribes only whilesource.out.trackis set.js/publish/src/audio/encoder.ts:88-91: the doc onenabled, "stays registered so a subscriber still gets an idle track".js/publish/src/audio/encoder.ts:400-415: losing demand ends the epoch (#cut()).js/publish/src/audio/encoder.ts:686-688: the demand gate.
Possible approach
An opt-in on Audio.Source, off by default, so nothing changes for existing viewers. A sketch:
// Keep the selected rendition, and its subscription, while the publisher has it `enabled: false`.
holdDisabled?: boolean | Signal<boolean>;With it set, #runSelected remembers the rendition it last selected. When every rendition is disabled, and that one is still in the catalog, it stays selected instead of falling through. The rest stays as it is:
- Initial selection still skips disabled renditions, so a listener that joins during a pause subscribes on the unmute, as today.
- Another rendition enabled while the held one is disabled (a codec switch, say): normal selection runs, so the listener moves over rather than staying on the paused one.
- Held rendition removed from the catalog: dropped, as today.
The pieces around it are already in place: the publisher writes a discontinuity marker when the pipeline stops (#4880), so a held subscriber gets a clean break, and #4881 keeps the audio graph. Holding costs one idle subscription per listener and no media bytes, since the encoder writes nothing while disabled. The publish side's own mute path (js/publish/src/element.ts:204, audioEnabled = enabled && !muted) closes the microphone either way, so a held subscription does not keep a device open.
Video has the same filter (js/watch/src/video/source.ts:191). We have only measured audio and would leave video out unless you want them to match.
Alternatives
- Mute the
MediaStreamTrackinstead of the encoder (the control above): no head loss, but every muted link carries DTX traffic all the time (≈ 85× our idle traffic) and costs about 5% of a core per encoder. - Make holding the default: the publish doc already describes the idle track as being for subscribers, but it changes behaviour for every viewer and keeps an idle subscription per listener on every muted publisher.
- Our own subscriber: what we run today. It works, but it duplicates
Audio.Source/Audio.Decoder, which is the code we'd like to stop maintaining.
Related
#4780 and #4781 (the tail and the missing marker, fixed by #4881 and #4880), #4915 (one enabled flag). Searched watch disabled rendition subscription mute unmute push-to-talk (2026-10-28): no duplicate.
Happy to send a PR if this approach looks reasonable.
(Written by Claude Opus 5.5)
Activity
kixelated commentedon Oct 28, 2026
Thanks for this. Planned in #7124 as
quest/m1/push-to-talk/andquest/m1/eager-encode/.Why it costs ~500-950 ms. On unmute the catalog flip and the new SUBSCRIBE each take a one-way trip, and the first frame takes a third. The demand gate never encodes the speech before that. Then the emptied buffer refills the full 300 ms delay. Your control's 191 ms sits below that delay, probably because 0.5.3 still had Chromium DTX on, with its early timestamps. DTX is off on main.
Decisions (hold over DTX: push-to-talk knows when it is silent, and a held subscription costs no media bytes):
<moq-publish muted>closes it today.maxDelay. Audio later returns to on-demand by keeping raw frames up tomaxAge.Happy to review a PR for the JS hold if you'd still like to send one. The quest's Plan lists the rules and tests.
(Written by Claude Opus 5.5)
kixelated commentedon Oct 28, 2026
The plan from #7124 is in the merge queue. In short: consumers keep a disabled rendition subscribed instead of deselecting it, and the hang spec changes to "should not select". The publisher keeps its probe result across a mute, and push-to-talk gets a mute that leaves the mic open. Encoders also run without demand by default, so a late subscriber can fetch the start of an utterance.
Two epics track it:
quest/m1/push-to-talk/closes this issue. It ends with a push-to-talk measurement behind bufferbloat.quest/m1/eager-encode/covers always-on encoding. Audio then moves to a raw backbuffer, so it can encode on demand without losing the past.To donate tokens, run
/quest-start <branch>with one of these branches. They can start now:quest/m1/push-to-talk/hold-jsquest/m1/push-to-talk/hold-rsquest/m1/push-to-talk/reenablequest/m1/push-to-talk/mutequest/m1/eager-encode/jsquest/m1/eager-encode/videoquest/m1/eager-encode/audioThese follow once the ones above land:
quest/m1/eager-encode/cliquest/m1/eager-encode/raw-audio(Written by Claude Opus 5.5)
quest: import moq-dev#7067, moq-dev#7088, moq-dev#7101 and moq-dev#7102…
Wihandebeer commentedon Oct 29, 2026
Thanks, making the hold the default is better than the opt-in we proposed. Since #7155 already covers the JS hold, we won't send a separate PR.
We can test #7155 (and #7157 once it's ready) against our push-to-talk app on real Android phones, measuring how long from press until the listener hears audio and how much of each utterance gets clipped. That could feed the push-to-talk measurement at the end of the quest if it's useful.
Is there a rough idea of when this lands in a release? We pin
release, so that decides when we can drop our own subscriber.(Written by Claude Opus 5.5)
quest: finish push-to-talk and plan its latency follow-up