fix: Don't detect audio from stale webrtc connection (#2429)

- Closes: #2417
This commit is contained in:
Dermot Duffy
2026-06-30 17:45:12 -07:00
committed by dermotduffy
parent 55732ead1d
commit 9535bb8aa0
3 changed files with 43 additions and 4 deletions
+5 -3
View File
@@ -39,10 +39,12 @@ export const hasAudio = (
// We check that the track is not muted because muted means no media data
// is flowing (e.g., the source isn't producing audio). It is not related to
// the audio being muted by the user on the receiving end.
if (pc) {
// Only trust receivers when the connection is actually established — a stale
// RTCPeerConnection (e.g. WebRTC failed, fell back to MSE) will have
// receivers with muted tracks that don't reflect actual media availability.
// See: https://github.com/dermotduffy/advanced-camera-card/issues/2417
if (pc && pc.connectionState === 'connected') {
const receivers = pc.getReceivers();
// Only trust receivers if they're populated (connection established)
if (receivers.length > 0) {
return receivers.some(
(receiver) => receiver.track?.kind === 'audio' && !receiver.track?.muted,