Commit d2e255d0 authored by dino@apple.com's avatar dino@apple.com

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148038 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 35793949
2013-04-08 Dean Jackson <dino@apple.com>
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 <timothy_horton@apple.com>
[wk2] IconDatabase images should be decoded in the WebProcess
......@@ -44,8 +44,7 @@ public:
enum Type {
// Start with value one since default HashTraits<> disallows zero as key.
TypeRegularProcess = 1,
TypeSnapshotProcess,
TypeRestartedProcess
TypeSnapshotProcess
};
static PluginProcess& shared();
......
......@@ -48,7 +48,10 @@ using namespace WebCore;
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 @@ void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connectio
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.
......
......@@ -54,7 +54,7 @@ PlatformLayer* PluginProxy::pluginLayer()
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];
......
......@@ -56,12 +56,12 @@ static uint64_t generatePluginInstanceID()
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 @@ PluginProxy::PluginProxy(const String& pluginPath, PluginProcess::Type processTy
, m_remoteLayerClientID(0)
, m_waitingOnAsynchronousInitialization(false)
, m_processType(processType)
, m_isRestartedProcess(isRestartedProcess)
{
}
......
......@@ -56,7 +56,7 @@ struct PluginCreationParameters;
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 @@ public:
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 @@ private:
#endif
PluginProcess::Type m_processType;
bool m_isRestartedProcess;
};
} // namespace WebKit
......
......@@ -559,12 +559,9 @@ PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* plu
#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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment