Bug 220406 - Service Worker is no longer inspectable
Summary: Service Worker is no longer inspectable
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords: InRadar
Depends on:
Blocks: 227971
  Show dependency treegraph
 
Reported: 2021-01-07 03:13 PST by youenn fablet
Modified: 2021-07-14 15:59 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.16 KB, patch)
2021-01-08 00:57 PST, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Fixes the service worker regression (3.93 KB, text/plain)
2021-01-08 04:53 PST, youenn fablet
no flags Details
Patch (9.96 KB, patch)
2021-01-08 05:25 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 youenn fablet 2021-01-07 03:13:50 PST
Service Worker is no longer inspectable
Comment 1 youenn fablet 2021-01-07 03:14:00 PST
<rdar://problem/72883757>
Comment 2 youenn fablet 2021-01-07 03:15:04 PST
Seems to be related with https://bugs.webkit.org/show_bug.cgi?id=219386
Comment 3 youenn fablet 2021-01-07 03:19:48 PST
ServiceWorkerDebuggable (which implements Inspector::RemoteInspectionTarget) is currently owned by ServiceWorkerThreadProxy which lives in WebContent process.
There is no other debuggable in UIProcess contrary to Page and WebPageProxy.
Maybe this is what is missing?
Comment 4 Per Arne Vollan 2021-01-08 00:57:14 PST
Created attachment 417254 [details]
Patch
Comment 5 youenn fablet 2021-01-08 01:38:21 PST
Comment on attachment 417254 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:219
> +    if (WebCore::applicationBundleIdentifier() == "com.apple.Safari" && !CFPreferencesGetAppIntegerValue(CFSTR("ShowDevelopMenu"), CFSTR("com.apple.Safari.SandboxBroker"), nullptr))

This additional check is a no-op in case the app is Safari and Safari is no longer able to inspect service workers.
It is not clear to me how this could fix the issue.
Comment 6 Per Arne Vollan 2021-01-08 03:44:10 PST
(In reply to youenn fablet from comment #5)
> Comment on attachment 417254 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=417254&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:219
> > +    if (WebCore::applicationBundleIdentifier() == "com.apple.Safari" && !CFPreferencesGetAppIntegerValue(CFSTR("ShowDevelopMenu"), CFSTR("com.apple.Safari.SandboxBroker"), nullptr))
> 
> This additional check is a no-op in case the app is Safari and Safari is no
> longer able to inspect service workers.
> It is not clear to me how this could fix the issue.

I think Safari is still able to inspect service workers, but Safari Technology Preview is not, or perhaps I am mistaken?
Comment 7 youenn fablet 2021-01-08 04:41:00 PST
(In reply to Per Arne Vollan from comment #6)
> (In reply to youenn fablet from comment #5)
> > Comment on attachment 417254 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=417254&action=review
> > 
> > > Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:219
> > > +    if (WebCore::applicationBundleIdentifier() == "com.apple.Safari" && !CFPreferencesGetAppIntegerValue(CFSTR("ShowDevelopMenu"), CFSTR("com.apple.Safari.SandboxBroker"), nullptr))
> > 
> > This additional check is a no-op in case the app is Safari and Safari is no
> > longer able to inspect service workers.
> > It is not clear to me how this could fix the issue.
> 
> I think Safari is still able to inspect service workers, but Safari
> Technology Preview is not, or perhaps I am mistaken?

I tried Safari with the latest WebKit ToT and it no longer sees service worker.
When reverting https://trac.webkit.org/changeset/270326, I can see airhorner.com.
Comment 8 youenn fablet 2021-01-08 04:45:08 PST
I locally did a test to pass the sandbox extension at the time we initialise the web process and it fixes the issue.
It seems the sandbox extension arrives too late.
Comment 9 youenn fablet 2021-01-08 04:53:10 PST
Created attachment 417263 [details]
Fixes the service worker regression
Comment 10 Per Arne Vollan 2021-01-08 04:54:56 PST
(In reply to youenn fablet from comment #8)
> I locally did a test to pass the sandbox extension at the time we initialise
> the web process and it fixes the issue.
> It seems the sandbox extension arrives too late.

Ah, good catch! Maybe we need to call enableRemoteInspectorIfNeeded() after having intialized the web process?
Comment 11 Per Arne Vollan 2021-01-08 04:56:51 PST
(In reply to youenn fablet from comment #9)
> Created attachment 417263 [details]
> Fixes the service worker regression

It seems this patch creates the extension unconditionally. I think we only should create the extension when the Develop menu is enabled.
Comment 12 youenn fablet 2021-01-08 04:58:54 PST
(In reply to Per Arne Vollan from comment #11)
> (In reply to youenn fablet from comment #9)
> > Created attachment 417263 [details]
> > Fixes the service worker regression
> 
> It seems this patch creates the extension unconditionally. I think we only
> should create the extension when the Develop menu is enabled.

Right, and it should not be MAC specific, I just wrote it to validate the assumption that the sandbox extension was arriving too late.
I am not sure why it is important to happen sooner rather than later, it would be interesting to understand why.

I guess we could still use this patch approach as a fix.
Comment 13 youenn fablet 2021-01-08 05:25:43 PST
Created attachment 417264 [details]
Patch
Comment 14 youenn fablet 2021-01-08 05:30:17 PST
This patch fixes the main regression.
The case that does not work is if the process running the service worker started while the develop menu is off.
I think additional refactoring should be done to fix that case.
Comment 15 Per Arne Vollan 2021-01-08 06:46:32 PST
Comment on attachment 417264 [details]
Patch

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

Great, thanks for fixing! R=me.

> Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:225
> +void WebProcessProxy::enableRemoteInspectorIfNeeded()
> +{
> +    if (!shouldEnableRemoteInspector())
> +        return;
> +    send(Messages::WebProcess::EnableRemoteWebInspector(), 0);

It this function still needed? It could be useful when we implement observation of the Develop menu preference key.
Comment 16 Per Arne Vollan 2021-01-08 07:10:02 PST
Comment on attachment 417264 [details]
Patch

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

>> Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:225
>> +    send(Messages::WebProcess::EnableRemoteWebInspector(), 0);
> 
> It this function still needed? It could be useful when we implement observation of the Develop menu preference key.

I see that it is still needed; we call it when receiving an enable remote inspector notification.
Comment 17 EWS 2021-01-08 07:22:33 PST
Committed r271294: <https://trac.webkit.org/changeset/271294>

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