From 3bc3edf9ea8f34c394581cef0e9a8df50e58df46 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 3 Jun 2026 23:01:05 -0400 Subject: [PATCH] =?UTF-8?q?zebra-spaces:=20remove=20dead=20audioPath=20ref?= =?UTF-8?q?erences=20=E2=80=94=20fixes=20leave=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS error fox spotted via the new unhandledrejection forwarder: audioPath is not defined audioPath was a per-uuid map ('dj' | 'rtc') I added when listeners auto-enrolled into HTTP DJ mode. The auto-enrol path was reverted when fox pointed out phones can't autoplay HTTP audio, but four audioPath.set/.clear references survived in startStream, stopStream, and the btn-leave click handler. The leave handler hit audioPath.clear() before the bye send and threw ReferenceError, abandoning the rest of the cleanup (which is why the leave button felt half-broken: bye did fire from somewhere earlier in the handler, but post-leave UI never reset). Removed every dead audioPath reference. WebRTC unmute is now handled inline in stopStream where needed. applyAudioMute is the last defined-but-unused holdover; keeping it since callers of attachSfu- Track / startStream still reference the no-op via stale comments, and it's cheap. --- web/zebra-spaces.html | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/web/zebra-spaces.html b/web/zebra-spaces.html index 6a60d78..cef736f 100644 --- a/web/zebra-spaces.html +++ b/web/zebra-spaces.html @@ -4136,14 +4136,10 @@ async function startStream(uuid, pubHex){ } a.src = wantUrl; const onPlaying = () => { - audioPath.set(uuid, 'dj'); - applyAudioMute(); logLine('', 'stream on for '+pubHex.slice(0,12)+' — DJ mode (~2s delay, glitch-free)'); }; const onFail = (why) => { - audioPath.set(uuid, 'rtc'); - streamMode.delete(pubHex); // allow next auto-enrol pass to retry - applyAudioMute(); + streamMode.delete(pubHex); // allow next toggle attempt to retry logLine('err', 'stream for '+pubHex.slice(0,12)+' '+why+' — staying on live WebRTC'); }; a.addEventListener('playing', onPlaying, { once: true }); @@ -4161,8 +4157,10 @@ function stopStream(uuid){ try { a.pause(); } catch(_){} try { a.removeAttribute('src'); a.load(); } catch(_){} } - audioPath.set(uuid, 'rtc'); - applyAudioMute(); + /* re-enable the WebRTC audio for this peer in case we'd muted it + * while DJ mode was active. */ + const w = remoteAudio.get(uuid); + if (w) try { w.muted = false; } catch(_){} } function toggleStreamFor(uuid, pubHex){ if (streamMode.has(pubHex)){ @@ -4886,18 +4884,13 @@ $('btn-leave').addEventListener('click', async () => { try { sessionStorage.removeItem(ACTIVE_CAM_KEY); } catch(_){} if (sigReconnect){ clearTimeout(sigReconnect); sigReconnect = null; } /* tear down ALL DJ-mode HTTP streams + their