- Revision
- 140230
- Author
- [email protected]
- Date
- 2013-01-18 18:54:08 -0800 (Fri, 18 Jan 2013)
Log Message
Don't initialize AppKit for processes that don't use it
https://bugs.webkit.org/show_bug.cgi?id=107216
Reviewed by Alexey Proskuryakov.
* PluginProcess/mac/PluginProcessMainMac.mm:
(WebKit::PluginProcessMainDelegate::doPreInitializationWork):
* WebProcess/mac/WebProcessMainMac.mm:
(WebKit::WebProcessMainDelegate::doPreInitializationWork):
Move AppKit initialization to the two places it is used, the WebProcessMain and the PluginProcessMain.
* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::initialize):
Remove redundant call to InitializeWebKit2().
* Shared/mac/ChildProcessMain.h:
(WebKit::ChildProcessMain):
Remove initialization of AppKit now that the delegate does it if necessary,
and move InitializeWebKit2() to after delegate.doPreInitializationWork(), so
the delegate has a chance to set things up it, in this case, calling
RunLoop::setUseApplicationRunLoopOnMainRunLoop if needed.
* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::PluginProcess::platformInitializePluginProcess):
* WebProcess/mac/WebProcessMac.mm:
(WebKit::WebProcess::platformInitializeProcess):
Remove now redundant call to RunLoop::setUseApplicationRunLoopOnMainRunLoop().
* WebProcess/mac/WebProcessServiceEntryPoints.mm:
(WebKit::WebProcessServiceEventHandler):
(webProcessServiceMain):
(initializeWebProcessForWebProcessServiceForWebKitDevelopment):
Call WebCore::RunLoop::setUseApplicationRunLoopOnMainRunLoop() and make call to InitializeWebKit2()
more consistent.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (140229 => 140230)
--- trunk/Source/WebKit2/ChangeLog 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/ChangeLog 2013-01-19 02:54:08 UTC (rev 140230)
@@ -1,3 +1,40 @@
+2013-01-17 Sam Weinig <[email protected]>
+
+ Don't initialize AppKit for processes that don't use it
+ https://bugs.webkit.org/show_bug.cgi?id=107216
+
+ Reviewed by Alexey Proskuryakov.
+
+ * PluginProcess/mac/PluginProcessMainMac.mm:
+ (WebKit::PluginProcessMainDelegate::doPreInitializationWork):
+ * WebProcess/mac/WebProcessMainMac.mm:
+ (WebKit::WebProcessMainDelegate::doPreInitializationWork):
+ Move AppKit initialization to the two places it is used, the WebProcessMain and the PluginProcessMain.
+
+ * Shared/ChildProcess.cpp:
+ (WebKit::ChildProcess::initialize):
+ Remove redundant call to InitializeWebKit2().
+
+ * Shared/mac/ChildProcessMain.h:
+ (WebKit::ChildProcessMain):
+ Remove initialization of AppKit now that the delegate does it if necessary,
+ and move InitializeWebKit2() to after delegate.doPreInitializationWork(), so
+ the delegate has a chance to set things up it, in this case, calling
+ RunLoop::setUseApplicationRunLoopOnMainRunLoop if needed.
+
+ * PluginProcess/mac/PluginProcessMac.mm:
+ (WebKit::PluginProcess::platformInitializePluginProcess):
+ * WebProcess/mac/WebProcessMac.mm:
+ (WebKit::WebProcess::platformInitializeProcess):
+ Remove now redundant call to RunLoop::setUseApplicationRunLoopOnMainRunLoop().
+
+ * WebProcess/mac/WebProcessServiceEntryPoints.mm:
+ (WebKit::WebProcessServiceEventHandler):
+ (webProcessServiceMain):
+ (initializeWebProcessForWebProcessServiceForWebKitDevelopment):
+ Call WebCore::RunLoop::setUseApplicationRunLoopOnMainRunLoop() and make call to InitializeWebKit2()
+ more consistent.
+
2013-01-18 Tim Horton <[email protected]>
[wk2] Intrinsic content size should report a flexible width if the content is not wider than the minimum layout width
Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm (140229 => 140230)
--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm 2013-01-19 02:54:08 UTC (rev 140230)
@@ -32,7 +32,16 @@
#import "EnvironmentUtilities.h"
#import "NetscapePluginModule.h"
#import "PluginProcess.h"
+#import <WebCore/RunLoop.h>
+#if USE(APPKIT)
+@interface NSApplication (WebNSApplicationDetails)
+-(void)_installAutoreleasePoolsOnCurrentThreadIfNecessary;
+@end
+#endif
+
+using namespace WebCore;
+
namespace WebKit {
class PluginProcessMainDelegate : public ChildProcessMainDelegate {
@@ -48,9 +57,23 @@
// spawned by the PluginProcess don't try to insert the shim and crash.
EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
+#if USE(APPKIT)
+ RunLoop::setUseApplicationRunLoopOnMainRunLoop();
+
+ // Initialize AppKit.
+ [NSApplication sharedApplication];
+
+ // Installs autorelease pools on the current runloop which prevents memory from accumulating between user events.
+ // FIXME: Remove when <rdar://problem/8929426> is fixed.
+ [NSApp _installAutoreleasePoolsOnCurrentThreadIfNecessary];
+#endif
+
// Check if we're being spawned to write a MIME type preferences file.
String pluginPath = m_commandLine["createPluginMIMETypesPreferences"];
if (!pluginPath.isEmpty()) {
+ // We are never going to get to the actual initialization, so initialize WebKit2 now.
+ InitializeWebKit2();
+
if (!NetscapePluginModule::createPluginMIMETypesPreferences(pluginPath))
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (140229 => 140230)
--- trunk/Source/WebKit2/Shared/ChildProcess.cpp 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp 2013-01-19 02:54:08 UTC (rev 140230)
@@ -66,8 +66,6 @@
void ChildProcess::initialize(const ChildProcessInitializationParameters& parameters)
{
- InitializeWebKit2();
-
platformInitialize();
initializeProcess(parameters);
Modified: trunk/Source/WebKit2/Shared/mac/ChildProcessMain.h (140229 => 140230)
--- trunk/Source/WebKit2/Shared/mac/ChildProcessMain.h 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/Shared/mac/ChildProcessMain.h 2013-01-19 02:54:08 UTC (rev 140230)
@@ -33,12 +33,6 @@
#import <WebKitSystemInterface.h>
#import <sysexits.h>
-#if USE(APPKIT)
-@interface NSApplication (WebNSApplicationDetails)
--(void)_installAutoreleasePoolsOnCurrentThreadIfNecessary;
-@end
-#endif
-
namespace WebKit {
class ChildProcessMainDelegate {
@@ -69,11 +63,11 @@
ChildProcessMainDelegateType delegate(commandLine);
@autoreleasepool {
- InitializeWebKit2();
-
delegate.installSignalHandlers();
delegate.doPreInitializationWork();
+ InitializeWebKit2();
+
ChildProcessInitializationParameters parameters;
if (!delegate.getConnectionIdentifier(parameters.connectionIdentifier))
return EXIT_FAILURE;
@@ -90,16 +84,6 @@
if (cfLocalization)
WKSetDefaultLocalization(cfLocalization.get());
-#if USE(APPKIT)
- // FIXME: We should not need to use AppKit in every process, but right now, WebCore::RunLoop depends
- // on the outer most runloop being an AppKit runloop.
- [NSApplication sharedApplication];
-
- // Installs autorelease pools on the current CFRunLoop which prevents memory from accumulating between user events.
- // FIXME: Remove when <rdar://problem/8929426> is fixed.
- [[NSApplication sharedApplication] _installAutoreleasePoolsOnCurrentThreadIfNecessary];
-#endif
-
ChildProcessType::shared().initialize(parameters);
}
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm (140229 => 140230)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm 2013-01-19 02:54:08 UTC (rev 140230)
@@ -305,8 +305,6 @@
void WebProcess::platformInitializeProcess(const ChildProcessInitializationParameters&)
{
- RunLoop::setUseApplicationRunLoopOnMainRunLoop();
-
WKAXRegisterRemoteApp();
#if USE(SECURITY_FRAMEWORK)
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm (140229 => 140230)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMainMac.mm 2013-01-19 02:54:08 UTC (rev 140230)
@@ -26,12 +26,13 @@
#import "config.h"
#import "WebProcessMain.h"
+#import "ChildProcessMain.h"
#import "CommandLine.h"
-#import "ChildProcessMain.h"
#import "EnvironmentUtilities.h"
#import "EnvironmentVariables.h"
#import "StringUtilities.h"
#import "WebProcess.h"
+#import <WebCore/RunLoop.h>
#import <mach/mach_error.h>
#import <servers/bootstrap.h>
#import <spawn.h>
@@ -40,8 +41,16 @@
#import <wtf/text/CString.h>
#import <wtf/text/WTFString.h>
+#if USE(APPKIT)
+@interface NSApplication (WebNSApplicationDetails)
+-(void)_installAutoreleasePoolsOnCurrentThreadIfNecessary;
+@end
+#endif
+
extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, uint64_t);
+using namespace WebCore;
+
namespace WebKit {
class WebProcessMainDelegate : public ChildProcessMainDelegate {
@@ -56,6 +65,17 @@
// Remove the WebProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
// the WebProcess don't try to insert the shim and crash.
EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
+
+#if USE(APPKIT)
+ RunLoop::setUseApplicationRunLoopOnMainRunLoop();
+
+ // Initialize AppKit.
+ [NSApplication sharedApplication];
+
+ // Installs autorelease pools on the current runloop which prevents memory from accumulating between user events.
+ // FIXME: Remove when <rdar://problem/8929426> is fixed.
+ [NSApp _installAutoreleasePoolsOnCurrentThreadIfNecessary];
+#endif
}
virtual bool getConnectionIdentifier(CoreIPC::Connection::Identifier& identifier)
Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.mm (140229 => 140230)
--- trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.mm 2013-01-19 02:22:41 UTC (rev 140229)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessServiceEntryPoints.mm 2013-01-19 02:54:08 UTC (rev 140230)
@@ -31,6 +31,7 @@
#import "EnvironmentUtilities.h"
#import "WebKit2Initialize.h"
#import "WebProcess.h"
+#import <WebCore/RunLoop.h>
#import <stdio.h>
#import <stdlib.h>
#import <xpc/xpc.h>
@@ -58,8 +59,6 @@
xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply);
xpc_release(reply);
- InitializeWebKit2();
-
ChildProcessInitializationParameters parameters;
parameters.uiProcessName = xpc_dictionary_get_string(event, "ui-process-name");
parameters.clientIdentifier = xpc_dictionary_get_string(event, "client-identifier");
@@ -75,13 +74,19 @@
} // namespace WebKit
+using namespace WebCore;
+using namespace WebKit;
+
int webProcessServiceMain(int argc, char** argv)
{
// Remove the WebProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
// the WebProcess don't try to insert the shim and crash.
- WebKit::EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
+ EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
- xpc_main(WebKit::WebProcessServiceEventHandler);
+ RunLoop::setUseApplicationRunLoopOnMainRunLoop();
+ InitializeWebKit2();
+
+ xpc_main(WebProcessServiceEventHandler);
return 0;
}
@@ -89,16 +94,17 @@
{
// Remove the WebProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
// the WebProcess don't try to insert the shim and crash.
- WebKit::EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
+ EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
- WebKit::InitializeWebKit2();
+ RunLoop::setUseApplicationRunLoopOnMainRunLoop();
+ InitializeWebKit2();
- WebKit::ChildProcessInitializationParameters parameters;
+ ChildProcessInitializationParameters parameters;
parameters.uiProcessName = uiProcessName;
parameters.clientIdentifier = clientIdentifier;
parameters.connectionIdentifier = CoreIPC::Connection::Identifier(serverPort, connection);
- WebKit::WebProcess::shared().initialize(parameters);
+ WebProcess::shared().initialize(parameters);
}
#endif // HAVE(XPC)