zebra-spaces: deploy publisher-side telemetry

This commit is contained in:
russell@unturf.com 2026-06-04 14:37:04 -04:00
parent 645db6aca7
commit 80a936fe7b
No known key found for this signature in database

View file

@ -3904,6 +3904,47 @@ 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). */
const pubPCs = [
['mic.send', sfuPubPC],
['cam.send', sfuCameraPC],
['scr.send', sfuScreenPC],
['game.send', sfuGamePC],
];
for (const [label, pc] of pubPCs){
if (!pc || typeof pc.getStats !== 'function') continue;
try {
const stats = await pc.getStats(null);
const nowMs = Date.now();
let out = null, remoteIn = null;
stats.forEach(r => {
if (r.type === 'outbound-rtp' && (r.kind === 'audio' || r.kind === 'video')){
if (!out || (r.packetsSent|0) > (out.packetsSent|0)) out = r;
}
if (r.type === 'remote-inbound-rtp') {
if (!remoteIn || (r.packetsLost|0) > (remoteIn.packetsLost|0)) remoteIn = 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));
}
parts.push(s);
} catch(_){}
}
/* every <audio> element in the room — both the WebRTC remoteAudio
* pool (rtc[]) and the DJ HTTP-pull streamAudio (stream[]). Capture
* wedged elements (rs>=2 HAVE_CURRENT_DATA but paused at ct=0) so
@ -5884,8 +5925,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">67528afd1d51390c2a2ab8da5fa00105</span><br>
sha256 <span class="stamp-sha">cf6c2988e44172286d60aeadde0f448f5b3b91fdf1270129cfa2ebae8213fe21</span><br>
md5 <span class="stamp-md5">d0fe5b9f0e4be6dedc517506de9ef174</span><br>
sha256 <span class="stamp-sha">95e89b4620eff5e68a55b443b467f640d3ddc01eb6e5921c9cfe4262cce72543</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>