Title: [228569] trunk
Revision
228569
Author
[email protected]
Date
2018-02-16 11:38:13 -0800 (Fri, 16 Feb 2018)

Log Message

Implement stopping of run loop in the WebContent process when using NSRunLoop.
https://bugs.webkit.org/show_bug.cgi?id=182499
<rdar://problem/37247424>

Reviewed by Brent Fulgham.

Source/WebKit:

Add the method ChildProcess::stopNSRunLoop to end the WebContent process by executing a block
with 'exit(0)' on the main run loop.

* Shared/ChildProcess.h:
* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::stopNSRunLoop):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
(WebKit::WebProcess::stopRunLoop):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/WebProcessTerminate.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (228568 => 228569)


--- trunk/Source/WebKit/ChangeLog	2018-02-16 19:35:52 UTC (rev 228568)
+++ trunk/Source/WebKit/ChangeLog	2018-02-16 19:38:13 UTC (rev 228569)
@@ -1,3 +1,21 @@
+2018-02-16  Per Arne Vollan  <[email protected]>
+
+        Implement stopping of run loop in the WebContent process when using NSRunLoop.
+        https://bugs.webkit.org/show_bug.cgi?id=182499
+        <rdar://problem/37247424>
+
+        Reviewed by Brent Fulgham.
+
+        Add the method ChildProcess::stopNSRunLoop to end the WebContent process by executing a block
+        with 'exit(0)' on the main run loop. 
+
+        * Shared/ChildProcess.h:
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::stopNSRunLoop):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        (WebKit::WebProcess::stopRunLoop):
+
 2018-02-16  Yousuke Kimoto  <[email protected]>
 
         [WinCario] Add NetworkSessionCurl

Modified: trunk/Source/WebKit/Shared/ChildProcess.h (228568 => 228569)


--- trunk/Source/WebKit/Shared/ChildProcess.h	2018-02-16 19:35:52 UTC (rev 228568)
+++ trunk/Source/WebKit/Shared/ChildProcess.h	2018-02-16 19:38:13 UTC (rev 228569)
@@ -103,6 +103,10 @@
 #if USE(APPKIT)
     static void stopNSAppRunLoop();
 #endif
+    
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+    static void stopNSRunLoop();
+#endif
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 

Modified: trunk/Source/WebKit/Shared/mac/ChildProcessMac.mm (228568 => 228569)


--- trunk/Source/WebKit/Shared/mac/ChildProcessMac.mm	2018-02-16 19:35:52 UTC (rev 228568)
+++ trunk/Source/WebKit/Shared/mac/ChildProcessMac.mm	2018-02-16 19:38:13 UTC (rev 228569)
@@ -219,6 +219,16 @@
 }
 #endif
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+void ChildProcess::stopNSRunLoop()
+{
+    ASSERT([NSRunLoop mainRunLoop]);
+    [[NSRunLoop mainRunLoop] performBlock:^{
+        exit(0);
+    }];
+}
+#endif
+
 void ChildProcess::setQOS(int latencyQOS, int throughputQOS)
 {
     if (!latencyQOS && !throughputQOS)

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (228568 => 228569)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-02-16 19:35:52 UTC (rev 228568)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-02-16 19:38:13 UTC (rev 228569)
@@ -177,7 +177,7 @@
     [NSApplication sharedApplication];
     [NSApplication _accessibilityInitialize];
 #endif
-    
+
     _CFNetworkSetATSContext(parameters.networkATSContext.get());
 
 #if TARGET_OS_IPHONE
@@ -315,7 +315,11 @@
 #if USE(APPKIT)
 void WebProcess::stopRunLoop()
 {
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+    ChildProcess::stopNSRunLoop();
+#else
     ChildProcess::stopNSAppRunLoop();
+#endif
 }
 #endif
 

Modified: trunk/Tools/ChangeLog (228568 => 228569)


--- trunk/Tools/ChangeLog	2018-02-16 19:35:52 UTC (rev 228568)
+++ trunk/Tools/ChangeLog	2018-02-16 19:38:13 UTC (rev 228569)
@@ -1,3 +1,15 @@
+2018-02-16  Per Arne Vollan  <[email protected]>
+
+        Implement stopping of run loop in the WebContent process when using NSRunLoop.
+        https://bugs.webkit.org/show_bug.cgi?id=182499
+        <rdar://problem/37247424>
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/WebProcessTerminate.mm: Added.
+        (TEST):
+
 2018-02-15  Alexey Proskuryakov  <[email protected]>
 
         Speed up dSYM generation on build.webkit.org with -gline-tables-only

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (228568 => 228569)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-02-16 19:35:52 UTC (rev 228568)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2018-02-16 19:38:13 UTC (rev 228569)
@@ -1753,6 +1753,7 @@
 		C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
 		C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; };
 		C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
+		C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; };
 		C25CCA051E51380B0026CB8A /* LineBreaking.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LineBreaking.mm; path = ../WebCore/LineBreaking.mm; sourceTree = "<group>"; };
 		C25CCA0A1E513F490026CB8A /* LineBreaking.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LineBreaking.html; sourceTree = "<group>"; };
 		C25CCA0C1E5140E50026CB8A /* AllAhem.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AllAhem.svg; sourceTree = "<group>"; };
@@ -2179,6 +2180,7 @@
 				83779C371F82FEB0007CDA8A /* VisitedLinkStore.mm */,
 				5C973F5B1F58EF0A00359C27 /* WebGLPolicy.mm */,
 				51714EB61CF8C7A4004723C4 /* WebProcessKillIDBCleanup.mm */,
+				C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */,
 				5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */,
 				5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */,
 				2E5C77061FA70136005932C3 /* WKAttachmentTests.mm */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebProcessTerminate.mm (0 => 228569)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebProcessTerminate.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebProcessTerminate.mm	2018-02-16 19:38:13 UTC (rev 228569)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WebKit.h>
+
+#if WK_API_ENABLED
+
+TEST(WebKit, WebProcessTerminate)
+{
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    auto pid = [webView _webProcessIdentifier];
+    [webView _killWebContentProcessAndResetState];
+
+    [webView loadHTMLString:@"test" baseURL:nil];
+    [webView _test_waitForDidFinishNavigation];
+
+    auto pid2 = [webView _webProcessIdentifier];
+    EXPECT_TRUE(pid != pid2);
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to