Bug 215569 - [Cocoa] Avoid waiting for Launch Services on every load
Summary: [Cocoa] Avoid waiting for Launch Services on every load
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-17 07:20 PDT by Per Arne Vollan
Modified: 2020-10-02 11:54 PDT (History)
7 users (show)

See Also:


Attachments
Patch (2.60 KB, patch)
2020-08-17 07:23 PDT, Per Arne Vollan
darin: review+
Details | Formatted Diff | Diff
Patch (2.68 KB, patch)
2020-08-17 14:21 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Patch (2.68 KB, patch)
2020-08-17 14:29 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Per Arne Vollan 2020-08-17 07:20:25 PDT
Currently, we are waiting for the Launch Services database to be present on every load in the WebContent process. It should be sufficient to wait only on the first load.
Comment 1 Per Arne Vollan 2020-08-17 07:23:57 PDT
Created attachment 406715 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2020-08-17 07:25:25 PDT
<rdar://problem/67242794>
Comment 3 Darin Adler 2020-08-17 14:13:16 PDT
Comment on attachment 406715 [details]
Patch

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

> Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:69
> +    static std::once_flag onceFlag;
> +    std::call_once(onceFlag, [] {

This is a multi-thread-safe way of doing this. Can this be called from multiple threads? If not, a simple global check would suffice.
Comment 4 Per Arne Vollan 2020-08-17 14:16:11 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 406715 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406715&action=review
> 
> > Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:69
> > +    static std::once_flag onceFlag;
> > +    std::call_once(onceFlag, [] {
> 
> This is a multi-thread-safe way of doing this. Can this be called from
> multiple threads? If not, a simple global check would suffice.

No, I don't believe this can be called from multiple threads. Will fix.

Thanks for reviewing!
Comment 5 Per Arne Vollan 2020-08-17 14:21:36 PDT
Created attachment 406742 [details]
Patch
Comment 6 Darin Adler 2020-08-17 14:24:15 PDT
Comment on attachment 406742 [details]
Patch

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

> Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:79
> +    };

This semicolon is not needed.
Comment 7 Per Arne Vollan 2020-08-17 14:29:12 PDT
(In reply to Darin Adler from comment #6)
> Comment on attachment 406742 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406742&action=review
> 
> > Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:79
> > +    };
> 
> This semicolon is not needed.

Thanks, will fix :)
Comment 8 Per Arne Vollan 2020-08-17 14:29:48 PDT
Created attachment 406743 [details]
Patch
Comment 9 EWS 2020-08-17 14:54:47 PDT
Committed r265774: <https://trac.webkit.org/changeset/265774>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 406743 [details].
Comment 10 Chris Dumez 2020-10-02 11:27:01 PDT
Comment on attachment 406743 [details]
Patch

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

> Source/WebKit/ChangeLog:10
> +        increase the maximum wait time from 1s to 5s.

I don't think we are ever OK with hanging for 5 seconds. As a matter of fact, during this database update, the process is not processing incoming IPC anymore and gets reported as unresponsive to the client after 3 seconds. Clients such as mail kill the process right away which means that we hung but don't see the time out logging (because the process was terminated before reaching the timeout).

There are 2 issues here:
1. We should not be hanging in the first place
2. The 5 seconds timeout is too long. I'd suggest 1 or 2 seconds, something definitely below the 3 second timeout the UIProcess ResponsivenessTimer uses.
Comment 11 Darin Adler 2020-10-02 11:34:36 PDT
Comment on attachment 406743 [details]
Patch

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

>> Source/WebKit/ChangeLog:10
>> +        increase the maximum wait time from 1s to 5s.
> 
> I don't think we are ever OK with hanging for 5 seconds. As a matter of fact, during this database update, the process is not processing incoming IPC anymore and gets reported as unresponsive to the client after 3 seconds. Clients such as mail kill the process right away which means that we hung but don't see the time out logging (because the process was terminated before reaching the timeout).
> 
> There are 2 issues here:
> 1. We should not be hanging in the first place
> 2. The 5 seconds timeout is too long. I'd suggest 1 or 2 seconds, something definitely below the 3 second timeout the UIProcess ResponsivenessTimer uses.

Change it back to the 1 second it was before this patch?
Comment 12 Per Arne Vollan 2020-10-02 11:53:34 PDT
(In reply to Chris Dumez from comment #10)
> Comment on attachment 406743 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406743&action=review
> 
> > Source/WebKit/ChangeLog:10
> > +        increase the maximum wait time from 1s to 5s.
> 
> I don't think we are ever OK with hanging for 5 seconds. As a matter of
> fact, during this database update, the process is not processing incoming
> IPC anymore and gets reported as unresponsive to the client after 3 seconds.
> Clients such as mail kill the process right away which means that we hung
> but don't see the time out logging (because the process was terminated
> before reaching the timeout).
> 
> There are 2 issues here:
> 1. We should not be hanging in the first place

Yes. This seems to be caused by the entitlement check for "com.apple.private.webkit.use-xpc-endpoint" failing. I am currently looking into this.

> 2. The 5 seconds timeout is too long. I'd suggest 1 or 2 seconds, something
> definitely below the 3 second timeout the UIProcess ResponsivenessTimer uses.

That sounds good, I will change that.

Thanks for reviewing!
Comment 13 Per Arne Vollan 2020-10-02 11:54:00 PDT
(In reply to Darin Adler from comment #11)
> Comment on attachment 406743 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406743&action=review
> 
> >> Source/WebKit/ChangeLog:10
> >> +        increase the maximum wait time from 1s to 5s.
> > 
> > I don't think we are ever OK with hanging for 5 seconds. As a matter of fact, during this database update, the process is not processing incoming IPC anymore and gets reported as unresponsive to the client after 3 seconds. Clients such as mail kill the process right away which means that we hung but don't see the time out logging (because the process was terminated before reaching the timeout).
> > 
> > There are 2 issues here:
> > 1. We should not be hanging in the first place
> > 2. The 5 seconds timeout is too long. I'd suggest 1 or 2 seconds, something definitely below the 3 second timeout the UIProcess ResponsivenessTimer uses.
> 
> Change it back to the 1 second it was before this patch?

Yes, I will change it back to 1 second.

Thanks for reviewing!