Simplify visibility activity accounting for plugins
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Aug 2014 17:33:22 +0000 (17:33 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Aug 2014 17:33:22 +0000 (17:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135981

Reviewed by Dan Bernstein.

Just take one per connection, rather than implementing a counting mechanism.

* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::PluginControllerProxy):
* PluginProcess/PluginControllerProxy.h:
    - added m_visiblityActivity.
* PluginProcess/PluginProcess.cpp:
(WebKit::PluginProcess::PluginProcess):
(WebKit::PluginProcess::pluginsForWebProcessDidBecomeVisible): Deleted.
(WebKit::PluginProcess::pluginsForWebProcessDidBecomeHidden): Deleted.
* PluginProcess/PluginProcess.h:
    - removed pluginsForWebProcessDidBecomeVisible/Hidden.
* PluginProcess/WebProcessConnection.cpp:
(WebKit::WebProcessConnection::removePluginControllerProxy):
(WebKit::WebProcessConnection::pluginDidBecomeVisible): Deleted.
(WebKit::WebProcessConnection::pluginDidBecomeHidden): Deleted.
* PluginProcess/WebProcessConnection.h:
    - removed pluginDidBecomeVisible/Hidden.
* PluginProcess/mac/PluginControllerProxyMac.mm:
(WebKit::PluginControllerProxy::windowVisibilityChanged):
    - windowVisibilityChanged uses m_visiblityActivity, rather than calling to PluginControllerProxy.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172629 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/PluginProcess/PluginProcess.cpp
Source/WebKit2/PluginProcess/PluginProcess.h
Source/WebKit2/PluginProcess/WebProcessConnection.cpp
Source/WebKit2/PluginProcess/WebProcessConnection.h
Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm

index 600e272..818beee 100644 (file)
@@ -1,3 +1,32 @@
+2014-08-15  Gavin Barraclough  <barraclough@apple.com>
+
+        Simplify visibility activity accounting for plugins
+        https://bugs.webkit.org/show_bug.cgi?id=135981
+
+        Reviewed by Dan Bernstein.
+
+        Just take one per connection, rather than implementing a counting mechanism.
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::PluginControllerProxy):
+        * PluginProcess/PluginControllerProxy.h:
+            - added m_visiblityActivity.
+        * PluginProcess/PluginProcess.cpp:
+        (WebKit::PluginProcess::PluginProcess):
+        (WebKit::PluginProcess::pluginsForWebProcessDidBecomeVisible): Deleted.
+        (WebKit::PluginProcess::pluginsForWebProcessDidBecomeHidden): Deleted.
+        * PluginProcess/PluginProcess.h:
+            - removed pluginsForWebProcessDidBecomeVisible/Hidden.
+        * PluginProcess/WebProcessConnection.cpp:
+        (WebKit::WebProcessConnection::removePluginControllerProxy):
+        (WebKit::WebProcessConnection::pluginDidBecomeVisible): Deleted.
+        (WebKit::WebProcessConnection::pluginDidBecomeHidden): Deleted.
+        * PluginProcess/WebProcessConnection.h:
+            - removed pluginDidBecomeVisible/Hidden.
+        * PluginProcess/mac/PluginControllerProxyMac.mm:
+        (WebKit::PluginControllerProxy::windowVisibilityChanged):
+            - windowVisibilityChanged uses m_visiblityActivity, rather than calling to PluginControllerProxy.
+
 2014-08-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.5.3 release.
index a9532ac..e505e6d 100644 (file)
@@ -72,6 +72,7 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, c
     , m_contentsScaleFactor(creationParameters.contentsScaleFactor)
     , m_windowNPObject(0)
     , m_pluginElementNPObject(0)
+    , m_visiblityActivity("Plugin is visible.")
 {
 }
 
index 7e72859..07f87ff 100644 (file)
@@ -35,6 +35,7 @@
 #include "ShareableBitmap.h"
 #include "WebProcessConnectionMessages.h"
 #include <WebCore/SecurityOrigin.h>
+#include <WebCore/UserActivity.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RunLoop.h>
 
@@ -220,6 +221,9 @@ private:
 
     // The plug-in element NPObject.
     NPObject* m_pluginElementNPObject;
+
+    // Hold an activity when the plugin is visible to prevent throttling.
+    UserActivity m_visiblityActivity;
 };
 
 } // namespace WebKit
index dc44864..2841eed 100644 (file)
@@ -61,7 +61,6 @@ PluginProcess::PluginProcess()
     , m_compositingRenderServerPort(MACH_PORT_NULL)
 #endif
     , m_connectionActivity("PluginProcess connection activity.")
-    , m_visiblePluginsActivity("Visible plugins from PluginProcess activity.")
 {
     NetscapePlugin::setSetExceptionFunction(WebProcessConnection::setGlobalException);
     m_audioHardwareListener = AudioHardwareListener::create(*this);
@@ -246,16 +245,6 @@ void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters
 }
 #endif
 
-void PluginProcess::pluginsForWebProcessDidBecomeVisible()
-{
-    m_visiblePluginsActivity.increment();
-}
-
-void PluginProcess::pluginsForWebProcessDidBecomeHidden()
-{
-    m_visiblePluginsActivity.decrement();
-}
-    
 void PluginProcess::audioHardwareDidBecomeActive()
 {
     for (auto& connection : m_webProcessConnections)
index 944239a..1665439 100644 (file)
@@ -68,9 +68,6 @@ public:
 
     CountedUserActivity& connectionActivity() { return m_connectionActivity; }
 
-    void pluginsForWebProcessDidBecomeHidden();
-    void pluginsForWebProcessDidBecomeVisible();
-
 private:
     PluginProcess();
     ~PluginProcess();
@@ -133,8 +130,7 @@ private:
 
     static void lowMemoryHandler(bool critical);
     CountedUserActivity m_connectionActivity;
-    CountedUserActivity m_visiblePluginsActivity;
-    
+
     RefPtr<WebCore::AudioHardwareListener> m_audioHardwareListener;
 };
 
index 28ccd5f..186a7cb 100644 (file)
@@ -93,8 +93,6 @@ void WebProcessConnection::removePluginControllerProxy(PluginControllerProxy* pl
         ASSERT(pluginControllerUniquePtr.get() == pluginController);
     }
 
-    pluginDidBecomeHidden(pluginInstanceID);
-
     // Invalidate all objects related to this plug-in.
     if (plugin)
         m_npRemoteObjectMap->pluginDestroyed(plugin);
@@ -325,28 +323,6 @@ void WebProcessConnection::createPluginAsynchronously(const PluginCreationParame
     m_connection->sendSync(Messages::PluginProxy::DidCreatePlugin(wantsWheelEvents, remoteLayerClientID), Messages::PluginProxy::DidCreatePlugin::Reply(), creationParameters.pluginInstanceID);
 }
     
-void WebProcessConnection::pluginDidBecomeVisible(unsigned pluginInstanceID)
-{
-    bool oldState = m_visiblePluginInstanceIDs.isEmpty();
-    
-    m_visiblePluginInstanceIDs.add(pluginInstanceID);
-
-    ASSERT(m_visiblePluginInstanceIDs.size() <= m_pluginControllers.size());
-    
-    if (oldState != m_visiblePluginInstanceIDs.isEmpty())
-        PluginProcess::shared().pluginsForWebProcessDidBecomeVisible();
-}
-
-void WebProcessConnection::pluginDidBecomeHidden(unsigned pluginInstanceID)
-{
-    bool oldState = m_visiblePluginInstanceIDs.isEmpty();
-    
-    m_visiblePluginInstanceIDs.remove(pluginInstanceID);
-    
-    if (oldState != m_visiblePluginInstanceIDs.isEmpty())
-        PluginProcess::shared().pluginsForWebProcessDidBecomeHidden();
-}
-    
 void WebProcessConnection::audioHardwareDidBecomeActive()
 {
     m_connection->send(Messages::PluginProcessConnection::AudioHardwareDidBecomeActive(), 0);
index ac057db..af061d6 100644 (file)
@@ -54,9 +54,6 @@ public:
 
     static void setGlobalException(const String&);
     
-    void pluginDidBecomeVisible(unsigned pluginInstanceID);
-    void pluginDidBecomeHidden(unsigned pluginInstanceID);
-
     void audioHardwareDidBecomeActive();
     void audioHardwareDidBecomeInactive();
 
@@ -87,7 +84,6 @@ private:
     HashMap<uint64_t, std::unique_ptr<PluginControllerProxy>> m_pluginControllers;
     RefPtr<NPRemoteObjectMap> m_npRemoteObjectMap;
     HashSet<uint64_t> m_asynchronousInstanceIDsToIgnore;
-    HashSet<uint64_t> m_visiblePluginInstanceIDs;
 };
 
 } // namespace WebKit
index a3ce535..9b657ea 100644 (file)
@@ -108,9 +108,9 @@ void PluginControllerProxy::windowVisibilityChanged(bool isVisible)
 {
     m_plugin->windowVisibilityChanged(isVisible);
     if (isVisible)
-        m_connection->pluginDidBecomeVisible(m_pluginInstanceID);
+        m_visiblityActivity.start();
     else
-        m_connection->pluginDidBecomeHidden(m_pluginInstanceID);
+        m_visiblityActivity.stop();
 }
 
 void PluginControllerProxy::sendComplexTextInput(const String& textInput)