zebra-spaces: tear down stale <audio> fallback when worklet path takes over

This commit is contained in:
russell@unturf.com 2026-06-05 19:52:43 -04:00
parent 43780b2d6f
commit 32497859b0
No known key found for this signature in database

View file

@ -3392,6 +3392,20 @@ function attachSfuTrack(uuid, stream){
* AudioContext where <audio>.play() doesn't. */
if (myRole === 'listener'){
if (attachListenerStreamViaAudioContext(uuid, stream)){
/* If a stale-stream attempt earlier in this lifecycle left an
* <audio> fallback element in remoteAudio[uuid], the SFU's still-
* alive transceiver continues feeding RTP into it. Now that the
* worklet path is the live audio source, tear the <audio> element
* down so we don't play the same publisher twice — once via
* <audio> (~0.5s native jbuf = "early") and once via worklet (4s
* = "on time"). Fox 2026-06-05: "fxhp-android-firefox is also
* hearing two, one perfectly synced, other is not." */
const stale = remoteAudio.get(uuid);
if (stale){
try { stale.srcObject = null; stale.pause(); stale.remove(); } catch(_){}
remoteAudio.delete(uuid);
logLine('', 'detached stale <audio> fallback for '+uuid.slice(0,4));
}
stopMeter(uuid); startMeter(uuid, stream);
logLine('', 'sfu: receiving '+((members.get(uuid)||{}).handle || uuid)+' (audioctx 4s)');
return;
@ -3401,6 +3415,12 @@ function attachSfuTrack(uuid, stream){
} else {
/* speaker / cohost / host: smaller buffer, same path. */
if (attachAudioStreamViaWorklet(uuid, stream, SPEAKER_PLAYOUT_DELAY_SEC)){
const stale = remoteAudio.get(uuid);
if (stale){
try { stale.srcObject = null; stale.pause(); stale.remove(); } catch(_){}
remoteAudio.delete(uuid);
logLine('', 'detached stale <audio> fallback for '+uuid.slice(0,4));
}
stopMeter(uuid); startMeter(uuid, stream);
logLine('', 'sfu: receiving '+((members.get(uuid)||{}).handle || uuid)+' (audioctx '+SPEAKER_PLAYOUT_DELAY_SEC+'s)');
return;
@ -7839,8 +7859,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-05</span><br>
md5 <span class="stamp-md5">bebca66d15d021b0f695814f8b0330f3</span><br>
sha256 <span class="stamp-sha">1489ff6f3224001b234fdffec8c616127b3ccf4812e410e188e892ce2dec1875</span><br>
md5 <span class="stamp-md5">14097cba6e18c225634093484e581807</span><br>
sha256 <span class="stamp-sha">a48c12affaea0497df78d186a44649081c342148ad993bd529ab216c55de8a88</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>