1. Create a WebWorker that listens for messages using self.onmessage() 2. post the WebWorker a message port from the main thread 3. When the WebWorker receives a message port, listen to messages sent to it with port.OnMessage() 4. from the main thread, post a SharedArrayBuffer on the MessagePort. 5. Upon receiving the posted SharedArrayBuffer, the WebWorker will actually see an ArrayBuffer.. In my application I actually have multiple workers and allow communication between them using SharedArraybuffers that are posted on startup. This all works fine in Chrome, but unfortunately fails because of unwanted SharedArrayBuffer -> ArrayBuffer conversion in Safari.
Just realised, I didn't mention that the message port posted from the main thread to the web worker was one of the ports created as part of a new MessageChannel. The main thread then sends SharedArraybuffers using it's port from the MessageChannel and the WebWorker is listening on the port it has been sent.
<rdar://problem/102711280>