You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make Service Worker implementation up-to-date #19302
As @creativcoder mentioned in #11091, the implementation of Service Worker has changed a lot.
I'd like to create this issue to make the Service Worker implementation up-to-date.
@CYBAI From the referenced PR it looks like you intend to work on this, but it's not assigned. Does that mean there is a chance to collaborate or would you like to work on this yourself?
@mandreyel Sure! The main goal for this issue is to make the implementation of Service Worker up-to-date. So, my first attempt is to update all the related webidl files. Let's update these webidl files first!
One thing I'd like to note and check against other people's view:
It seems to me that we spawn one "service worker manager" per script-process, running it as a thread on the same process.
I think this design could be improved on, because service workers are shared per-origin(with one origin potentially having many scopes), and the concept of a script process doesn't map to origin, it maps essentially to domain.
Also, even same-origin pages do not necessarily run in the same script process, since they can be part of different browsing context groups.
So, we could certainly share a service worker running in one script-process across all origins running the in the browser, but it seems sub-optimal to run them inside a script-process in that case. For example, what happens when the script process shuts down? In theory service workers should remain available to any other same-origin page running in another script-process, and lastly, I think service workers should even remain available once all script-processes have shut down.
So, I think an improvement on the design could be for the constellation to keep track of service workers(managers) on a per-origin basis, and run them in their own dedicated process, one per origin(which would be child processes of the constellation, not of script).
Then, when script requests a service-worker, it would initially be "brokered" by the constellation, which would then make a direct IPC communication possible between a script-process and the requested service-worker.
The constellation would then also be able to do stuff with service-workers outside of the scope of script, such as forwarding notifications coming from elsewhwere(I understand that's part of the idea of service workers).
we could certainly share a service worker running in one script-process across all origins running the in the browser, but it seems sub-optimal to run them inside a script-process in that case
this sounds efficient to me.
In theory service workers should remain available to any other same-origin page running in another script-process
yes, I think we should be able to reuse the same service worker between different browsing context but same origin?
Then, when script requests a service-worker, it would initially be "brokered" by the constellation, which would then make a direct IPC communication possible between a script-process and the requested service-worker.
The constellation would then also be able to do stuff with service-workers outside of the scope of script, such as forwarding notifications coming from elsewhere(I understand that's part of the idea of service workers).
Please let me know what you think.
@gterzian Sure! Don't have too much time recently 😓 but I will read the code and share my thought again here! (also read the SharedWorker issue you just opened) Btw, I'm working on #23545 because we'll also need to handle modules for service workers!
the same service worker between different browsing context but same origin
Yes, so the idea is, I think, that every ScriptThread for a given origin should use a single ServiceWorkerGlobalScope.
I'm reading a bit more through the existing code and there something that surprises me:
The constellation seems to have only one swmanager_chan, and it's set to a new value each time a sw_manager registers itself. So I in multiprocess Servo, I think this means that each time a new script process is started, a new sw_manager will be registered, at which point it will send it's swmanager_chan to the constellation and effectively overwrite a previous one. So it seems that in multiprocess mode, the process is broken since you'll end-up with only one SW manager in communication with the constellation, and each new script-process will overwrite a previously registered one(from the constellation's perspective).
In single-process mode a single sw_manager is created on start-up, however it runs all workers in the same process(obviously).
So my proposal is essentially have only one sw_manager, like is currently done in single-process Servo, but have it run one process per origin, and have all script-threads/processes use that single sw_manager, running one ServiceWorkerGlobalScope per origin(and have that run multiple registration scopes in one thread, or one thread per registration scope?)
Activity
Auto merge of #22171 - CYBAI:sw-up-to-date, r=<try>
vimpunk commentedon Nov 11, 2018
@CYBAI From the referenced PR it looks like you intend to work on this, but it's not assigned. Does that mean there is a chance to collaborate or would you like to work on this yourself?
CYBAI commentedon Nov 12, 2018
@mandreyel Sure! The main goal for this issue is to make the implementation of Service Worker up-to-date. So, my first attempt is to update all the related
webidlfiles. Let's update these webidl files first!vimpunk commentedon Nov 12, 2018
@CYBAI Cool, I'll look into updating some myself this evening, if that's alright!
CYBAI commentedon Nov 12, 2018
@mandreyel Great! You can leave a comment to let me know you'd like to work on which one so that I can work on the others 😆
vimpunk commentedon Nov 12, 2018
@CYBAI Alright, I will (please do the same)! I'm still reading the spec to get a better grip on the concepts at play here.
Auto merge of #22171 - CYBAI:sw-up-to-date, r=jdm
Auto merge of #22171 - CYBAI:sw-up-to-date, r=jdm
vimpunk commentedon Nov 13, 2018
I'm going to try updating the WebIDL of
ServiceWorkerGlobalScope!Auto merge of #22191 - mandreyel:update-sw-global-scope, r=paulrouget
Auto merge of #22171 - CYBAI:sw-up-to-date, r=jdm
Auto merge of #22191 - mandreyel:update-sw-global-scope, r=paulrouget
Auto merge of #22171 - CYBAI:sw-up-to-date, r=jdm
Auto merge of #22191 - mandreyel:update-sw-global-scope, r=paulrouget
9 remaining items
Auto merge of #22218 - CYBAI:sw-up-to-date, r=<try>
Auto merge of #22218 - CYBAI:sw-up-to-date, r=jdm
Auto merge of #22218 - CYBAI:sw-up-to-date, r=jdm
CYBAI commentedon Dec 18, 2018
I'll work on the remaining two for updating webidl and see what the next step is.
Auto merge of #22538 - CYBAI:update-sw-container, r=jdm
Auto merge of #22540 - CYBAI:update-sw-webidl, r=jdm
Auto merge of #22540 - CYBAI:update-sw-webidl, r=jdm
gterzian commentedon Jun 3, 2019
FYI there seems to be a huge amount of discussions over at https://github.com/whatwg/fetch/search?q=service+worker&type=Issues with regards to how Service Workers integrate with fetch and the http-cache. Related: #23495
gterzian commentedon Jul 18, 2019
One thing I'd like to note and check against other people's view:
It seems to me that we spawn one "service worker manager" per script-process, running it as a thread on the same process.
I think this design could be improved on, because service workers are shared per-origin(with one origin potentially having many scopes), and the concept of a script process doesn't map to origin, it maps essentially to domain.
Also, even same-origin pages do not necessarily run in the same script process, since they can be part of different browsing context groups.
So, we could certainly share a service worker running in one script-process across all origins running the in the browser, but it seems sub-optimal to run them inside a script-process in that case. For example, what happens when the script process shuts down? In theory service workers should remain available to any other same-origin page running in another script-process, and lastly, I think service workers should even remain available once all script-processes have shut down.
So, I think an improvement on the design could be for the constellation to keep track of service workers(managers) on a per-origin basis, and run them in their own dedicated process, one per origin(which would be child processes of the constellation, not of script).
Then, when script requests a service-worker, it would initially be "brokered" by the constellation, which would then make a direct IPC communication possible between a script-process and the requested service-worker.
The constellation would then also be able to do stuff with service-workers outside of the scope of script, such as forwarding notifications coming from elsewhwere(I understand that's part of the idea of service workers).
Please let me know what you think.
CYBAI commentedon Jul 18, 2019
this sounds efficient to me.
yes, I think we should be able to reuse the same service worker between different browsing context but same origin?
@gterzian Sure! Don't have too much time recently 😓 but I will read the code and share my thought again here! (also read the SharedWorker issue you just opened) Btw, I'm working on #23545 because we'll also need to handle
modulesfor service workers!gterzian commentedon Jul 18, 2019
Yes, so the idea is, I think, that every ScriptThread for a given origin should use a single
ServiceWorkerGlobalScope.I'm reading a bit more through the existing code and there something that surprises me:
The constellation seems to have only one
swmanager_chan, and it's set to a new value each time a sw_manager registers itself. So I in multiprocess Servo, I think this means that each time a new script process is started, a newsw_managerwill be registered, at which point it will send it'sswmanager_chanto the constellation and effectively overwrite a previous one. So it seems that in multiprocess mode, the process is broken since you'll end-up with only one SW manager in communication with the constellation, and each new script-process will overwrite a previously registered one(from the constellation's perspective).In single-process mode a single sw_manager is created on start-up, however it runs all workers in the same process(obviously).
So my proposal is essentially have only one sw_manager, like is currently done in single-process Servo, but have it run one process per origin, and have all script-threads/processes use that single sw_manager, running one
ServiceWorkerGlobalScopeper origin(and have that run multiple registration scopes in one thread, or one thread per registration scope?)gterzian commentedon Jul 22, 2019
This is worth reading: https://docs.google.com/presentation/d/1GZJ3VnLIO_Pw0jr9nRw6_-trg68ol-AkliMxJ6jo6Bo/edit#slide=id.g36f61837b7_1_69
gterzian commentedon Apr 6, 2020
I think we've ticked all the boxes at #19302 (comment)
Time to close this one?