zebra-spaces: split outbound-rtp telemetry per kind (.aud + .vid)

Previous loop picked the max-packets outbound-rtp per PC, which always
collapsed onto the video track on screen/camera PCs — hiding what
screen-audio was doing during the wiggle test entirely.

Now iterates ALL outbound-rtp entries on every publisher PC and emits
one line per kind: scr.send.aud, scr.send.vid, cam.send.aud (when the
camera mic is published), cam.send.vid, mic.send.aud, game.send.*.
remote-inbound-rtp is paired back by ssrc.

Lets us answer the key diagnostic question: when Firefox's
getDisplayMedia video capture stalls under X11 wiggle, does the audio
track from the same MediaStream stall in lockstep (Firefox couples
audio + video producers internally) or stay flowing (decoupled)? If
decoupled, an app-layer fix (route audio + video to separate
RTCPeerConnections) would work. If coupled, the fix has to be either
OS-level (PulseAudio loopback to mic) or upstream in Firefox.
This commit is contained in:
Russell Ballestrini 2026-06-04 14:53:39 -04:00
parent 763ba181be
commit e3f91b1e55
No known key found for this signature in database

View file

@ -3921,10 +3921,13 @@ async function dumpTelemetry(){
} catch(e){ parts.push('stats.err=' + e.message); }
}
/* publisher-side stats — what we are actually emitting on the wire.
* Catches publisher stalls (X11 compositor blocking the audio thread
* during a window wiggle is a real one). gap = now - lastPacketSent
* — a gap > frame-interval is a wire stall. rtt is the most recent
* round-trip from remote-inbound-rtp (the SFU's view of our sender). */
* One line per kind so screen-audio shows up independently of
* screen-video (earlier collapse hid scr.send.aud entirely under
* scr.send.vid). Critical for diagnosing whether Firefox
* getDisplayMedia couples its audio + video source producers under
* X11 contention. gap = now - lastPacketSent — a gap > frame-
* interval is a wire stall. rtt is the most recent round-trip from
* remote-inbound-rtp (the SFU's view of our sender). */
const pubPCs = [
['mic.send', sfuPubPC],
['cam.send', sfuCameraPC],
@ -3936,29 +3939,35 @@ async function dumpTelemetry(){
try {
const stats = await pc.getStats(null);
const nowMs = Date.now();
let out = null, remoteIn = null;
/* keyed by ssrc so audio + video each get a slot; remote-inbound
* pairs back via .ssrc on remote-inbound-rtp → ssrc on outbound. */
const outsBySSRC = new Map();
const remoteInsBySSRC = new Map();
stats.forEach(r => {
if (r.type === 'outbound-rtp' && (r.kind === 'audio' || r.kind === 'video')){
if (!out || (r.packetsSent|0) > (out.packetsSent|0)) out = r;
outsBySSRC.set(r.ssrc, r);
}
if (r.type === 'remote-inbound-rtp') {
if (!remoteIn || (r.packetsLost|0) > (remoteIn.packetsLost|0)) remoteIn = r;
if (r.type === 'remote-inbound-rtp' && typeof r.ssrc !== 'undefined') {
remoteInsBySSRC.set(r.ssrc, r);
}
});
if (!out) continue;
const gap = out.lastPacketSentTimestamp
? ((nowMs - out.lastPacketSentTimestamp) / 1000).toFixed(1) + 's'
: '?';
let s = label + ' pkt=' + (out.packetsSent|0) +
' bytes=' + (out.bytesSent|0) +
' gap=' + gap;
if (out.kind === 'video') s += ' frames=' + (out.framesEncoded|0);
if (remoteIn) {
s += ' rtt=' + ((remoteIn.roundTripTime||0).toFixed(3)) +
' rlost=' + (remoteIn.packetsLost|0) +
' rjit=' + ((remoteIn.jitter||0).toFixed(4));
for (const out of outsBySSRC.values()){
const gap = out.lastPacketSentTimestamp
? ((nowMs - out.lastPacketSentTimestamp) / 1000).toFixed(1) + 's'
: '?';
const kindLabel = out.kind === 'audio' ? '.aud' : '.vid';
let s = label + kindLabel + ' pkt=' + (out.packetsSent|0) +
' bytes=' + (out.bytesSent|0) +
' gap=' + gap;
if (out.kind === 'video') s += ' frames=' + (out.framesEncoded|0);
const remoteIn = remoteInsBySSRC.get(out.ssrc);
if (remoteIn) {
s += ' rtt=' + ((remoteIn.roundTripTime||0).toFixed(3)) +
' rlost=' + (remoteIn.packetsLost|0) +
' rjit=' + ((remoteIn.jitter||0).toFixed(4));
}
parts.push(s);
}
parts.push(s);
} catch(_){}
}
/* every <audio> element in the room — both the WebRTC remoteAudio
@ -5941,8 +5950,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');
<footer style="margin:2.2rem auto 0;font-size:0.65rem;color:#999;line-height:1.7;word-break:break-all;font-family:monospace">
<span id="pi-seal" style="color:#777;cursor:default;user-select:none" title="">page integrity</span> &nbsp;·&nbsp; built <span class="stamp-date">2026-06-04</span><br>
md5 <span class="stamp-md5">a120f5b4723d88b8f6d4518fa647e390</span><br>
sha256 <span class="stamp-sha">82d23c2333f6d6ab0f3c2149725d274a44807ec0a878ebf1ddb59cf07c095197</span><br>
md5 <span class="stamp-md5">e3c7120739d2e4ef52d4f95860be5eaf</span><br>
sha256 <span class="stamp-sha">b4416e44b5dca523fe5c9f32160d8f4d219c585b02d90e84e8d8129646ae27c6</span><br>
<span style="color:#bbb">hashes are of this page with these two fields zeroed — to verify, blank them and re-hash</span><br>
<span style="color:#bbb">one self-contained file — <strong>save a copy</strong> and verify against these hashes; point at your own servers with ?signal= and ?turncred=, or <a href="host-your-own.html" style="color:#999">host your own community</a></span>
</footer>