Bug 143115

Summary: REGRESSION(r180768): Slower startup time for WKWebView
Product: WebKit Reporter: Enrica Casucci <enrica>
Component: WebKit2Assignee: Enrica Casucci <enrica>
Status: RESOLVED FIXED    
Severity: Normal CC: thorton
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch2 andersca: review+

Description Enrica Casucci 2015-03-26 15:16:30 PDT
In http://trac.webkit.org/changeset/180768 we added an observer to track visibility of the NSFontPanel to ensure we could fetch the font information for the current selection when the panel first became visible.
It turns out that adding the observer requires the shared font panel object to be created. That is apparently a very expensive operation that is regressing the initialization time for the WKWebView.
We should do that lazily.

rdar://problem/20233711
Comment 1 Enrica Casucci 2015-03-26 15:24:47 PDT
Created attachment 249518 [details]
Patch
Comment 2 Anders Carlsson 2015-03-26 15:28:07 PDT
Comment on attachment 249518 [details]
Patch

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

> Source/WebKit2/UIProcess/API/mac/WKView.mm:2622
> +    [[NSFontPanel sharedFontPanel] addObserver:self forKeyPath:@"visible" options:NSKeyValueObservingOptionNew context:nil];

I don't think you need NSKeyValueObservingOptionNew unless you actually get it from the dictionary in your observe method. Also you need to specify a context. Just add something like

static void* wkViewObservationContext = &wkViewObservationContext;

and pass that in add and remove. You also need to compare the context in your observe method.
Comment 3 Enrica Casucci 2015-03-26 15:52:56 PDT
Created attachment 249524 [details]
Patch2

New patch that includes feedback from Anders.
Comment 4 Enrica Casucci 2015-03-26 15:54:08 PDT
Comment on attachment 249524 [details]
Patch2

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

> Source/WebKit2/UIProcess/API/mac/WKView.mm:3728
> +    NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingCursorUpdate;

Please  disregard this line. I had to update ToT.
Comment 5 Enrica Casucci 2015-03-26 16:25:04 PDT
Committed revision 182037.