Title: [287907] trunk
Revision
287907
Author
[email protected]
Date
2022-01-11 20:01:30 -0800 (Tue, 11 Jan 2022)

Log Message

WebPageProxy destruction should not launch a network process
https://bugs.webkit.org/show_bug.cgi?id=235086

Reviewed by Alex Christensen.

Source/WebKit:

Inspired by a backtrace in rdar://86706412.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy): No need to message the network
process requesting our removal if it doesn't exist.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
(TEST): Include WebView destruction in the test. Also do a little
run loop spinning, to give the test a better chance of failing when
async behavior does launch the Network process.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (287906 => 287907)


--- trunk/Source/WebKit/ChangeLog	2022-01-12 02:14:34 UTC (rev 287906)
+++ trunk/Source/WebKit/ChangeLog	2022-01-12 04:01:30 UTC (rev 287907)
@@ -1,3 +1,16 @@
+2022-01-11  Geoffrey Garen  <[email protected]>
+
+        WebPageProxy destruction should not launch a network process
+        https://bugs.webkit.org/show_bug.cgi?id=235086
+
+        Reviewed by Alex Christensen.
+
+        Inspired by a backtrace in rdar://86706412.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::~WebPageProxy): No need to message the network
+        process requesting our removal if it doesn't exist.
+
 2022-01-11  Alex Christensen  <[email protected]>
 
         Remove references to moved/deleted files in WebKit.xcodeproj

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (287906 => 287907)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-01-12 02:14:34 UTC (rev 287906)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-01-12 04:01:30 UTC (rev 287907)
@@ -606,7 +606,8 @@
     for (auto& callback : m_nextActivityStateChangeCallbacks)
         callback();
 
-    websiteDataStore().networkProcess().send(Messages::NetworkProcess::RemoveWebPageNetworkParameters(sessionID(), m_identifier), 0);
+    if (auto* networkProcess = websiteDataStore().networkProcessIfExists())
+        networkProcess->send(Messages::NetworkProcess::RemoveWebPageNetworkParameters(sessionID(), m_identifier), 0);
 
 #if ENABLE(MEDIA_SESSION_COORDINATOR) && HAVE(GROUP_ACTIVITIES)
     if (m_preferences->mediaSessionCoordinatorEnabled())

Modified: trunk/Tools/ChangeLog (287906 => 287907)


--- trunk/Tools/ChangeLog	2022-01-12 02:14:34 UTC (rev 287906)
+++ trunk/Tools/ChangeLog	2022-01-12 04:01:30 UTC (rev 287907)
@@ -1,3 +1,15 @@
+2022-01-11  Geoffrey Garen  <[email protected]>
+
+        WebPageProxy destruction should not launch a network process
+        https://bugs.webkit.org/show_bug.cgi?id=235086
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
+        (TEST): Include WebView destruction in the test. Also do a little
+        run loop spinning, to give the test a better chance of failing when
+        async behavior does launch the Network process.
+
 2022-01-11  Carlos Garcia Campos  <[email protected]>
 
         [GTK][a11y] Web process crashes in some sites having SVG images

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm (287906 => 287907)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm	2022-01-12 02:14:34 UTC (rev 287906)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm	2022-01-12 04:01:30 UTC (rev 287907)
@@ -87,11 +87,18 @@
 
 TEST(NetworkProcess, LaunchOnlyWhenNecessary)
 {
-    auto webView = adoptNS([WKWebView new]);
-    [webView configuration].websiteDataStore._resourceLoadStatisticsEnabled = YES;
-    [[webView configuration].processPool _registerURLSchemeAsSecure:@"test"];
-    [[webView configuration].processPool _registerURLSchemeAsBypassingContentSecurityPolicy:@"test"];
-    EXPECT_FALSE([[webView configuration].websiteDataStore _networkProcessExists]);
+    RetainPtr<WKWebsiteDataStore> websiteDataStore;
+
+    @autoreleasepool {
+        auto webView = adoptNS([WKWebView new]);
+        websiteDataStore = adoptNS([webView configuration].websiteDataStore);
+        [websiteDataStore _setResourceLoadStatisticsEnabled:YES];
+        [[webView configuration].processPool _registerURLSchemeAsSecure:@"test"];
+        [[webView configuration].processPool _registerURLSchemeAsBypassingContentSecurityPolicy:@"test"];
+    }
+
+    TestWebKitAPI::Util::spinRunLoop(10);
+    EXPECT_FALSE([websiteDataStore _networkProcessExists]);
 }
 
 TEST(NetworkProcess, CrashWhenNotAssociatedWithDataStore)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to