Source/WebKit2/ChangeLog

 12013-10-08 Anders Carlsson <andersca@apple.com>
 2
 3 WebProcess crash on SAP WebCycle web app
 4 https://bugs.webkit.org/show_bug.cgi?id=122520
 5 <rdar://problem/15030605>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 Stop trying to use RunLoop to manage the top-level run loop and just have the child process and their
 10 delegate subclasses start and stop the run loops. This fixes a bug with showModalDialog where we would
 11 unintentionally call -[NSApp stop] when closing a modal dialog.
 12
 13 This also lets us move all knowledge of NSApplication from RunLoop. (Both the web process and plug-in process
 14 need to use -[NSApp run] and -[NSApp stop:]).
 15
 16 * PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm:
 17 (WebKit::PluginProcessMainDelegate::doPreInitializationWork):
 18 Remove call to RunLoop::setUseApplicationRunLoopOnMainRunLoop. Add a startRunLoop override that calls
 19 -[NSApp run].
 20
 21 * PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
 22 (PluginServiceInitializer):
 23 Remove call to RunLoop::setUseApplicationRunLoopOnMainRunLoop.
 24
 25 * PluginProcess/PluginProcess.h:
 26 Add stopRunLoop() override on Mac.
 27
 28 * PluginProcess/mac/PluginProcessMac.mm:
 29 (WebKit::PluginProcess::stopRunLoop):
 30 Call -[NSApp stop:] and tickle the event system.
 31
 32 * Shared/ChildProcess.cpp:
 33 (WebKit::ChildProcess::stopRunLoop):
 34 Add default implementation that just calls RunLoop::main()->stop().
 35
 36 (WebKit::ChildProcess::terminate):
 37 Call stopRunLoop().
 38
 39 * Shared/ChildProcess.h:
 40 * Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.h:
 41 Add startRunLoop member function and call it instead of RunLoop::run().
 42
 43 * Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.mm:
 44 (WebKit::ChildProcessMainDelegate::startRunLoop):
 45 Call RunLoop::run().
 46
 47 * WebProcess/EntryPoint/mac/LegacyProcess/WebContentProcessMain.mm:
 48 (WebKit::WebContentProcessMainDelegate::doPreInitializationWork):
 49 Remove call to RunLoop::setUseApplicationRunLoopOnMainRunLoop.
 50 Add startRunLoop override that calls -[NSApp run].
 51
 52 * WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
 53 (WebContentServiceInitializer):
 54 Remove call to RunLoop::setUseApplicationRunLoopOnMainRunLoop.
 55
 56 * WebProcess/WebProcess.cpp:
 57 (WebKit::WebProcess::didClose):
 58 Call stopRunLoop().
 59
 60 * WebProcess/WebProcess.h:
 61 Add stopRunLoop override.
 62
 63 * WebProcess/mac/WebProcessMac.mm:
 64 (WebKit::WebProcess::stopRunLoop):
 65 Call -[NSApp stop:] and tickle the event system.
 66
1672013-10-08 Commit Queue <commit-queue@webkit.org>
268
369 Unreviewed, rolling out r157090.

Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm

@@public:
5858 EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
5959
6060#if USE(APPKIT)
61  RunLoop::setUseApplicationRunLoopOnMainRunLoop();
62 
6361 // Initialize AppKit.
6462 [NSApplication sharedApplication];
6563

@@public:
9492 return true;
9593 }
9694
 95 virtual void startRunLoop() OVERRIDE
 96 {
 97 ASSERT(NSApp);
 98 [NSApp run];
 99 }
 100
97101 virtual void doPostRunWork()
98102 {
99103#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080

Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm

@@void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initiali
7373 // Remove the PluginProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes
7474 // spawned by the PluginProcess don't try to insert the shim and crash.
7575 EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
76  RunLoop::setUseApplicationRunLoopOnMainRunLoop();
7776
7877 XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(connection, initializerMessage);
7978}

Source/WebKit2/PluginProcess/PluginProcess.h

@@private:
7474 virtual bool shouldTerminate() OVERRIDE;
7575 void platformInitializeProcess(const ChildProcessInitializationParameters&);
7676
 77#if PLATFORM(MAC)
 78 virtual void stopRunLoop() OVERRIDE;
 79#endif
 80
7781 // CoreIPC::Connection::Client
7882 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
7983 virtual void didClose(CoreIPC::Connection*) OVERRIDE;

Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm

@@void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters
493493 ChildProcess::initializeSandbox(parameters, sandboxParameters);
494494}
495495
 496
 497void PluginProcess::stopRunLoop()
 498{
 499 ASSERT([NSApp isRunning]);
 500 [NSApp stop:nil];
 501 NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
 502 location:NSMakePoint(0, 0)
 503 modifierFlags:0
 504 timestamp:0.0
 505 windowNumber:0
 506 context:nil
 507 subtype: 0
 508 data1:0
 509 data2:0];
 510 [NSApp postEvent:event atStart:true];
 511}
 512
496513} // namespace WebKit
497514
498515#endif // ENABLE(NETSCAPE_PLUGIN_API)

Source/WebKit2/Shared/ChildProcess.cpp

@@void ChildProcess::terminationTimerFired()
149149 terminate();
150150}
151151
 152void ChildProcess::stopRunLoop()
 153{
 154 RunLoop::main()->stop();
 155}
 156
152157void ChildProcess::terminate()
153158{
154159 m_connection->invalidate();
155160
156  RunLoop::main()->stop();
 161 stopRunLoop();
157162}
158163
159164#if !PLATFORM(MAC)

Source/WebKit2/Shared/ChildProcess.h

@@protected:
9191 virtual bool shouldTerminate() = 0;
9292 virtual void terminate();
9393
 94 virtual void stopRunLoop();
 95
9496private:
9597 // CoreIPC::MessageSender
9698 virtual CoreIPC::Connection* messageSenderConnection() OVERRIDE;

Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.h

@@public:
5252 virtual bool getClientProcessName(String& clientProcessName);
5353 virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData);
5454
 55 virtual void startRunLoop();
5556 virtual void doPostRunWork();
5657
5758protected:

@@int ChildProcessMain(int argc, char** argv)
8990 ChildProcessType::shared().initialize(parameters);
9091 }
9192
92  WebCore::RunLoop::run();
 93 delegate.startRunLoop();
9394
9495 @autoreleasepool {
9596 delegate.doPostRunWork();

Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.mm

3434
3535#define SHOW_CRASH_REPORTER 1
3636
 37using namespace WebCore;
 38
3739namespace WebKit {
3840
3941ChildProcessMainDelegate::~ChildProcessMainDelegate()

@@bool ChildProcessMainDelegate::getExtraInitializationData(HashMap<String, String
9395 return true;
9496}
9597
 98void ChildProcessMainDelegate::startRunLoop()
 99{
 100 RunLoop::run();
 101}
 102
96103void ChildProcessMainDelegate::doPostRunWork()
97104{
98105}

Source/WebKit2/WebProcess/EntryPoint/mac/LegacyProcess/WebContentProcessMain.mm

@@public:
6666 EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/WebProcessShim.dylib");
6767
6868#if USE(APPKIT)
69  RunLoop::setUseApplicationRunLoopOnMainRunLoop();
70 
7169 // Initialize AppKit.
7270 [NSApplication sharedApplication];
7371

@@public:
166164 return false;
167165 return true;
168166 }
 167
 168 virtual void startRunLoop() OVERRIDE
 169 {
 170 ASSERT(NSApp);
 171 [NSApp run];
 172 }
169173};
170174
171175} // namespace WebKit

Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm

@@void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t init
4444 // the this process don't try to insert the shim and crash.
4545 EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/WebProcessShim.dylib");
4646
47  RunLoop::setUseApplicationRunLoopOnMainRunLoop();
48 
4947 XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(connection, initializerMessage);
5048}
5149

Source/WebKit2/WebProcess/WebProcess.cpp

@@void WebProcess::didClose(CoreIPC::Connection*)
668668#endif
669669
670670 // The UI process closed this connection, shut down.
671  RunLoop::main()->stop();
 671 stopRunLoop();
672672}
673673
674674void WebProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference, CoreIPC::StringReference)

Source/WebKit2/WebProcess/WebProcess.h

@@private:
228228 virtual bool shouldTerminate() OVERRIDE;
229229 virtual void terminate() OVERRIDE;
230230
 231#if PLATFORM(MAC)
 232 virtual void stopRunLoop() OVERRIDE;
 233#endif
 234
231235 void platformInitializeProcess(const ChildProcessInitializationParameters&);
232236
233237 // CoreIPC::Connection::Client

Source/WebKit2/WebProcess/mac/WebProcessMac.mm

@@void WebProcess::platformInitializeProcess(const ChildProcessInitializationParam
208208#endif
209209}
210210
 211void WebProcess::stopRunLoop()
 212{
 213 ASSERT([NSApp isRunning]);
 214 [NSApp stop:nil];
 215 NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
 216 location:NSMakePoint(0, 0)
 217 modifierFlags:0
 218 timestamp:0.0
 219 windowNumber:0
 220 context:nil
 221 subtype: 0
 222 data1:0
 223 data2:0];
 224 [NSApp postEvent:event atStart:true];
 225}
 226
211227void WebProcess::platformTerminate()
212228{
213229 if (m_clearResourceCachesDispatchGroup) {