Open MotasemAghbar opened 4 years ago
Thanks for this PR, it works perfectly. Too bad the original developer has vanished and this won't be ever merged.
I think that a better fix for this issue is to remove onaudioprocess event handler before processor has been deleted in cancelRecording function and finishRecording function (WevAudioRecorder.js):
cancelRecording: function () {
if (this.isRecording()) {
this.input.disconnect();
this.processor.disconnect();
this.processor.onaudioprocess = null;
delete this.processor;
this.worker.postMessage({ command: 'cancel' });
} else this.error('cancelRecording: no recording is running');
},
finishRecording: function () {
if (this.isRecording()) {
this.input.disconnect();
this.processor.disconnect();
this.processor.onaudioprocess = null;
delete this.processor;
this.worker.postMessage({ command: 'finish' });
} else this.error('finishRecording: no recording is running');
},
@maria-nedelkova thank you for the fix, I add the line this.processor.onaudioprocess = null;
before those functions and it fixes the error. :)
The function 'record' might throw a TypeError when executing
recBuffers.push
.This happens when stopping the recorder, there is a chance for a race condition in the last 'record' event call and clean method, the clean method assigns the recBuffers to null, record event might be executing after the clean method, and then throw type error because recBuffers isn't defined.
The fix is to check if the recBuffers is undefined before accessing that var.