Re:Blink-dev – Intent to Ship: SharedArrayBuffer
by streptomycin on Friday April 07, 2017 @12:03AM
(#14057029)
You're right about Shared Workers not being needed for this, but just to continue going off on a tangent...
I think a polyfill would be pretty difficult. First you have to make sure only one tab starts a Web Worker. Maybe that's not impossible, but it's tricky. And then the real difficulty... when the tab that spawned the Web Worker closes while another tab is open, you'd need to spawn another Web Worker in that tab and copy the state of the first Web Worker to the second Web Worker before the first one is destroyed by the browser. Not sure if that's possible.
Re:Blink-dev – Intent to Ship: SharedArrayBuffer
by the8472 on Friday April 07, 2017 @05:47AM
(#14058405)
You can use broadcastchannel to coordinate multiple tabs and workers. And I think once you receive a message from such a channel you get a proxy for the sender, which means you can establish a 1-1 channel, which in turn means you can can transfer objects like sharedarraybuffer.
Using Web Workers instead of Shared Workers just means that any actual communication beyond the shared memory must be posted via the instantiator of the worker.