Bug 231771 - Add a callback to know when the service worker loads via -[WKWebView _loadServiceWorker:]
Summary: Add a callback to know when the service worker loads via -[WKWebView _loadSer...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-14 14:17 PDT by Timothy Hatcher
Modified: 2021-10-18 15:21 PDT (History)
8 users (show)

See Also:


Attachments
Patch (21.25 KB, patch)
2021-10-18 09:44 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (21.54 KB, patch)
2021-10-18 11:16 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (24.01 KB, patch)
2021-10-18 12:37 PDT, 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 Timothy Hatcher 2021-10-14 14:17:51 PDT
Currently there is no way to know the service worker has loaded. Currently `webView:didFinishNavigation:` fires early and the service worker loads after this.

A new delegate or a completion handler on _loadServiceWorker: would be great. The completion handler should likely pass an `NSError`, or `bool` for success or failure reporting.
Comment 1 Radar WebKit Bug Importer 2021-10-14 14:26:23 PDT
<rdar://problem/84274364>
Comment 2 Chris Dumez 2021-10-18 09:44:33 PDT
Created attachment 441618 [details]
Patch
Comment 3 Chris Dumez 2021-10-18 11:16:58 PDT
Created attachment 441624 [details]
Patch
Comment 4 Alex Christensen 2021-10-18 12:08:02 PDT
Comment on attachment 441624 [details]
Patch

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

> Source/WebKit/UIProcess/WebPageProxy.cpp:4812
> +            m_serviceWorkerLaunchCompletionHandler(false);

I think you need this in the destructor too.
Comment 5 Chris Dumez 2021-10-18 12:09:33 PDT
(In reply to Alex Christensen from comment #4)
> Comment on attachment 441624 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=441624&action=review
> 
> > Source/WebKit/UIProcess/WebPageProxy.cpp:4812
> > +            m_serviceWorkerLaunchCompletionHandler(false);
> 
> I think you need this in the destructor too.

Good point, will fix.
Comment 6 Chris Dumez 2021-10-18 12:37:34 PDT
Created attachment 441631 [details]
Patch
Comment 7 EWS 2021-10-18 15:21:48 PDT
Committed r284406 (243179@main): <https://commits.webkit.org/243179@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 441631 [details].