Bug 188995 - iOS 12 WKHTTPCookieStoreObserver does not consistently callback on cookie changes
Summary: iOS 12 WKHTTPCookieStoreObserver does not consistently callback on cookie cha...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: Safari Technology Preview
Hardware: iPhone / iPad Other
: P1 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-27 11:29 PDT by bchenindeed
Modified: 2018-08-30 09:54 PDT (History)
2 users (show)

See Also:


Attachments
sample project (40.17 KB, application/zip)
2018-08-27 11:29 PDT, bchenindeed
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description bchenindeed 2018-08-27 11:29:38 PDT
Created attachment 348177 [details]
sample project

On iOS 12 beta 10 (and earlier), the WKHTTPCookieStoreObserver cookiesDidChange method is not being consistently called.

We use the WKHTTPCookieStoreObserver to synchronize login state.  Our login occurs in WKWebView which sets cookies with authentication tokens.  We then transfer those cookies to our NSURLSession requests to our direct API.

As of iOS 12 beta, the WKHTTPCookieStoreObserver, cookiesDidChange method seems to be getting called inconsistently.  During debugging (via logs) we see it getting called for some initial requests and then it just stops being called.

Attached a sample project that demonstrates issue.  Callback is called on initial page load.  When you perform a search, cookies are modified, but the observer is never notified.

Radar: 43691855
Comment 1 Sihui Liu 2018-08-29 17:38:04 PDT
(In reply to bchenindeed from comment #0)
> Created attachment 348177 [details]
> sample project
> 
> On iOS 12 beta 10 (and earlier), the WKHTTPCookieStoreObserver
> cookiesDidChange method is not being consistently called.
> 
> We use the WKHTTPCookieStoreObserver to synchronize login state.  Our login
> occurs in WKWebView which sets cookies with authentication tokens.  We then
> transfer those cookies to our NSURLSession requests to our direct API.
> 
> As of iOS 12 beta, the WKHTTPCookieStoreObserver, cookiesDidChange method
> seems to be getting called inconsistently.  During debugging (via logs) we
> see it getting called for some initial requests and then it just stops being
> called.
> 
> Attached a sample project that demonstrates issue.  Callback is called on
> initial page load.  When you perform a search, cookies are modified, but the
> observer is never notified.
> 
> Radar: 43691855

Hi Brian, thanks for providing the test case. This is a known issue and it's not a webkit bug. We are working on a fix.

What we found is the cookie was set successfully but notification of changes was not sent, so a workaround may be using [WKHTTPCookieStore getAllCookies:] inside decidePolicyForNavigationRespons?
Comment 2 Alexey Proskuryakov 2018-08-30 09:54:50 PDT
Marking as invalid as this is an issue outside WebKit. Thank you again for the report!