Bug 143115 - REGRESSION(r180768): Slower startup time for WKWebView
Summary: REGRESSION(r180768): Slower startup time for WKWebView
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Enrica Casucci
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-26 15:16 PDT by Enrica Casucci
Modified: 2015-03-26 16:25 PDT (History)
1 user (show)

See Also:


Attachments
Patch (4.97 KB, patch)
2015-03-26 15:24 PDT, Enrica Casucci
no flags Details | Formatted Diff | Diff
Patch2 (6.88 KB, patch)
2015-03-26 15:52 PDT, Enrica Casucci
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.