chrisguttandin / extendable-media-recorder-wav-encoder

A Wave file encoder for the extendable-media-recorder package.
MIT License
40 stars 4 forks source link

Chunks missing in Safari 15.6.1 #404

Closed FlawTECH closed 1 year ago

FlawTECH commented 1 year ago

I have an issue which is oddly similar to #400 but using latest versions:

It sounds like half the audio is completely removed from the resulting recording at regular intervals. For example, counting from 1 to 10 to 1 again results in "1,2,3, cuts, 6,7,8,9, cuts, 6,5,4-cuts-2,1" or something similar.

Here is a PoC with code sample: https://codesandbox.io/s/nostalgic-sea-vi5m4q

Tested on Safari 15.6.1 (MacOS). No issues at all on Chrome / Firefox.

Thank you

chrisguttandin commented 1 year ago

Hi @FlawTECH,

thanks for reporting this. I could reproduce the problem in Safari v16.1 as well. And sadly it is also reproducible in v16.2 and the Technology Preview.

It seems to be a problem with the AudioWorklet. When I force the usage of the ScriptProcessorNode everything gets recorded but with a lot of glitches.

Unfortunately I have no idea for a quick fix. I think I won't have time to take a closer look at this before next year.

FlawTECH commented 1 year ago

Thank you for looking into it. No problem on the delay, take all the time you need.

Yes I had a ton of issues with ScriptProcessorNode and that was what made me look for a better solution with AudioWorklets. I'd be very happy to try and look into the issue myself but I unfortunately don't have the time and knowledge. If I ever come around to it, I'll let you know. I'm writing a (very crappy) version myself which doesn't use MediaRecorder in the hopes that it works well enough in the meantime.

chrisguttandin commented 1 year ago

It looks like there is a bug in Safari which is triggered when the AudioContext is created after the call to getUserMedia().

Here is an example which works: https://stackblitz.com/edit/js-qschf4?file=index.js

And here is one which doesn't: https://stackblitz.com/edit/js-twknnl?file=index.js

The only difference between the two is the order in which new AudioContext() and getUserMedia() are called in line 27 to 30.

chrisguttandin commented 1 year ago

I guess this bug was fixed yesterday. https://bugs.webkit.org/show_bug.cgi?id=251091

FlawTECH commented 1 year ago

Thanks a lot for your insights. I can confirm it works when AudioContext is created before calling getUserMedia(). Looks like the webkit bug report you linked is indeed related to this matter.

Not sure if the fix is included in Safari 16.3 as I'm unable to update at this time; will report back once I can try. In the meantime, I'll close the issue as it's a Webkit issue.