-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why AudioWorklet disables Atomics.wait? #1848
Comments
By design, AudioWorkletProcessor must be synchronously processed by "rendering thread". If the user code in the processor blocks the thread (like For real-time audio use case, synchronously blocking the thread is generally not a good idea. I'll update my example with a better shared memory model. |
http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing is the classic reference for this kind of question, but the bottom line is: one should never ever ever wait in a real-time audio callback, so we disabled |
Does this also apply to the WASM instruction |
I didn't test on other browser but only Chrome and it might only matter on Chrome.
As AudioWorklet SharedArrayBuffer model example shows, a separate
Worker
thread produce audio data andAudioWorklet
thread consumes the produced data continuously.But this sample code has race condition issue when producing audio data on
Worker
thread takes heavy time for some reason andWorklet
thread tries to consume before the data is produced.Which means
Worklet
should check whether data is ready or not. Two possible solutions are (as written on hereBut both of them seems to have a problem.
Glitching is not a problem in here since glitching has already happened when consumer suffers lack of data. Rather than, this such unnatural solution to solve this situation makes me feel bad. If
Atomics.wait
can be used inWorklet
thread, it can just wait usingAtomics.wait
until data is ready and everything will looks fine.Or, is there any technical / design issue which prevents
Atomics.wait
to be enabled onAudioWorklet
?The text was updated successfully, but these errors were encountered: