padenot / ringbuf.js

Wait-free thread-safe single-consumer single-producer ring buffer using SharedArrayBuffer
https://ringbuf-js.netlify.app/
Mozilla Public License 2.0
201 stars 18 forks source link

main-thread-to-audioworklet doesn't work on Safari #14

Closed ebekebe closed 1 year ago

ebekebe commented 2 years ago

I tried to run main-thread-to-audioworklet on Safari 15.4 on macOS with __XPC_JSC_useSharedArrayBuffer=1, but it doesn't work. Is that a known limitation of Safari?

padenot commented 2 years ago

Real strange, this used to work. console.log from the worklet doesn't work either.

chaosprint commented 2 years ago

Real strange, this used to work. console.log from the worklet doesn't work either.

I got this problem too. Safari version 15.2

designerfuzzi commented 2 years ago

to be able to work an class named "SharedArrayBuffer" should exist, which is nowhere to find.. means as it does not exist in Safari the ringbuff works starting Safari 15.2 and has no fallback

EricTetz commented 2 years ago

@designerfuzzi If SharedArrayBuffer is missing it's because the file was served with the wrong headers (see here).

I'm seeing the everything get instantiated correctly, the AudioContext change status to "running", the AudioWorkletNode gets loaded (its script is loaded and shows up in the debugger), and Safari even shows a icon in the URL bar (e.g. 🔊) to indicate that the tab is making sound. Just... nothing comes out. The AudioWorkletNode is not pulling data from the ring buffer, so it gets full and then is never written to again.

I've only been doing web audio for a few weeks and I think it's aged me a year. AudioWorkletNode is the bleeding edge, latest and great addition to the API, and it has a hardcoded buffer size? I don't understand who's writing this stuff.

Your approach here is clearly the best way to feed audio to the thread, and it just magically stops working in Safari. The debugger tells you nothing.

EricTetz commented 1 year ago

FYI, I just checked in a newer version of Safari and this is working again. Yeah!

ebekebe commented 1 year ago

@EricTetz that is great news, so I am going to close this issue.

padenot commented 1 year ago

Thanks for checking folks, glad this is working. I'll be updating the readme.

designerfuzzi commented 1 year ago

SharedArrayBuffer is supported from Safari 15.2. every earlier version will just do nothing of course. https://caniuse.com/sharedarraybuffer