Our iOS application reads cookies from WKHTTPCookieStore
to call the initialization webservice. If the specific cookie we are looking for is not present in the CookieStore, will pass empty value in the webservice and it will return the relevant response. Since this is an initialization API, we are calling the webservice in the completion handler as below and blocks the UI by adding an activity indicator until it gives a success or failure.
WKWebsiteDataStore.default().httpCookieStore.getAllCookies { (cookies) in
callInitializationService(cookies)
}
In our testing, it worked well in all available testing devices in OS versions ranging from iOS 11.3 to 12.2.
The current issue is the production app is having a weird behaviour where the activity indicator does not dismiss at all after install. We found out the root cause to be WKHTTPCookieStore.getAllCookies
completion handler is never called and hence it blocks the UI. The issue is majorly observed in iOS 11.2.x OS versions, but not sure whether it affects any other OS versions as well. Even re starting the app does not solve the issue.
Does anyone experienced this issue before ? Any resolution/workaround available to fix this ?
Ever since this change, WebKit doesn't initialize
WKWebsiteDataStore
until necessary, and this has been causing issues where it is sometimes not initialized when it should be. The true source of the bug only Apple can fix. Until then, you can trick the system into initializing theWKWebsiteDataStore
with this workaround put directly after your call to get or set cookies:I've found this solution here in the answer written by hshamansky. It appears the original author filed a bug report, but it doesn't look like it was ever resolved. It seems Apple has difficulty reproducing the issue.