Bug 207593 - [WK2][Cocoa] Implement in-WebProcess cookie cache to avoid sync IPC for document.cookie in most cases
Summary: [WK2][Cocoa] Implement in-WebProcess cookie cache to avoid sync IPC for docum...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-11 15:46 PST by Chris Dumez
Modified: 2020-02-24 16:23 PST (History)
15 users (show)

See Also:


Attachments
WIP Patch (55.13 KB, patch)
2020-02-11 15:48 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (56.26 KB, patch)
2020-02-11 16:37 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (58.43 KB, patch)
2020-02-12 10:24 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (59.51 KB, patch)
2020-02-12 10:46 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (59.60 KB, patch)
2020-02-12 10:58 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (66.28 KB, patch)
2020-02-12 13:02 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (69.04 KB, patch)
2020-02-12 14:30 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
WIP Patch (72.19 KB, patch)
2020-02-12 15:02 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (88.61 KB, patch)
2020-02-12 16:00 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (89.51 KB, patch)
2020-02-13 14:33 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (89.51 KB, patch)
2020-02-13 14:37 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (89.54 KB, patch)
2020-02-13 15:00 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (89.75 KB, patch)
2020-02-13 15:26 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (93.24 KB, patch)
2020-02-17 09:57 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (93.34 KB, patch)
2020-02-17 09:58 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (90.88 KB, patch)
2020-02-17 14:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (91.88 KB, patch)
2020-02-17 16:59 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-02-11 15:46:06 PST
Implement in-WebProcess cookie cache to avoid sync IPC for document.cookie in most cases.
Comment 1 Chris Dumez 2020-02-11 15:46:22 PST
<rdar://problem/56027027>
Comment 2 Chris Dumez 2020-02-11 15:48:55 PST
Created attachment 390450 [details]
WIP Patch
Comment 3 Chris Dumez 2020-02-11 16:37:04 PST
Created attachment 390462 [details]
WIP Patch
Comment 4 Chris Dumez 2020-02-12 10:24:03 PST
Created attachment 390533 [details]
WIP Patch
Comment 5 Chris Dumez 2020-02-12 10:46:34 PST
Created attachment 390536 [details]
WIP Patch
Comment 6 Chris Dumez 2020-02-12 10:58:11 PST
Created attachment 390539 [details]
WIP Patch
Comment 7 Chris Dumez 2020-02-12 13:02:08 PST
Created attachment 390549 [details]
WIP Patch

Now passing layout tests locally.
Comment 8 Chris Dumez 2020-02-12 14:30:50 PST
Created attachment 390561 [details]
WIP Patch
Comment 9 Chris Dumez 2020-02-12 15:02:49 PST
Created attachment 390567 [details]
WIP Patch

With more layout tests.
Comment 10 Chris Dumez 2020-02-12 16:00:08 PST
Created attachment 390575 [details]
Patch
Comment 11 Antti Koivisto 2020-02-13 12:44:36 PST
Comment on attachment 390575 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=390575&action=review

> Source/WTF/wtf/PlatformEnable.h:802
> +#if !defined(ENABLE_COOKIE_CACHE) && PLATFORM(COCOA) && HAVE(CFNETWORK_COOKIE_CHANGE_LISTENER_API)
> +#define ENABLE_COOKIE_CACHE 1
> +#endif

Couldn't this just be a runtime no-op without CFNETWORK_COOKIE_CHANGE_LISTENER_API and avoid most #ifs?

> Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:617
> +    ASSERT(observers.add(&observer).isNewEntry);

Why is observer only added in debug build?

> Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:131
> +    if (!m_hostsWithCookieListeners.isEmpty()) {
> +        auto hostsWithCookieListeners = copyToVector(m_hostsWithCookieListeners);
> +        unsubscribeFromCookieChangeNotifications(hostsWithCookieListeners);
> +    }

I think it would be nicer to have a separate function or just loop over m_hostsWithCookieListeners here (avoiding the vector copy). It is just call to stopListeningForCookieChangeNotifications for each.

> Source/WebKit/WebProcess/WebPage/WebCookieCache.h:44
> +    bool isFunctional();

isEnabled/isSupported?
Comment 12 Chris Dumez 2020-02-13 12:47:58 PST
Comment on attachment 390575 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=390575&action=review

>> Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:617
>> +    ASSERT(observers.add(&observer).isNewEntry);
> 
> Why is observer only added in debug build?

ouch, last minute clean up I made :/ Thanks for catching.
Comment 13 Antti Koivisto 2020-02-13 12:50:59 PST
> ouch, last minute clean up I made :/ Thanks for catching.

Observers don't seem to have much test coverage.
Comment 14 Chris Dumez 2020-02-13 13:07:21 PST
(In reply to Antti Koivisto from comment #13)
> > ouch, last minute clean up I made :/ Thanks for catching.
> 
> Observers don't seem to have much test coverage.

EWS does not have the CFNetwork SPI needed and thus does not cover my change. Actual layout test bots will run the tests with the cookie cache enabled (at least some of the bots will).
Comment 15 Chris Dumez 2020-02-13 14:33:35 PST
Created attachment 390687 [details]
Patch
Comment 16 Chris Dumez 2020-02-13 14:37:32 PST
Created attachment 390688 [details]
Patch
Comment 17 Chris Dumez 2020-02-13 15:00:29 PST
Created attachment 390691 [details]
Patch
Comment 18 Chris Dumez 2020-02-13 15:26:52 PST
Created attachment 390695 [details]
Patch
Comment 19 Chris Dumez 2020-02-17 09:57:04 PST
Created attachment 390925 [details]
Patch
Comment 20 Chris Dumez 2020-02-17 09:58:13 PST
Created attachment 390926 [details]
Patch
Comment 21 Chris Dumez 2020-02-17 14:53:38 PST
Created attachment 390988 [details]
Patch
Comment 22 Chris Dumez 2020-02-17 16:59:00 PST
Created attachment 391004 [details]
Patch
Comment 23 WebKit Commit Bot 2020-02-17 22:32:49 PST
Comment on attachment 391004 [details]
Patch

Clearing flags on attachment: 391004

Committed r256820: <https://trac.webkit.org/changeset/256820>
Comment 24 WebKit Commit Bot 2020-02-17 22:32:51 PST
All reviewed patches have been landed.  Closing bug.
Comment 25 Truitt Savell 2020-02-24 16:23:01 PST
The new test http/tests/cookies/document-cookie-after-showModalDialog.html

is a flaky failure. tracking in https://bugs.webkit.org/show_bug.cgi?id=208165