Bug 116359 - Disable SharedWorker when in multiple web process model
Summary: Disable SharedWorker when in multiple web process model
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-05-17 15:33 PDT by Alexey Proskuryakov
Modified: 2018-01-07 18:12 PST (History)
5 users (show)

See Also:


Attachments
proposed patch (6.70 KB, patch)
2013-05-17 15:45 PDT, Alexey Proskuryakov
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2013-05-17 15:33:38 PDT
Shared workers can not communicate across processes currently, so they should better be disabled.

<rdar://problem/13819878>
Comment 1 Alexey Proskuryakov 2013-05-17 15:45:55 PDT
Created attachment 202167 [details]
proposed patch
Comment 2 Alexey Proskuryakov 2013-05-17 17:04:44 PDT
Committed <http://trac.webkit.org/r150310>.
Comment 3 Ryosuke Niwa 2013-05-17 19:15:39 PDT
This patch caused a whole bunch of tests to fail on WK2 bots:
http://build.webkit.org/results/Apple%20MountainLion%20Release%20WK2%20(Tests)/r150313%20(8978)/results.html
Comment 4 Alexey Proskuryakov 2013-05-17 21:23:46 PDT
Fixed in <http://trac.webkit.org/changeset/150322>.
Comment 5 Takahiro Ichihashi 2017-07-26 03:37:34 PDT
Hello, could you consider/discuss reenabling this feature? 

"The implementation of Shared Web Workers was imposing undesirable constraints on the engine. The feature never gained any adoption and was eventually removed from the engine."
https://webkit.org/status/#feature-shared-web-workers

I understand this, but API itself looks very simple, and easier(-to-use) than service worker.
Comment 6 Ryosuke Niwa 2017-07-26 04:32:53 PDT
(In reply to Takahiro Ichihashi from comment #5)
> Hello, could you consider/discuss reenabling this feature? 
> 
> "The implementation of Shared Web Workers was imposing undesirable
> constraints on the engine. The feature never gained any adoption and was
> eventually removed from the engine."
> https://webkit.org/status/#feature-shared-web-workers
> 
> I understand this, but API itself looks very simple, and easier(-to-use)
> than service worker.

What we need is a compelling evidence that Web developers will use shared workers. Given that people don't even use shared workers in the browsers that support it (Chrome & Firefox), the argument for supporting this feature is rather weak. Also understand that the engineering resources spent to make shared worker work is the engineering resource that can't be spent elsewhere like implementing service workers so there is a huge opportunity cost associated with making this feature work across web content processes.
Comment 7 Takahiro Ichihashi 2017-07-26 09:04:52 PDT
Thanks for your reply.

The reason behind the low adoption rate of the API is probably the immaturity of the developer communities - meaning, it sometimes takes time for new APIs to become mainstream (XHR, formally a vendor-specific Microsoft.XMLHTTP or dynamic <script tag generation technique took 7~8 years to become a core part of web). 

Difficultly I found is that, currently it is a bit tricky to make a script that is shared across windows/tabs; in my case there are persistent connections via websocket / webrtc that provides some information periodically, which I want to make it more efficient by just having a one thread/tab that handles such connection even when there're multiple tabs opening, but at this time a polyfill should be made probably by utilizing localStorage events. 

Service workers will solve this problem (I'm fine with this API given a lower development priority compared to service worker anyway) but personally I feel that service workers have got so many features, and I believe there's a possibility that shared worker would be loved by many developers with specific needs like the above one. But thanks for your quick reply anyway, pls let me know if anything that I can help.
Comment 8 nmrugg 2017-10-23 20:31:59 PDT
Hi,

I work at Chess.com. We're definitely interested in SharedWorkers, but since it's not supported in all browsers and there are no polyfills, we can't use them. So, low adoption rate is inevitable. It'd be nice if you'd reconsider.
Comment 9 Igor Zvyagintsev 2017-11-30 03:56:50 PST
(In reply to Ryosuke Niwa from comment #6)
> What we need is a compelling evidence that Web developers will use shared
> workers.

Naturally, developers don't use SharedWorkers because it isn't supports in all browsers and no way to polyfill it.
Comment 10 Ryosuke Niwa 2017-12-04 13:58:46 PST
(In reply to nmrugg from comment #8)
> I work at Chess.com. We're definitely interested in SharedWorkers, but since
> it's not supported in all browsers and there are no polyfills, we can't use
> them. So, low adoption rate is inevitable. It'd be nice if you'd reconsider.

(In reply to Igor Zvyagintsev from comment #9)
> Naturally, developers don't use SharedWorkers because it isn't supports in
> all browsers and no way to polyfill it.

What are your concrete use cases? Wanting to share scripts across tabs/pages isn't one. That's a very specific mechanism by which some use case is addressed. Sharing a network connection between multiple tabs is one abstract use case that came up but that's better served by a service worker.
Comment 11 Igor Zvyagintsev 2017-12-04 14:16:10 PST
(In reply to Ryosuke Niwa from comment #10) 
> What are your concrete use cases?

Synchronous logout e.g. when the user presses the exit button, he must automatically log out of the system and on the other tabs. It's real task assumed on me in Jira.
Comment 12 Kellen Green 2018-01-07 11:13:08 PST
At the moment I'm using SharedWorkers to Share a single WebSocket connection between all tabs. 

ServiceWorkers (from my understanding) would not be sufficient for such a use case.
Comment 13 nmrugg 2018-01-07 18:12:22 PST
(In reply to Ryosuke Niwa from comment #10)
> What are your concrete use cases? Wanting to share scripts across tabs/pages
> isn't one. That's a very specific mechanism by which some use case is
> addressed. Sharing a network connection between multiple tabs is one
> abstract use case that came up but that's better served by a service worker.

At Chess.com, we are considering running a single instance of a WASM chess engine that can be shared across multiple tabs. The chess engine takes a lot of resources and also has a noticeable start up time. Sharing one could be useful for certain tasks.