zebra-spaces: deploy SFU worklet detach on mesh ontrack

This commit is contained in:
russell@unturf.com 2026-06-04 17:51:56 -04:00
parent a9433589a0
commit eaf5e37650
No known key found for this signature in database

View file

@ -5077,6 +5077,15 @@ async function connectToPeer(uuid, weOffer){
for (const tr of micStream.getTracks()){ tagTrack(tr); pc.addTrack(tr, micStream); } for (const tr of micStream.getTracks()){ tagTrack(tr); pc.addTrack(tr, micStream); }
setSenderBitrate(pc.getSenders().find(s=>s.track && s.track.kind==='audio')); setSenderBitrate(pc.getSenders().find(s=>s.track && s.track.kind==='audio'));
pc.ontrack = (ev) => { pc.ontrack = (ev) => {
/* Tear down the SFU worklet path for this uuid before mesh's
* <audio> takes over. Without this we hear the same voice
* through TWO paths simultaneously: SFU mic → AudioContext
* worklet (~0.5s delay), and mesh mic → <audio> (~50ms).
* Pre-refactor, both paths used <audio> in the remoteAudio map
* so the second overwrote the first. After role-aware routing,
* SFU lives in listenerAudioNodes and mesh in remoteAudio —
* different maps, both play, echo. Fox 2026-06-04. */
detachListenerStream(uuid);
let a = remoteAudio.get(uuid); let a = remoteAudio.get(uuid);
if (!a){ if (!a){
a = document.createElement('audio'); a.autoplay = true; a = document.createElement('audio'); a.autoplay = true;
@ -5091,6 +5100,7 @@ async function connectToPeer(uuid, weOffer){
try { ev.receiver.playoutDelayHint = SPEAKER_PLAYOUT_DELAY_SEC; } catch(_){} try { ev.receiver.playoutDelayHint = SPEAKER_PLAYOUT_DELAY_SEC; } catch(_){}
try { ev.receiver.jitterBufferTarget = SPEAKER_PLAYOUT_DELAY_SEC * 1000; } catch(_){} try { ev.receiver.jitterBufferTarget = SPEAKER_PLAYOUT_DELAY_SEC * 1000; } catch(_){}
stopMeter(uuid); startMeter(uuid, a.srcObject); stopMeter(uuid); startMeter(uuid, a.srcObject);
logLine('', 'mesh audio attached for '+uuid.slice(0,4)+' — SFU worklet path detached');
}; };
pc.onicecandidate = (ev) => { /* using waitForIceGathering pattern, candidates ignored */ }; pc.onicecandidate = (ev) => { /* using waitForIceGathering pattern, candidates ignored */ };
pc.onconnectionstatechange = () => { pc.onconnectionstatechange = () => {
@ -6371,8 +6381,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"> <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> <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">544ed25e7616ced6a24bbc8c29bf13ae</span><br> md5 <span class="stamp-md5">ffdaafffe887e5213d2152178708bb3b</span><br>
sha256 <span class="stamp-sha">1bb6283957a5a00cc6e9e52c427d85791345bd6383d95f24bca1016497205f81</span><br> sha256 <span class="stamp-sha">e1f9d34469407f49bc8129eef43cf990c611bd77cd6f8725bd2be8416e5eb644</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">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> <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> </footer>