Bug 179552 - Call "Terminate Service Worker" on all workers when all their clients are gone
Summary: Call "Terminate Service Worker" on all workers when all their clients are gone
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-10 15:08 PST by Brady Eidson
Modified: 2017-12-05 13:24 PST (History)
5 users (show)

See Also:


Attachments
Patch (5.81 KB, patch)
2017-12-02 18:31 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (1.36 KB, patch)
2017-12-05 11:04 PST, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2017-11-10 15:08:47 PST
Consider calling "Terminate Service Worker" when WebProcesses go away
Comment 1 Brady Eidson 2017-11-16 12:50:09 PST
Rename for the simplicity of this patch: 
Consider calling "Terminate Service Worker" on all workers when all WebProcesses go away
Comment 2 youenn fablet 2017-12-02 18:31:21 PST
Created attachment 328272 [details]
Patch
Comment 3 WebKit Commit Bot 2017-12-04 12:35:09 PST
Comment on attachment 328272 [details]
Patch

Clearing flags on attachment: 328272

Committed r225486: <https://trac.webkit.org/changeset/225486>
Comment 4 WebKit Commit Bot 2017-12-04 12:35:10 PST
All reviewed patches have been landed.  Closing bug.
Comment 5 Radar WebKit Bug Importer 2017-12-04 12:37:30 PST
<rdar://problem/35836323>
Comment 6 Geoffrey Garen 2017-12-04 13:43:33 PST
Comment on attachment 328272 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328272&action=review

> Source/WebCore/workers/service/server/SWServer.cpp:55
> +static Seconds terminationDelay { 60_s };

I think we can make this value a lot smaller.

Starting a worker is less expensive than loading one or more webpages. So, if the user unloads the last page from a given origin, we really aren't that concerned about having to restart the origin's worker later.

I'd suggest something like 5s.
Comment 7 youenn fablet 2017-12-04 14:02:48 PST
(In reply to Geoffrey Garen from comment #6)
> Comment on attachment 328272 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=328272&action=review
> 
> > Source/WebCore/workers/service/server/SWServer.cpp:55
> > +static Seconds terminationDelay { 60_s };
> 
> I think we can make this value a lot smaller.
> 
> Starting a worker is less expensive than loading one or more webpages. So,
> if the user unloads the last page from a given origin, we really aren't that
> concerned about having to restart the origin's worker later.
> 
> I'd suggest something like 5s.

Maybe 60 is too big indeed, especially if we add another timer to quit the service worker process when there is no longer any running service worker.

That said, we might need some measurements on how much time it will take for a service worker to run and be ready to process fetch events as this may impact page load time.
Comment 8 youenn fablet 2017-12-05 11:04:43 PST
Reopening to attach new patch.
Comment 9 youenn fablet 2017-12-05 11:04:43 PST
Created attachment 328474 [details]
Patch
Comment 10 youenn fablet 2017-12-05 11:05:13 PST
(In reply to youenn fablet from comment #9)
> Created attachment 328474 [details]
> Patch

Reducing from 60_s to 10_s for now.
Comment 11 WebKit Commit Bot 2017-12-05 13:24:39 PST
Comment on attachment 328474 [details]
Patch

Clearing flags on attachment: 328474

Committed r225533: <https://trac.webkit.org/changeset/225533>
Comment 12 WebKit Commit Bot 2017-12-05 13:24:41 PST
All reviewed patches have been landed.  Closing bug.