title: WKHTTPCookieStore getAllCookies crash
body: <p>I've got a weird crash when calling <code>getAllCookies()</code></p>
  
  <p>The crash is only reproducible on real device with iOS 11.3.1. On Simulator works fine.</p>
  
  <pre><code>let httpCookieStore = WKWebsiteDataStore.default().httpCookieStore
  httpCookieStore.getAllCookies { (cookies) in
  
  }
  </code></pre>
  
  <p>The crash in Xcode console says:</p>
  
  <p><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL length]: unrecognized selector sent to instance 0x10fc42790'</code></p>
  
  <p>The crash on Crashlytics:</p>
  
  <pre><code>Fatal Exception: NSInvalidArgumentException
  -[NSURL length]: unrecognized selector sent to instance 0x1c4466d00
  
  Fatal Exception: NSInvalidArgumentException
  0  CoreFoundation                 0x18105ed8c __exceptionPreprocess
  1  libobjc.A.dylib                0x1802185ec objc_exception_throw
  2  CoreFoundation                 0x18106c098 __methodDescriptionForSelector
  3  CoreFoundation                 0x1810645c8 ___forwarding___
  4  CoreFoundation                 0x180f4a41c _CF_forwarding_prep_0
  5  CFNetwork                      0x1817a8e44 _CFStringGetOrCreateCString
  6  CFNetwork                      0x181799a54 CompactHTTPCookieWithData::CompactHTTPCookieWithData(__CFDictionary const*)::PropDecanter::getEnumeratedString(unsigned int)
  7  CFNetwork                      0x181798fb4 Decanter::decant(__CFAllocator const*)
  8  CFNetwork                      0x18179956c CompactHTTPCookieWithData::CompactHTTPCookieWithData(__CFDictionary const*)
  9  CFNetwork                      0x18164f8b0 CFHTTPCookieCreateWithProperties
  10 CFNetwork                      0x18171fe58 -[NSHTTPCookie initWithProperties:]
  11 CFNetwork                      0x18171fe24 +[NSHTTPCookie cookieWithProperties:]
  12 WebKit                         0x190cdc598 WTF::Function&lt;void (WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;)&gt;::CallableWrapper&lt;-[WKHTTPCookieStore getAllCookies:]::$_0&gt;::call(WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;)
  13 WebKit                         0x190b292ac WebKit::GenericCallback&lt;WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;&gt;::performCallbackWithReturnValue(WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;)
  14 WebKit                         0x190b291b4 WebKit::WebCookieManagerProxy::didGetCookies(WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;, WebKit::CallbackID)
  15 WebKit                         0x190b2bb08 void IPC::handleMessage&lt;Messages::WebCookieManagerProxy::DidGetCookies, WebKit::WebCookieManagerProxy, void (WebKit::WebCookieManagerProxy::*)(WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;, WebKit::CallbackID)&gt;(IPC::Decoder&amp;, WebKit::WebCookieManagerProxy*, void (WebKit::WebCookieManagerProxy::*)(WTF::Vector&lt;WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt; const&amp;, WebKit::CallbackID))
  16 WebKit                         0x190a0a5bc IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
  17 WebKit                         0x190a5e3c0 WebKit::NetworkProcessProxy::didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
  18 WebKit                         0x1909cd8ec IPC::Connection::dispatchMessage(std::__1::unique_ptr&lt;IPC::Decoder, std::__1::default_delete&lt;IPC::Decoder&gt; &gt;)
  19 WebKit                         0x1909d02f4 IPC::Connection::dispatchOneMessage()
  20 JavaScriptCore                 0x188663e98 WTF::RunLoop::performWork()
  21 JavaScriptCore                 0x188664158 WTF::RunLoop::performWork(void*)
  22 CoreFoundation                 0x181007404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
  23 CoreFoundation                 0x181006c2c __CFRunLoopDoSources0
  24 CoreFoundation                 0x18100479c __CFRunLoopRun
  25 CoreFoundation                 0x180f24da8 CFRunLoopRunSpecific
  26 GraphicsServices               0x182f07020 GSEventRunModal
  27 UIKit                          0x18af0578c UIApplicationMain
  28 NAKD-InHouseProd               0x100164ea4 main (AppDelegate.swift:13)
  29 libdyld.dylib                  0x1809b5fc0 start
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/50070595/1381708">Calling getAllCookies asynchronously in the main thread</a>, do not solve the problem.</p>