From 51ac3ef64a90aac3c36d103e590b4b38d4768f74 Mon Sep 17 00:00:00 2001 From: Armel Chesnais Date: Tue, 25 Oct 2022 15:55:47 -0400 Subject: [PATCH] fix(noise-suppression) exit out early if no input data to Worklet Disconnecting the input node to the worklet causes the worklet to crash. Adding a guard clause for empty input prevents this. --- .../noise-suppression/NoiseSuppressorWorklet.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/react/features/stream-effects/noise-suppression/NoiseSuppressorWorklet.ts b/react/features/stream-effects/noise-suppression/NoiseSuppressorWorklet.ts index 2236aa461..89e7555dd 100644 --- a/react/features/stream-effects/noise-suppression/NoiseSuppressorWorklet.ts +++ b/react/features/stream-effects/noise-suppression/NoiseSuppressorWorklet.ts @@ -106,6 +106,12 @@ class NoiseSuppressorWorklet extends AudioWorkletProcessor { const inData = inputs[0][0]; const outData = outputs[0][0]; + // Exit out early if there is no input data (input node not connected/disconnected) + // as rest of worklet will crash otherwise + if (!inData) { + return true; + } + // Append new raw PCM sample. this._circularBuffer.set(inData, this._inputBufferLength); this._inputBufferLength += inData.length;