Bug 248170
| Summary: | Listeners to MessagePort Postmessage() receive ArrayBuffer rather than SharedArrayBuffer | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Dan S <d_a_stapleton> |
| Component: | WebCore JavaScript | Assignee: | 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 | ||
Dan S
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.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Dan S
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.
Radar WebKit Bug Importer
<rdar://problem/102711280>