我们最近迁移到了 WKWebview。我们为 cookie 更改添加了一个监听器,以获取更新的 cookie 并更新我们自己的商店。
- (void)cookiesDidChangeInCookieStore:(WKHTTPCookieStore *)cookieStore {
[cookieStore getAllCookies:^(NSArray* cookies) {
}];
}
加载控制器后,它会调用 cookiesDidChangeInCookieStore 并在“getAllCookies”处崩溃。但这种崩溃仅发生在 TestFlight/Fabric 构建中。当我从 xcode 直接在设备上运行应用程序时(在调试和发布模式下)不会发生。以下是崩溃报告,
Thread 9 name: WebThread
Thread 9 Crashed:
0 WebKit 0x0000000192fbfc10 WebKit::CallbackMap::put+ 1186832 (WTF::Ref<WebKit::CallbackBase, WTF::DumbPtrTraits<WebKit::CallbackBase> >&&) + 128
1 WebKit 0x0000000192fbfbb4 WebKit::CallbackMap::put+ 1186740 (WTF::Ref<WebKit::CallbackBase, WTF::DumbPtrTraits<WebKit::CallbackBase> >&&) + 36
2 WebKit 0x00000001930490cc WebKit::CallbackID WebKit::CallbackMap::put<WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WebKit::CallbackBase::Error>(WTF::Function<void + 1749196 (WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WebKit::CallbackBase::Error)>&&) + 136
3 WebKit 0x0000000193049008 WebKit::WebCookieManagerProxy::getAllCookies(PAL::SessionID, WTF::Function<void + 1749000 (WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&, WebKit::CallbackBase::Error)>&&) + 44
4 WebKit 0x0000000192eb5b90 API::HTTPCookieStore::cookies(WTF::Function<void + 97168 (WTF::Vector<WebCore::Cookie, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc> const&)>&&) + 124
5 WebKit 0x00000001931fbdf8 -[WKHTTPCookieStore getAllCookies:] + 92
6 WebKit 0x00000001931fc96c WKHTTPCookieStoreObserver::cookiesDidChange+ 3533164 (API::HTTPCookieStore&) + 44
7 WebKit 0x0000000192eb61b0 API::HTTPCookieStore::cookiesDidChange+ 98736 () + 72
8 JavaScriptCore 0x000000018a0e17d4 WTF::dispatchFunctionsFromMainThread+ 6100 () + 344
9 JavaScriptCore 0x000000018a208650 WTF::timerFired+ 1214032 (__CFRunLoopTimer*, void*) + 40
10 CoreFoundation 0x0000000183527aa8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
11 CoreFoundation 0x000000018352776c __CFRunLoopDoTimer + 864
12 CoreFoundation 0x0000000183527010 __CFRunLoopDoTimers + 248
13 CoreFoundation 0x0000000183524b60 __CFRunLoopRun + 2168
14 CoreFoundation 0x0000000183444da8 CFRunLoopRunSpecific + 552
15 WebCore 0x000000018b6d1dcc RunWebThread+ 265676 (void*) + 592
16 libsystem_pthread.dylib 0x00000001831a5220 _pthread_body + 272
17 libsystem_pthread.dylib 0x00000001831a5110 _pthread_body + 0
18 libsystem_pthread.dylib 0x00000001831a3b10 thread_start + 4
调用 getAllCookies 时似乎存在溢出。这仅在 iOS 11.3 中发生。