Bug 240981

Summary: Move disk operations when deleting cookies off from the main thread
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: WebKit Misc.Assignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, ews-watchlist, hi, japhet, joepeck, pangle, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch achristensen: review-, ews-feeder: commit-queue-

Alex Christensen
Reported 2022-05-26 14:56:46 PDT
When it's on the main thread, it causes hangs and lack of responsiveness.
Attachments
Patch (43.79 KB, patch)
2022-05-26 15:07 PDT, Alex Christensen
achristensen: review-
ews-feeder: commit-queue-
Alex Christensen
Comment 1 2022-05-26 15:00:14 PDT
Alex Christensen
Comment 2 2022-05-26 15:07:03 PDT
Chris Dumez
Comment 3 2022-05-26 15:13:29 PDT
Comment on attachment 459795 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=459795&action=review > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:155 > + [nsCookieStorage() setCookie:newCookie]; Isn't this doing a cookie storage operation on the main thread? > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:585 > + [nsCookieStorage() _saveCookies:makeBlockPtr([completionHandler = WTFMove(completionHandler)] () mutable { Isn't this doing cookie operations on the main thread? > Source/WebKit/NetworkProcess/Cookies/WebCookieManager.h:76 > + void deleteAllCookies(PAL::SessionID, CompletionHandler<void()>&&); I wish you'd use `CompletionHandler<void()>&&` consistently in your patch. However, you're using `CompletionHandler<void()>` as parameter sometimes.
Alex Christensen
Comment 4 2022-05-26 15:19:25 PDT
(In reply to Chris Dumez from comment #3) > Comment on attachment 459795 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=459795&action=review > > > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:155 > > + [nsCookieStorage() setCookie:newCookie]; > > Isn't this doing a cookie storage operation on the main thread? I think setting a cookie doesn't always immediately go to disk on the same thread. This patch only addresses cookie deleting on the main thread. > > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:585 > > + [nsCookieStorage() _saveCookies:makeBlockPtr([completionHandler = WTFMove(completionHandler)] () mutable { > > Isn't this doing cookie operations on the main thread? Ditto. > > Source/WebKit/NetworkProcess/Cookies/WebCookieManager.h:76 > > + void deleteAllCookies(PAL::SessionID, CompletionHandler<void()>&&); > > I wish you'd use `CompletionHandler<void()>&&` consistently in your patch. > However, you're using `CompletionHandler<void()>` as parameter sometimes. I'm trying to move to without && but there were places where it looked out of place. The two are functionally equivalent.
Chris Dumez
Comment 5 2022-05-26 15:22:25 PDT
(In reply to Alex Christensen from comment #4) > (In reply to Chris Dumez from comment #3) > > Comment on attachment 459795 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=459795&action=review > > > > > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:155 > > > + [nsCookieStorage() setCookie:newCookie]; > > > > Isn't this doing a cookie storage operation on the main thread? > I think setting a cookie doesn't always immediately go to disk on the same > thread. This patch only addresses cookie deleting on the main thread. > > > > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:585 > > > + [nsCookieStorage() _saveCookies:makeBlockPtr([completionHandler = WTFMove(completionHandler)] () mutable { > > > > Isn't this doing cookie operations on the main thread? > Ditto. > > > > Source/WebKit/NetworkProcess/Cookies/WebCookieManager.h:76 > > > + void deleteAllCookies(PAL::SessionID, CompletionHandler<void()>&&); > > > > I wish you'd use `CompletionHandler<void()>&&` consistently in your patch. > > However, you're using `CompletionHandler<void()>` as parameter sometimes. > I'm trying to move to without && but there were places where it looked out > of place. The two are functionally equivalent. CompletionHandler<void()>&& communicates to the caller that we want a r-value and they need to WTFMove(). CompletionHandler<void()> doesn't communicate that. It will give a build time error though if they fail to WTFMove() (only because CompletionHandler is not copyable).
Alex Christensen
Comment 6 2022-05-26 15:41:47 PDT
Comment on attachment 459795 [details] Patch GitHub PR has more &&
EWS
Comment 7 2022-05-27 12:21:15 PDT
Committed r294947 (251055@main): <https://commits.webkit.org/251055@main> Reviewed commits have been landed. Closing PR #1072 and removing active labels.
Radar WebKit Bug Importer
Comment 8 2022-05-27 12:22:14 PDT
Note You need to log in before you can comment on or make changes to this bug.