Title: [148919] trunk/Source/WebKit2
Revision
148919
Author
[email protected]
Date
2013-04-22 15:36:43 -0700 (Mon, 22 Apr 2013)

Log Message

Plugin Snapshotting: Don't consume insane amounts of time detecting the primary plugin
https://bugs.webkit.org/show_bug.cgi?id=114994
<rdar://problem/13696269>

Reviewed by Anders Carlsson.

On some pages, we currently waste a lot of time on every subframe load
and every addPluginView doing primary plugin detection. This patch
attempts to address this via a few minor changes:

- Only allow detection after the main frame's didFinishLoad comes, instead of the first subframe.

- Only explicitly detect on the main frame's didFinishLoad (not subframes).

- Coalesce calls to determinePrimarySnapshottedPlugIn from both addPluginView
(in case JS is adding lots of plugins in a loop) and didFinishLoad.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::addPluginView): Coalesce calls to determinePrimarySnapshottedPlugIn.
(WebKit::WebPage::didFinishLoad):
Coalesce calls to determinePrimarySnapshottedPlugIn.
Bail on subframe loads, we're only interested in the main frame being complete.
(WebKit::WebPage::determinePrimarySnapshottedPlugInTimerFired):
Call determinePrimarySnapshottedPlugIn.
* WebProcess/WebPage/WebPage.h:
Add m_determinePrimarySnapshottedPlugInTimer and determinePrimarySnapshottedPlugInTimerFired

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (148918 => 148919)


--- trunk/Source/WebKit2/ChangeLog	2013-04-22 22:29:22 UTC (rev 148918)
+++ trunk/Source/WebKit2/ChangeLog	2013-04-22 22:36:43 UTC (rev 148919)
@@ -1,3 +1,32 @@
+2013-04-22  Tim Horton  <[email protected]>
+
+        Plugin Snapshotting: Don't consume insane amounts of time detecting the primary plugin
+        https://bugs.webkit.org/show_bug.cgi?id=114994
+        <rdar://problem/13696269>
+
+        Reviewed by Anders Carlsson.
+
+        On some pages, we currently waste a lot of time on every subframe load
+        and every addPluginView doing primary plugin detection. This patch
+        attempts to address this via a few minor changes:
+
+        - Only allow detection after the main frame's didFinishLoad comes, instead of the first subframe.
+
+        - Only explicitly detect on the main frame's didFinishLoad (not subframes).
+
+        - Coalesce calls to determinePrimarySnapshottedPlugIn from both addPluginView
+        (in case JS is adding lots of plugins in a loop) and didFinishLoad.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::addPluginView): Coalesce calls to determinePrimarySnapshottedPlugIn.
+        (WebKit::WebPage::didFinishLoad):
+        Coalesce calls to determinePrimarySnapshottedPlugIn.
+        Bail on subframe loads, we're only interested in the main frame being complete.
+        (WebKit::WebPage::determinePrimarySnapshottedPlugInTimerFired):
+        Call determinePrimarySnapshottedPlugIn.
+        * WebProcess/WebPage/WebPage.h:
+        Add m_determinePrimarySnapshottedPlugInTimer and determinePrimarySnapshottedPlugInTimerFired
+
 2013-04-22  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/13334446> [Mac] Tweak sandbox profiles.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (148918 => 148919)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-04-22 22:29:22 UTC (rev 148918)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-04-22 22:36:43 UTC (rev 148919)
@@ -242,6 +242,7 @@
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
     , m_readyToFindPrimarySnapshottedPlugin(false)
     , m_didFindPrimarySnapshottedPlugin(false)
+    , m_determinePrimarySnapshottedPlugInTimer(RunLoop::main(), this, &WebPage::determinePrimarySnapshottedPlugInTimerFired)
 #endif
 #if PLATFORM(MAC)
     , m_pdfPluginEnabled(false)
@@ -2943,8 +2944,7 @@
 
     m_pluginViews.add(pluginView);
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
-    if (!m_page->settings()->snapshotAllPlugIns() && m_page->settings()->primaryPlugInSnapshotDetectionEnabled())
-        determinePrimarySnapshottedPlugIn();
+    m_determinePrimarySnapshottedPlugInTimer.startOneShot(0);
 #endif
 }
 
@@ -3923,9 +3923,11 @@
 void WebPage::didFinishLoad(WebFrame* frame)
 {
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
+    if (!frame->isMainFrame())
+        return;
+
     m_readyToFindPrimarySnapshottedPlugin = true;
-    if (!m_page->settings()->snapshotAllPlugIns() && m_page->settings()->primaryPlugInSnapshotDetectionEnabled())
-        determinePrimarySnapshottedPlugIn();
+    m_determinePrimarySnapshottedPlugInTimer.startOneShot(0);
 #else
     UNUSED_PARAM(frame);
 #endif
@@ -3938,6 +3940,14 @@
 static int primarySnapshottedPlugInMinimumWidth = 450;
 static int primarySnapshottedPlugInMinimumHeight = 300;
 
+#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
+void WebPage::determinePrimarySnapshottedPlugInTimerFired()
+{
+    if (!m_page->settings()->snapshotAllPlugIns() && m_page->settings()->primaryPlugInSnapshotDetectionEnabled())
+        determinePrimarySnapshottedPlugIn();
+}
+#endif
+
 void WebPage::determinePrimarySnapshottedPlugIn()
 {
     if (!m_page->settings()->plugInSnapshottingEnabled())

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (148918 => 148919)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-04-22 22:29:22 UTC (rev 148918)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-04-22 22:36:43 UTC (rev 148919)
@@ -648,6 +648,7 @@
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
     void determinePrimarySnapshottedPlugIn();
+    void determinePrimarySnapshottedPlugInTimerFired();
     void resetPrimarySnapshottedPlugIn();
     bool matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const;
 #endif
@@ -874,6 +875,7 @@
     String m_primaryPlugInPageOrigin;
     String m_primaryPlugInOrigin;
     String m_primaryPlugInMimeType;
+    WebCore::RunLoop::Timer<WebPage> m_determinePrimarySnapshottedPlugInTimer;
 #endif
 
 #if PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to