Changeset 264613 in webkit


Ignore:
Timestamp:
Jul 20, 2020 1:12:44 PM (4 years ago)
Author:
commit-queue@webkit.org
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 <achristensen@webkit.org> 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:
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r264602 r264613  
     12020-07-20  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r263551) Main thread often hangs while saving cookies
     4        https://bugs.webkit.org/show_bug.cgi?id=214564
     5        <rdar://problem/65779712>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        I had assumed that CFNetwork wouldn't write cookies on the main thread, but I was wrong.
     10        That change caused spins, so let's just do the work on the WebsiteDataStore's queue instead.
     11
     12        * UIProcess/API/APIHTTPCookieStore.h:
     13        * UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm:
     14        (API::HTTPCookieStore::flushDefaultUIProcessCookieStore):
     15        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     16        (WebKit::WebsiteDataStore::dispatchOnQueue):
     17        * UIProcess/WebsiteData/WebsiteDataStore.h:
     18
    1192020-07-20  David Kilzer  <ddkilzer@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/API/APIHTTPCookieStore.h

    r263551 r264613  
    8686    void unregisterForNewProcessPoolNotifications();
    8787
    88     static void flushDefaultUIProcessCookieStore(CompletionHandler<void()>&&);
     88    void flushDefaultUIProcessCookieStore(CompletionHandler<void()>&&);
    8989    static Vector<WebCore::Cookie> getAllDefaultUIProcessCookieStoreCookies();
    9090    static void setCookieInDefaultUIProcessCookieStore(const WebCore::Cookie&);
  • trunk/Source/WebKit/UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm

    r263551 r264613  
    2727#import "APIHTTPCookieStore.h"
    2828
     29#import "WebsiteDataStore.h"
    2930#import <WebCore/Cookie.h>
    3031#import <WebCore/CookieStorageObserver.h>
     
    4041#if HAVE(FOUNDATION_WITH_SAVE_COOKIES_WITH_COMPLETION_HANDLER)
    4142    ASSERT(RunLoop::isMain());
    42     [[NSHTTPCookieStorage sharedHTTPCookieStorage] _saveCookies:makeBlockPtr([completionHandler = WTFMove(completionHandler)]() mutable {
    43         // CFNetwork may call the completion block on a background queue, so we need to redispatch to the main thread.
    44         RunLoop::main().dispatch(WTFMove(completionHandler));
    45     }).get()];
     43    m_owningDataStore->dispatchOnQueue([completionHandler = WTFMove(completionHandler)] () mutable {
     44        [[NSHTTPCookieStorage sharedHTTPCookieStorage] _saveCookies:makeBlockPtr([completionHandler = WTFMove(completionHandler)]() mutable {
     45            RunLoop::main().dispatch(WTFMove(completionHandler));
     46        }).get()];
     47    });
    4648#else
    4749    [[NSHTTPCookieStorage sharedHTTPCookieStorage] _saveCookies];
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r264356 r264613  
    22222222}
    22232223
     2224void WebsiteDataStore::dispatchOnQueue(Function<void()>&& function)
     2225{
     2226    m_queue->dispatch(WTFMove(function));
     2227}
     2228
    22242229uint64_t WebsiteDataStore::perThirdPartyOriginStorageQuota() const
    22252230{
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r264356 r264613  
    237237    void clearPendingCookies();
    238238
     239    void dispatchOnQueue(Function<void()>&&);
     240
    239241#if USE(CURL)
    240242    void setNetworkProxySettings(WebCore::CurlProxySettings&&);
Note: See TracChangeset for help on using the changeset viewer.