Bug 114994

Summary: Plugin Snapshotting: Don't consume insane amounts of time detecting the primary plugin
Product: WebKit Reporter: Tim Horton <thorton>
Component: Plug-insAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, sam, simon.fraser
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch andersca: review+

Description Tim Horton 2013-04-22 15:13:28 PDT
Some pages either have tons of subframes or dynamically add lots of plugins.

We're currently wasting a lot of time on every subframe load and every addPluginView doing primary plugin detection. Some things we can do to improve this:

* only start detecting after the main frame's didFinishLoad comes. This was intended to be in the original implementation, but we only wait for the first subframe's didFinishLoad instead :|

* only explicitly detect on the main frame's didFinishLoad (not subframes)

* coalesce calls to determinePrimarySnapshottedPlugInTimerFired from both addPluginView (in case JS is adding lots of plugins in a loop) and didFinishLoad

I'm not sure this is a 100% solution, but it should not regress primary plugin detection while improving performance greatly on some pages (http://thelede.blogs.nytimes.com/2013/04/19/updates-on-aftermath-of-boston-marathon-explosions-2/).

<rdar://problem/13696269>
Comment 1 Tim Horton 2013-04-22 15:18:11 PDT
Created attachment 199117 [details]
patch
Comment 2 Tim Horton 2013-04-22 15:18:21 PDT
Going to test more before landing.
Comment 3 Anders Carlsson 2013-04-22 15:31:49 PDT
Comment on attachment 199117 [details]
patch

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

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3949
> +void WebPage::determinePrimarySnapshottedPlugInTimerFired()
> +{
> +#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
> +    if (!m_page->settings()->snapshotAllPlugIns() && m_page->settings()->primaryPlugInSnapshotDetectionEnabled())
> +        determinePrimarySnapshottedPlugIn();
> +#endif
> +}

You probably want to put the entire function body inside the #if.
Comment 4 Tim Horton 2013-04-22 15:35:53 PDT
https://trac.webkit.org/changeset/148919