Title: [234529] trunk/Source/WebKit
Revision
234529
Author
[email protected]
Date
2018-08-02 17:24:13 -0700 (Thu, 02 Aug 2018)

Log Message

Regression(r234486): assertion hit in ~CallbackAggregator()
https://bugs.webkit.org/show_bug.cgi?id=188283
<rdar://problem/42851342>

Reviewed by Alex Christensen.

[NSHTTPCookieStorage _saveCookies:] SPI may call its completion block on the background queue
so we need to make sure we dispatch back to the main thread before calling our completion
handler.

* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::saveCookies):
(WebKit::NetworkProcess::platformSyncAllCookies):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (234528 => 234529)


--- trunk/Source/WebKit/ChangeLog	2018-08-03 00:14:11 UTC (rev 234528)
+++ trunk/Source/WebKit/ChangeLog	2018-08-03 00:24:13 UTC (rev 234529)
@@ -1,3 +1,19 @@
+2018-08-02  Chris Dumez  <[email protected]>
+
+        Regression(r234486): assertion hit in ~CallbackAggregator()
+        https://bugs.webkit.org/show_bug.cgi?id=188283
+        <rdar://problem/42851342>
+
+        Reviewed by Alex Christensen.
+
+        [NSHTTPCookieStorage _saveCookies:] SPI may call its completion block on the background queue
+        so we need to make sure we dispatch back to the main thread before calling our completion
+        handler.
+
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::saveCookies):
+        (WebKit::NetworkProcess::platformSyncAllCookies):
+
 2018-08-02  Alex Christensen  <[email protected]>
 
         Fix some builds after r234516

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (234528 => 234529)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2018-08-03 00:14:11 UTC (rev 234528)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2018-08-03 00:24:13 UTC (rev 234529)
@@ -212,6 +212,19 @@
     });
 }
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
+static void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
+{
+    ASSERT(RunLoop::isMain());
+    [cookieStorage _saveCookies:BlockPtr<void()>::fromCallable([completionHandler = WTFMove(completionHandler)]() mutable {
+        // CFNetwork may call the completion block on a background queue, so we need to redispatch to the main thread.
+        RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() mutable {
+            completionHandler();
+        });
+    }).get()];
+}
+#endif
+
 void NetworkProcess::platformSyncAllCookies(CompletionHandler<void()>&& completionHander) {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
 #pragma clang diagnostic push
@@ -220,7 +233,7 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
     RefPtr<CallbackAggregator> callbackAggregator = CallbackAggregator::create(WTFMove(completionHander));
     WebCore::NetworkStorageSession::forEach([&] (auto& networkStorageSession) {
-        [networkStorageSession.nsCookieStorage() _saveCookies:[callbackAggregator] { }];
+        saveCookies(networkStorageSession.nsCookieStorage(), [callbackAggregator] { });
     });
 #else
     _CFHTTPCookieStorageFlushCookieStores();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to