Bug 248170

Summary: Listeners to MessagePort Postmessage() receive ArrayBuffer rather than SharedArrayBuffer
Product: WebKit Reporter: Dan S <d_a_stapleton>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ap, cdumez, karlcow, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 16   
Hardware: Mac (Apple Silicon)   
OS: macOS 13   

Description Dan S 2022-11-21 03:22:22 PST
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.
Comment 1 Dan S 2022-11-21 03:32:32 PST
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.
Comment 2 Radar WebKit Bug Importer 2022-11-28 03:23:20 PST
<rdar://problem/102711280>