Bug 231771

Summary: Add a callback to know when the service worker loads via -[WKWebView _loadServiceWorker:]
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: WebKit APIAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, cdumez, ews-watchlist, ggaren, japhet, timothy, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

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].