Exception in WKHTTPCookieStore.getAllCookies. No message.

I'm trying to observe cookie changes when I use `WKWebView`. I added my AppDelegate as an observer:


WKWebsiteDataStore.default().httpCookieStore.add(self)


The application starts and immediately `cookiesDidChange` fires. I then get an exception with nothing useful printed in the console. Xcode shows this on the third line below: WebThread (15): EXC_BREAKPOINT (code=1, subcode=0x1c67e03f4)


func cookiesDidChange(in cookieStore: WKHTTPCookieStore) {
    print("cookiesDidChange!!")
    cookieStore.getAllCookies{ cs in }  // <-- crashes here


I added some logic to not call `getAllCookies` until after some WebViews are created. It then succeeds a few times but fails again in same way.


Any ideas? Is there some thread safety issue around called `getAllCookies`?


Rob

Wrapping the call in DispatchQueue.main.async seems to be working for now. If this is required, it should be in the documentation.

Exception in WKHTTPCookieStore.getAllCookies. No message.
 
 
Q