From 56afbe6eb15a3819460cf41c367567dd2bae9ab8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 20 Jul 2022 20:49:07 +0100 Subject: [PATCH] Fix crash on screen share Don't try to wire up audio nodes if the stream has no audio track, 'cos it'll crash. Fixes https://github.com/vector-im/element-call/issues/421 --- src/video-grid/useMediaStream.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/video-grid/useMediaStream.ts b/src/video-grid/useMediaStream.ts index 79e8292..5fbf57d 100644 --- a/src/video-grid/useMediaStream.ts +++ b/src/video-grid/useMediaStream.ts @@ -202,7 +202,12 @@ export const useSpatialMediaStream = ( const sourceRef = useRef(); useEffect(() => { - if (spatialAudio && tileRef.current && !mute) { + if ( + spatialAudio && + tileRef.current && + !mute && + stream.getAudioTracks().length > 0 + ) { if (!pannerNodeRef.current) { pannerNodeRef.current = new PannerNode(audioContext, { panningModel: "HRTF",