Bug 179396 - [Service Workers] Support waitUntil() on the 'install' event
Summary: [Service Workers] Support waitUntil() on the 'install' event
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: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-07 15:03 PST by Chris Dumez
Modified: 2017-11-15 12:07 PST (History)
7 users (show)

See Also:


Attachments
WIP Patch (11.98 KB, patch)
2017-11-07 16:13 PST, Chris Dumez
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (2.60 MB, application/zip)
2017-11-07 17:27 PST, Build Bot
no flags Details
Archive of layout-test-results from ews125 for ios-simulator-wk2 (2.33 MB, application/zip)
2017-11-07 17:47 PST, Build Bot
no flags Details
WIP Patch (14.45 KB, patch)
2017-11-07 18:37 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (21.45 KB, patch)
2017-11-07 19:28 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (23.92 KB, patch)
2017-11-07 19:35 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (23.84 KB, patch)
2017-11-07 19:36 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (25.97 KB, patch)
2017-11-07 19:43 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (26.78 KB, patch)
2017-11-07 20:06 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (34.83 KB, patch)
2017-11-07 20:18 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (32.93 KB, patch)
2017-11-07 20:20 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-11-07 15:03:49 PST
Support waitUntil() on the 'install' event:
- https://w3c.github.io/ServiceWorker/#installation-algorithm (step 10.4)
Comment 1 Chris Dumez 2017-11-07 16:13:27 PST
Created attachment 326273 [details]
WIP Patch
Comment 2 Build Bot 2017-11-07 17:27:58 PST
Comment on attachment 326273 [details]
WIP Patch

Attachment 326273 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/5140403

New failing tests:
imported/w3c/web-platform-tests/service-workers/service-worker/windowclient-navigate.https.html
imported/w3c/web-platform-tests/service-workers/service-worker/oninstall-script-error.https.html
imported/w3c/web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https.html
Comment 3 Build Bot 2017-11-07 17:27:59 PST
Created attachment 326275 [details]
Archive of layout-test-results from ews105 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 4 Build Bot 2017-11-07 17:47:49 PST
Comment on attachment 326273 [details]
WIP Patch

Attachment 326273 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/5140439

New failing tests:
imported/w3c/web-platform-tests/streams/readable-streams/count-queuing-strategy-integration.serviceworker.https.html
imported/w3c/web-platform-tests/service-workers/service-worker/oninstall-script-error.https.html
imported/w3c/web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https.html
imported/w3c/web-platform-tests/service-workers/service-worker/windowclient-navigate.https.html
Comment 5 Build Bot 2017-11-07 17:47:51 PST
Created attachment 326279 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.6
Comment 6 Chris Dumez 2017-11-07 18:37:59 PST
Created attachment 326283 [details]
WIP Patch
Comment 7 Chris Dumez 2017-11-07 19:28:53 PST
Created attachment 326288 [details]
WIP Patch
Comment 8 Build Bot 2017-11-07 19:30:35 PST
Attachment 326288 [details] did not pass style-queue:


ERROR: Source/WebCore/workers/service/ServiceWorkerContainer.h:75:  The parameter name "registration" adds no information, so it should be removed.  [readability/parameter_name] [5]
ERROR: Source/WebCore/workers/service/ServiceWorkerContainer.h:76:  The parameter name "registration" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 2 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Chris Dumez 2017-11-07 19:35:29 PST
Created attachment 326289 [details]
WIP Patch
Comment 10 Chris Dumez 2017-11-07 19:36:46 PST
Created attachment 326290 [details]
WIP Patch
Comment 11 Chris Dumez 2017-11-07 19:43:34 PST
Created attachment 326292 [details]
WIP Patch
Comment 12 Chris Dumez 2017-11-07 20:06:33 PST
Created attachment 326294 [details]
WIP Patch
Comment 13 Chris Dumez 2017-11-07 20:18:05 PST
Created attachment 326295 [details]
Patch
Comment 14 Chris Dumez 2017-11-07 20:20:37 PST
Created attachment 326296 [details]
Patch
Comment 15 Chris Dumez 2017-11-08 09:26:27 PST
Comment on attachment 326296 [details]
Patch

Clearing flags on attachment: 326296

Committed r224584: <https://trac.webkit.org/changeset/224584>
Comment 16 Chris Dumez 2017-11-08 09:26:28 PST
All reviewed patches have been landed.  Closing bug.
Comment 17 youenn fablet 2017-11-08 09:34:05 PST
Comment on attachment 326296 [details]
Patch

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

> Source/WebCore/workers/service/context/ServiceWorkerThread.cpp:126
> +        installEvent->whenAllExtendLifetimePromisesAreSettled([serviceWorkerIdentifier](HashSet<Ref<DOMPromise>>&& extendLifetimePromises) {

Removing a promise from the hashset as soon as promise is settled seems simpler and is more efficient.
I am not sure why we want to keep references for all promises.
In the particular install case, we could instead have a callback taking an allResolved/rejected flag.
Would that work with all other cases?
Comment 18 youenn fablet 2017-11-08 09:35:05 PST
Ah I arrived too late there...
If the callback(allresolved/rejected) works, I would much prefer this model.
Comment 19 Chris Dumez 2017-11-08 09:41:08 PST
(In reply to youenn fablet from comment #18)
> Ah I arrived too late there...
> If the callback(allresolved/rejected) works, I would much prefer this model.

We can simplify later on. The current design is very flexible since it provides all the promises to the caller. This also matches the spec very closely.

I do not really buy the 'more efficient' argument since I do not have to remove anything from the HashSet and I only keep the promises alive until I call the "all promises resolved" callback.
Comment 20 Chris Dumez 2017-11-08 09:47:30 PST
(In reply to Chris Dumez from comment #19)
> (In reply to youenn fablet from comment #18)
> > Ah I arrived too late there...
> > If the callback(allresolved/rejected) works, I would much prefer this model.
> 
> We can simplify later on. The current design is very flexible since it
> provides all the promises to the caller. This also matches the spec very
> closely.
> 
> I do not really buy the 'more efficient' argument since I do not have to
> remove anything from the HashSet and I only keep the promises alive until I
> call the "all promises resolved" callback.

Note that I am not against the AllResolved/Rejected idea. I just do not think this has to be done now. There will be more users of waitUntil() and I'd rather we simplify the design once all are implemented (correctly).
Comment 21 youenn fablet 2017-11-08 09:56:37 PST
"more efficient" is in the sense that before the patch the promise is collectable as soon as settled. AFAIUI, with this patch, this will not happen until all related promises are settled. This does not seem like an improvement to me.

If there is an actual use case for checking each individual promise result, this patch is fine. My guess is that rejected/resolved is probably sufficient.
Comment 22 Chris Dumez 2017-11-08 10:00:21 PST
(In reply to Chris Dumez from comment #20)
> (In reply to Chris Dumez from comment #19)
> > (In reply to youenn fablet from comment #18)
> > > Ah I arrived too late there...
> > > If the callback(allresolved/rejected) works, I would much prefer this model.
> > 
> > We can simplify later on. The current design is very flexible since it
> > provides all the promises to the caller. This also matches the spec very
> > closely.
> > 
> > I do not really buy the 'more efficient' argument since I do not have to
> > remove anything from the HashSet and I only keep the promises alive until I
> > call the "all promises resolved" callback.
> 
> Note that I am not against the AllResolved/Rejected idea. I just do not
> think this has to be done now. There will be more users of waitUntil() and
> I'd rather we simplify the design once all are implemented (correctly).

I'll let you know once we implement the other call sites properly.
Comment 23 Radar WebKit Bug Importer 2017-11-15 12:07:52 PST
<rdar://problem/35567002>