Title: [154085] trunk/Source/WebKit2
Revision
154085
Author
[email protected]
Date
2013-08-14 17:43:19 -0700 (Wed, 14 Aug 2013)

Log Message

<https://webkit.org/b/119827> Allow primary plug-in detection to run more than once if necessary

Reviewed by Tim Horton.

We occasionally see cases where the primary plug-in detection runs before the plugins have been added
to the page, especially if they do so in response to a load event. Tweak the algorithm so that it can
run an arbitrary number of times if it fails.

While here, also have the detection run if there has ever been a plugin in the page as opposed to any
current views. We may have snapshotted a plugin by now and deleted its view.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): initialise new members.
(WebKit::WebPage::addPluginView): Mark that we've seen a plugin.
(WebKit::WebPage::resetPrimarySnapshottedPlugIn): Reset new members.
(WebKit::WebPage::determinePrimarySnapshottedPlugIn): Exit early if we've never
seen a plugin, rather than if we don't have any active views. Also, if we didn't find anything set
a timer to run again (maximum of two attempts at the moment).
* WebProcess/WebPage/WebPage.h: New members - m_numberOfPrimarySnapshotDetectionAttempts
and m_hasSeenPlugin.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (154084 => 154085)


--- trunk/Source/WebKit2/ChangeLog	2013-08-15 00:25:49 UTC (rev 154084)
+++ trunk/Source/WebKit2/ChangeLog	2013-08-15 00:43:19 UTC (rev 154085)
@@ -1,5 +1,28 @@
 2013-08-14  Dean Jackson  <[email protected]>
 
+        <https://webkit.org/b/119827> Allow primary plug-in detection to run more than once if necessary
+
+        Reviewed by Tim Horton.
+
+        We occasionally see cases where the primary plug-in detection runs before the plugins have been added
+        to the page, especially if they do so in response to a load event. Tweak the algorithm so that it can
+        run an arbitrary number of times if it fails.
+
+        While here, also have the detection run if there has ever been a plugin in the page as opposed to any
+        current views. We may have snapshotted a plugin by now and deleted its view.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage): initialise new members.
+        (WebKit::WebPage::addPluginView): Mark that we've seen a plugin.
+        (WebKit::WebPage::resetPrimarySnapshottedPlugIn): Reset new members.
+        (WebKit::WebPage::determinePrimarySnapshottedPlugIn): Exit early if we've never
+        seen a plugin, rather than if we don't have any active views. Also, if we didn't find anything set
+        a timer to run again (maximum of two attempts at the moment).
+        * WebProcess/WebPage/WebPage.h: New members - m_numberOfPrimarySnapshotDetectionAttempts
+        and m_hasSeenPlugin.
+
+2013-08-14  Dean Jackson  <[email protected]>
+
         <https://webkit.org/b/119820> Add pluginView-related logging to WebPage
 
         Reviewed by Tim Horton.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (154084 => 154085)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-08-15 00:25:49 UTC (rev 154084)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-08-15 00:43:19 UTC (rev 154085)
@@ -226,6 +226,7 @@
 
 WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     : m_viewSize(parameters.viewSize)
+    , m_hasSeenPlugin(false)
     , m_useFixedLayout(false)
     , m_drawsBackground(true)
     , m_drawsTransparentBackground(false)
@@ -240,6 +241,7 @@
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
     , m_readyToFindPrimarySnapshottedPlugin(false)
     , m_didFindPrimarySnapshottedPlugin(false)
+    , m_numberOfPrimarySnapshotDetectionAttempts(0)
     , m_determinePrimarySnapshottedPlugInTimer(RunLoop::main(), this, &WebPage::determinePrimarySnapshottedPlugInTimerFired)
 #endif
 #if PLATFORM(MAC)
@@ -3066,6 +3068,7 @@
     ASSERT(!m_pluginViews.contains(pluginView));
 
     m_pluginViews.add(pluginView);
+    m_hasSeenPlugin = true;
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
     LOG(Plugins, "Primary Plug-In Detection: triggering detection from addPluginView(%p)", pluginView);
     m_determinePrimarySnapshottedPlugInTimer.startOneShot(0);
@@ -4038,6 +4041,8 @@
 static float primarySnapshottedPlugInSearchBucketSize = 1.1;
 static int primarySnapshottedPlugInMinimumWidth = 400;
 static int primarySnapshottedPlugInMinimumHeight = 300;
+static unsigned maxPrimarySnapshottedPlugInDetectionAttempts = 2;
+static int deferredPrimarySnapshottedPlugInDetectionDelay = 3;
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
 void WebPage::determinePrimarySnapshottedPlugInTimerFired()
@@ -4063,8 +4068,8 @@
         return;
     }
 
-    if (m_pluginViews.isEmpty()) {
-        LOG(Plugins, "Primary Plug-In Detection: exiting - no plugin views.");
+    if (!m_hasSeenPlugin) {
+        LOG(Plugins, "Primary Plug-In Detection: exiting - we never saw a plug-in get added to the page.");
         return;
     }
 
@@ -4073,6 +4078,8 @@
         return;
     }
 
+    ++m_numberOfPrimarySnapshotDetectionAttempts;
+
     RenderView* renderView = corePage()->mainFrame()->view()->renderView();
 
     IntRect searchRect = IntRect(IntPoint(), corePage()->mainFrame()->view()->contentsSize());
@@ -4128,6 +4135,10 @@
 
     if (!candidatePlugIn) {
         LOG(Plugins, "Primary Plug-In Detection: fail - did not find a candidate plug-in.");
+        if (m_numberOfPrimarySnapshotDetectionAttempts < maxPrimarySnapshottedPlugInDetectionAttempts) {
+            LOG(Plugins, "Primary Plug-In Detection: will attempt again in %ds.", deferredPrimarySnapshottedPlugInDetectionDelay);
+            m_determinePrimarySnapshottedPlugInTimer.startOneShot(deferredPrimarySnapshottedPlugInDetectionDelay);
+        }
         return;
     }
 
@@ -4144,6 +4155,8 @@
 {
     m_readyToFindPrimarySnapshottedPlugin = false;
     m_didFindPrimarySnapshottedPlugin = false;
+    m_numberOfPrimarySnapshotDetectionAttempts = 0;
+    m_hasSeenPlugin = false;
 }
 
 bool WebPage::matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (154084 => 154085)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-08-15 00:25:49 UTC (rev 154084)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-08-15 00:43:19 UTC (rev 154085)
@@ -860,6 +860,7 @@
     OwnPtr<DrawingArea> m_drawingArea;
 
     HashSet<PluginView*> m_pluginViews;
+    bool m_hasSeenPlugin;
 
     HashMap<uint64_t, RefPtr<WebCore::TextCheckingRequest>> m_pendingTextCheckingRequestMap;
 
@@ -886,6 +887,7 @@
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
     bool m_readyToFindPrimarySnapshottedPlugin;
     bool m_didFindPrimarySnapshottedPlugin;
+    unsigned m_numberOfPrimarySnapshotDetectionAttempts;
     String m_primaryPlugInPageOrigin;
     String m_primaryPlugInOrigin;
     String m_primaryPlugInMimeType;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to