Title: [148038] trunk/Source/WebKit2
Revision
148038
Author
[email protected]
Date
2013-04-09 12:48:01 -0700 (Tue, 09 Apr 2013)

Log Message

Don't create another plugin process for restarted plugins
https://bugs.webkit.org/show_bug.cgi?id=114233

Reviewed by Geoff Garen.

A snapshotting plugin starts in a separate process from
regular plugins. This can be a little confusing to users
because they might see two plugin processes. We can set
the minimum life and timeout on the snapshotting process
to much smaller values, since the process doesn't need
to live that long. This will reduce some potential
confusion. Also, since there is another plugin process
running real plugins, it should be paged in if it needs
to restart.

There was, however, a bug in the process management. A
restarted plugin received a special PluginProcess::Type,
so that it could cross fade into the page nicely. This
caused it to start a *third* plugin process. Instead
mark a restarted flag directly on the PluginProxy and
revert back to two process types.

* PluginProcess/PluginProcess.h: Remove TypeRestartedProcess.

* UIProcess/Plugins/PluginProcessProxy.cpp: Add two new
    timeout values for snapshotting processes.
(WebKit::PluginProcessProxy::didFinishLaunching): Chose which
    of the timeout pairs to use.

* WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
(WebKit::PluginProxy::pluginLayer): Don't look at the process type, instead
    look at the process flag to see if we are restarted.
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::create): Copy the new flag into constructor.
(WebKit::PluginProxy::PluginProxy): Remember the flag.
* WebProcess/Plugins/PluginProxy.h: Add a new m_restartedProcess flag.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin): When we are creating the proxy, separate
    the concept of snapshotting and restarting.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (148037 => 148038)


--- trunk/Source/WebKit2/ChangeLog	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/ChangeLog	2013-04-09 19:48:01 UTC (rev 148038)
@@ -1,3 +1,46 @@
+2013-04-08  Dean Jackson  <[email protected]>
+
+        Don't create another plugin process for restarted plugins
+        https://bugs.webkit.org/show_bug.cgi?id=114233
+
+        Reviewed by Geoff Garen.
+
+        A snapshotting plugin starts in a separate process from
+        regular plugins. This can be a little confusing to users
+        because they might see two plugin processes. We can set
+        the minimum life and timeout on the snapshotting process
+        to much smaller values, since the process doesn't need
+        to live that long. This will reduce some potential
+        confusion. Also, since there is another plugin process
+        running real plugins, it should be paged in if it needs
+        to restart.
+
+        There was, however, a bug in the process management. A
+        restarted plugin received a special PluginProcess::Type,
+        so that it could cross fade into the page nicely. This
+        caused it to start a *third* plugin process. Instead
+        mark a restarted flag directly on the PluginProxy and
+        revert back to two process types.
+
+        * PluginProcess/PluginProcess.h: Remove TypeRestartedProcess.
+
+        * UIProcess/Plugins/PluginProcessProxy.cpp: Add two new
+            timeout values for snapshotting processes.
+        (WebKit::PluginProcessProxy::didFinishLaunching): Chose which
+            of the timeout pairs to use.
+
+        * WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm:
+        (WebKit::PluginProxy::pluginLayer): Don't look at the process type, instead
+            look at the process flag to see if we are restarted.
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::create): Copy the new flag into constructor.
+        (WebKit::PluginProxy::PluginProxy): Remember the flag.
+        * WebProcess/Plugins/PluginProxy.h: Add a new m_restartedProcess flag.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::createPlugin): When we are creating the proxy, separate
+            the concept of snapshotting and restarting.
+
 2013-04-09  Tim Horton  <[email protected]>
 
         [wk2] IconDatabase images should be decoded in the WebProcess

Modified: trunk/Source/WebKit2/PluginProcess/PluginProcess.h (148037 => 148038)


--- trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/PluginProcess/PluginProcess.h	2013-04-09 19:48:01 UTC (rev 148038)
@@ -44,8 +44,7 @@
     enum Type {
         // Start with value one since default HashTraits<> disallows zero as key.
         TypeRegularProcess = 1,
-        TypeSnapshotProcess,
-        TypeRestartedProcess
+        TypeSnapshotProcess
     };
 
     static PluginProcess& shared();

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp (148037 => 148038)


--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp	2013-04-09 19:48:01 UTC (rev 148038)
@@ -48,7 +48,10 @@
 namespace WebKit {
 
 static const double minimumLifetime = 2 * 60;
+static const double snapshottingMinimumLifetime = 30;
+
 static const double shutdownTimeout = 1 * 60;
+static const double snapshottingShutdownTimeout = 15;
 
 PassRefPtr<PluginProcessProxy> PluginProcessProxy::create(PluginProcessManager* PluginProcessManager, const PluginModuleInfo& pluginInfo, PluginProcess::Type processType)
 {
@@ -200,8 +203,13 @@
     
     PluginProcessCreationParameters parameters;
     parameters.processType = m_processType;
-    parameters.minimumLifetime = minimumLifetime;
-    parameters.terminationTimeout = shutdownTimeout;
+    if (m_processType == PluginProcess::TypeSnapshotProcess) {
+        parameters.minimumLifetime = snapshottingMinimumLifetime;
+        parameters.terminationTimeout = snapshottingShutdownTimeout;
+    } else {
+        parameters.minimumLifetime = minimumLifetime;
+        parameters.terminationTimeout = shutdownTimeout;
+    }
     platformInitializePluginProcess(parameters);
 
     // Initialize the plug-in host process.

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm (148037 => 148038)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/PluginProxyMac.mm	2013-04-09 19:48:01 UTC (rev 148038)
@@ -54,7 +54,7 @@
         m_pluginLayer.adoptNS([[CALayer alloc] init]);
         [m_pluginLayer.get() setGeometryFlipped:YES];
 
-        if (m_processType == PluginProcess::TypeRestartedProcess) {
+        if (m_isRestartedProcess) {
             CABasicAnimation *fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
             fadeInAnimation.fromValue = [NSNumber numberWithFloat:0];
             fadeInAnimation.toValue = [NSNumber numberWithFloat:1];

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (148037 => 148038)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2013-04-09 19:48:01 UTC (rev 148038)
@@ -56,12 +56,12 @@
     return ++uniquePluginInstanceID;
 }
 
-PassRefPtr<PluginProxy> PluginProxy::create(const String& pluginPath, PluginProcess::Type processType)
+PassRefPtr<PluginProxy> PluginProxy::create(const String& pluginPath, PluginProcess::Type processType, bool isRestartedProcess)
 {
-    return adoptRef(new PluginProxy(pluginPath, processType));
+    return adoptRef(new PluginProxy(pluginPath, processType, isRestartedProcess));
 }
 
-PluginProxy::PluginProxy(const String& pluginPath, PluginProcess::Type processType)
+PluginProxy::PluginProxy(const String& pluginPath, PluginProcess::Type processType, bool isRestartedProcess)
     : m_pluginPath(pluginPath)
     , m_pluginInstanceID(generatePluginInstanceID())
     , m_pluginBackingStoreContainsValidData(false)
@@ -71,6 +71,7 @@
     , m_remoteLayerClientID(0)
     , m_waitingOnAsynchronousInitialization(false)
     , m_processType(processType)
+    , m_isRestartedProcess(isRestartedProcess)
 {
 }
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (148037 => 148038)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2013-04-09 19:48:01 UTC (rev 148038)
@@ -56,7 +56,7 @@
 
 class PluginProxy : public Plugin {
 public:
-    static PassRefPtr<PluginProxy> create(const String& pluginPath, PluginProcess::Type);
+    static PassRefPtr<PluginProxy> create(const String& pluginPath, PluginProcess::Type, bool isRestartedProcess);
     ~PluginProxy();
 
     uint64_t pluginInstanceID() const { return m_pluginInstanceID; }
@@ -68,7 +68,7 @@
     bool isBeingAsynchronouslyInitialized() const { return m_waitingOnAsynchronousInitialization; }
 
 private:
-    explicit PluginProxy(const String& pluginPath, PluginProcess::Type);
+    explicit PluginProxy(const String& pluginPath, PluginProcess::Type, bool isRestartedProcess);
 
     // Plugin
     virtual bool initialize(const Parameters&);
@@ -218,6 +218,7 @@
 #endif
 
     PluginProcess::Type m_processType;
+    bool m_isRestartedProcess;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (148037 => 148038)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-04-09 19:18:29 UTC (rev 148037)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-04-09 19:48:01 UTC (rev 148038)
@@ -559,12 +559,9 @@
 
 #if ENABLE(PLUGIN_PROCESS)
 
-    PluginProcess::Type processType = PluginProcess::TypeRegularProcess;
-    if (pluginElement->displayState() == HTMLPlugInElement::WaitingForSnapshot)
-        processType = PluginProcess::TypeSnapshotProcess;
-    else if (pluginElement->displayState() == HTMLPlugInElement::Restarting || pluginElement->displayState() == HTMLPlugInElement::RestartingWithPendingMouseClick)
-        processType = PluginProcess::TypeRestartedProcess;
-    return PluginProxy::create(pluginPath, processType);
+    PluginProcess::Type processType = (pluginElement->displayState() == HTMLPlugInElement::WaitingForSnapshot ? PluginProcess::TypeSnapshotProcess : PluginProcess::TypeRegularProcess);
+    bool isRestartedProcess = (pluginElement->displayState() == HTMLPlugInElement::Restarting || pluginElement->displayState() == HTMLPlugInElement::RestartingWithPendingMouseClick);
+    return PluginProxy::create(pluginPath, processType, isRestartedProcess);
 #else
     NetscapePlugin::setSetExceptionFunction(NPRuntimeObjectMap::setGlobalException);
     return NetscapePlugin::create(NetscapePluginModule::getOrCreate(pluginPath));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to