Title: [292403] trunk
Revision
292403
Author
[email protected]
Date
2022-04-05 10:58:46 -0700 (Tue, 05 Apr 2022)

Log Message

Do not create network process in ~WebsiteDataStore destructor
https://bugs.webkit.org/show_bug.cgi?id=238570

Reviewed by Chris Dumez.

Source/WebKit:

Check if m_networkProcess is initialized before removing session
from it instead, otherwise WebsiteDataStore::networkProcess() lazily
creates the process and it will keep running after WebsiteDataStore
is destroyed.

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::~WebsiteDataStore):

Tools:

The test is written by Chris Dumez.

* TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
(TEST): Test that creating and destroying ephemer WebsiteDataStore doesn't initialize
default network process.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (292402 => 292403)


--- trunk/Source/WebKit/ChangeLog	2022-04-05 17:57:55 UTC (rev 292402)
+++ trunk/Source/WebKit/ChangeLog	2022-04-05 17:58:46 UTC (rev 292403)
@@ -1,3 +1,18 @@
+2022-04-05  Yury Semikhatsky  <[email protected]>
+
+        Do not create network process in ~WebsiteDataStore destructor
+        https://bugs.webkit.org/show_bug.cgi?id=238570
+
+        Reviewed by Chris Dumez.
+
+        Check if m_networkProcess is initialized before removing session
+        from it instead, otherwise WebsiteDataStore::networkProcess() lazily
+        creates the process and it will keep running after WebsiteDataStore
+        is destroyed.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::~WebsiteDataStore):
+
 2022-04-05  Eric Carlson  <[email protected]>
 
         5 Media API tests are flakily timing out on iOS14

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (292402 => 292403)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-04-05 17:57:55 UTC (rev 292402)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2022-04-05 17:58:46 UTC (rev 292403)
@@ -150,7 +150,8 @@
 
     ASSERT(allDataStores().get(m_sessionID) == this);
     allDataStores().remove(m_sessionID);
-    networkProcess().removeSession(*this);
+    if (m_networkProcess)
+        m_networkProcess->removeSession(*this);
 #if ENABLE(GPU_PROCESS)
     if (auto* gpuProcessProxy = GPUProcessProxy::singletonIfCreated())
         gpuProcessProxy->removeSession(m_sessionID);

Modified: trunk/Tools/ChangeLog (292402 => 292403)


--- trunk/Tools/ChangeLog	2022-04-05 17:57:55 UTC (rev 292402)
+++ trunk/Tools/ChangeLog	2022-04-05 17:58:46 UTC (rev 292403)
@@ -1,3 +1,16 @@
+2022-04-05  Yury Semikhatsky  <[email protected]>
+
+        Do not create network process in ~WebsiteDataStore destructor
+        https://bugs.webkit.org/show_bug.cgi?id=238570
+
+        Reviewed by Chris Dumez.
+
+        The test is written by Chris Dumez.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
+        (TEST): Test that creating and destroying ephemer WebsiteDataStore doesn't initialize
+        default network process.
+
 2022-04-04  Jonathan Bedard  <[email protected]>
 
         [Merge-Queue] Add author to commit message

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm (292402 => 292403)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm	2022-04-05 17:57:55 UTC (rev 292402)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm	2022-04-05 17:58:46 UTC (rev 292403)
@@ -159,6 +159,21 @@
         TestWebKitAPI::Util::spinRunLoop();
 }
 
+TEST(NetworkProcess, DoNotLaunchOnDataStoreDestruction)
+{
+    auto storeConfiguration1 = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
+    auto websiteDataStore1 = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration: storeConfiguration1.get()]);
+
+    EXPECT_FALSE([WKWebsiteDataStore _defaultNetworkProcessExists]);
+    @autoreleasepool {
+        auto storeConfiguration2 = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
+        auto websiteDataStore2 = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration: storeConfiguration2.get()]);
+    }
+
+    TestWebKitAPI::Util::spinRunLoop(10);
+    EXPECT_FALSE([WKWebsiteDataStore _defaultNetworkProcessExists]);
+}
+
 TEST(NetworkProcess, CORSPreflightCachePartitioned)
 {
     using namespace TestWebKitAPI;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to