Title: [264613] trunk/Source/WebKit
- Revision
- 264613
- Author
- [email protected]
- Date
- 2020-07-20 13:12:44 -0700 (Mon, 20 Jul 2020)
Log Message
REGRESSION(r263551) Main thread often hangs while saving cookies
https://bugs.webkit.org/show_bug.cgi?id=214564
<rdar://problem/65779712>
Patch by Alex Christensen <[email protected]> on 2020-07-20
Reviewed by Geoffrey Garen.
I had assumed that CFNetwork wouldn't write cookies on the main thread, but I was wrong.
That change caused spins, so let's just do the work on the WebsiteDataStore's queue instead.
* UIProcess/API/APIHTTPCookieStore.h:
* UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm:
(API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::dispatchOnQueue):
* UIProcess/WebsiteData/WebsiteDataStore.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (264612 => 264613)
--- trunk/Source/WebKit/ChangeLog 2020-07-20 20:04:38 UTC (rev 264612)
+++ trunk/Source/WebKit/ChangeLog 2020-07-20 20:12:44 UTC (rev 264613)
@@ -1,3 +1,21 @@
+2020-07-20 Alex Christensen <[email protected]>
+
+ REGRESSION(r263551) Main thread often hangs while saving cookies
+ https://bugs.webkit.org/show_bug.cgi?id=214564
+ <rdar://problem/65779712>
+
+ Reviewed by Geoffrey Garen.
+
+ I had assumed that CFNetwork wouldn't write cookies on the main thread, but I was wrong.
+ That change caused spins, so let's just do the work on the WebsiteDataStore's queue instead.
+
+ * UIProcess/API/APIHTTPCookieStore.h:
+ * UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm:
+ (API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::dispatchOnQueue):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
2020-07-20 David Kilzer <[email protected]>
WebPageProxyIdentifier parameter of WebPageProxy::CreateNewPage() should not be Optional
Modified: trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.h (264612 => 264613)
--- trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.h 2020-07-20 20:04:38 UTC (rev 264612)
+++ trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.h 2020-07-20 20:12:44 UTC (rev 264613)
@@ -85,7 +85,7 @@
void registerForNewProcessPoolNotifications();
void unregisterForNewProcessPoolNotifications();
- static void flushDefaultUIProcessCookieStore(CompletionHandler<void()>&&);
+ void flushDefaultUIProcessCookieStore(CompletionHandler<void()>&&);
static Vector<WebCore::Cookie> getAllDefaultUIProcessCookieStoreCookies();
static void setCookieInDefaultUIProcessCookieStore(const WebCore::Cookie&);
static void deleteCookieFromDefaultUIProcessCookieStore(const WebCore::Cookie&);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm (264612 => 264613)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm 2020-07-20 20:04:38 UTC (rev 264612)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm 2020-07-20 20:12:44 UTC (rev 264613)
@@ -26,6 +26,7 @@
#import "config.h"
#import "APIHTTPCookieStore.h"
+#import "WebsiteDataStore.h"
#import <WebCore/Cookie.h>
#import <WebCore/CookieStorageObserver.h>
#import <WebCore/HTTPCookieAcceptPolicy.h>
@@ -39,10 +40,11 @@
{
#if HAVE(FOUNDATION_WITH_SAVE_COOKIES_WITH_COMPLETION_HANDLER)
ASSERT(RunLoop::isMain());
- [[NSHTTPCookieStorage sharedHTTPCookieStorage] _saveCookies:makeBlockPtr([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(WTFMove(completionHandler));
- }).get()];
+ m_owningDataStore->dispatchOnQueue([completionHandler = WTFMove(completionHandler)] () mutable {
+ [[NSHTTPCookieStorage sharedHTTPCookieStorage] _saveCookies:makeBlockPtr([completionHandler = WTFMove(completionHandler)]() mutable {
+ RunLoop::main().dispatch(WTFMove(completionHandler));
+ }).get()];
+ });
#else
[[NSHTTPCookieStorage sharedHTTPCookieStorage] _saveCookies];
RunLoop::main().dispatch(WTFMove(completionHandler));
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (264612 => 264613)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2020-07-20 20:04:38 UTC (rev 264612)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2020-07-20 20:12:44 UTC (rev 264613)
@@ -2221,6 +2221,11 @@
m_pendingCookies.clear();
}
+void WebsiteDataStore::dispatchOnQueue(Function<void()>&& function)
+{
+ m_queue->dispatch(WTFMove(function));
+}
+
uint64_t WebsiteDataStore::perThirdPartyOriginStorageQuota() const
{
// FIXME: Consider whether allowing to set a perThirdPartyOriginStorageQuota from a WebsiteDataStore.
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (264612 => 264613)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2020-07-20 20:04:38 UTC (rev 264612)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2020-07-20 20:12:44 UTC (rev 264613)
@@ -236,6 +236,8 @@
void removePendingCookie(const WebCore::Cookie&);
void clearPendingCookies();
+ void dispatchOnQueue(Function<void()>&&);
+
#if USE(CURL)
void setNetworkProxySettings(WebCore::CurlProxySettings&&);
const WebCore::CurlProxySettings& networkProxySettings() const { return m_proxySettings; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes