简体   繁体   English

iOS UIWebView在WebCore :: FrameTree :: top上随机崩溃

[英]iOS UIWebView crashes randomly on WebCore::FrameTree::top

I have an iOS app that randomly seems to crash on a screen that has a UIWebView. 我有一个iOS应用程序随机似乎在具有UIWebView的屏幕上崩溃。 It looks like the crash happens mostly on iPhone 5C devices (74% of the time) and 100% of the time on iOS 10.X. 看起来崩溃主要发生在iPhone 5C设备上(占74%的时间),100%发生在iOS 10.X上。

The exception message is: 异常消息是:

EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000028

From that low memory address it makes me think something was nil . 从那个低内存地址,它让我觉得有些东西是nil

Here's the backtrace (this is not the main thread): 这是回溯(这不是主线程):

0    WebCore                                       WebCore::FrameTree::top() + 0
1    WebCore                                       WebCore::ContentSecurityPolicy::allowFrameAncestors() + 33
2    WebCore                                       WebCore::DocumentLoader::responseReceived() + 413
3    WebCore                                       WebCore::DocumentLoader::handleSubstituteDataLoadNow() + 203
4    WebCore                                       WebCore::ThreadTimers::sharedTimerFiredInternal() + 149
5    WebCore                                       WebCore::timerFired() + 23
6    CoreFoundation                                __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15
7    CoreFoundation                                __CFRunLoopDoTimer + 833
8    CoreFoundation                                __CFRunLoopDoTimers + 189
9    CoreFoundation                                __CFRunLoopRun + 781
10   CoreFoundation                               CFRunLoopRunSpecific + 471
11   CoreFoundation                               CFRunLoopRunInMode + 105
12   WebCore                                      RunWebThread() + 427
13   libsystem_pthread.dylib                      _pthread_body + 217
14   libsystem_pthread.dylib                      _pthread_start + 235

I can't reproduce this crash myself. 我自己无法重现这次崩溃。

Since WebKit is open source, I found the code where it crashes: WebCore::FrameTree::top . 由于WebKit是开源的,我找到了它崩溃的代码: WebCore :: FrameTree :: top From looking at that code, I'm guessing m_thisFrame->tree() is NULL , but I'm not sure how to explain it. 从查看该代码,我猜m_thisFrame->tree()NULL ,但我不知道如何解释它。 I'm not sure exactly what "frames" and "trees" are in that context. 我不确定在这种情况下究竟是什么“框架”和“树”。

From the backtrace it looks like there is some timer that's being fired, possibly after the View Controller or the Web View is already deallocated? 从回溯看起来有一些计时器被解雇,可能是在视图控制器或Web视图已被解除分配后? Is that timer due to a JavaScript setTimeout call? 这个计时器是由于JavaScript setTimeout调用吗?

Also I notice every time this crash happens, I get a call to [UIWebViewDelegate webView:didFailLoadWithError:] right before the crash. 此外,我注意到每次发生此崩溃时,我都会在崩溃之前调用[UIWebViewDelegate webView:didFailLoadWithError:] The most common errors returned in that delegate method are: 该委托方法中返回的最常见错误是:

  • Frame load interrupted 帧负载中断
  • too many HTTP redirects HTTP重定向太多了
  • The request timed out 请求超时

But I don't have analytics in place to correlate the error message with the crash, so I'm not sure which (if any) would explain it. 但是我没有将错误消息与崩溃相关联的分析,所以我不确定哪个(如果有的话)会解释它。 When that delegate method fires, I show the user an error message in a modal. 当该委托方法触发时,我向用户显示模态中的错误消息。 Could this be related to the crash? 这可能与坠机有关吗? I tried reproducing the "Frame load interrupted" and "too many HTTP redirects" errors but neither causes the crash for me in simulator. 我尝试重现“帧加载中断”和“太多HTTP重定向”错误,但都没有导致我在模拟器中崩溃。

I already follow the advice in this answer (mostly) and call [webview stopLoading] in viewWillDisappear and I call self.webView.delegate = nil in dealloc of the containing View Controller but it didn't help. 我已经按照这个答案中的建议(主要是)并在viewWillDisappear调用[webview stopLoading] ,并在包含View Controller的dealloc中调用self.webView.delegate = nil ,但它没有帮助。

This isn't really an answer, but this crash seems to be related to when content filtering (parent controls) are enabled. 这不是一个真正的答案,但这种崩溃似乎与启用内容过滤(父控件)有关。 If you add whatever domain your app is loading in the UIWebView to the iOS parent controls blocklist, you should see this error in the application logs (coming internally from WebKit's WebFilter). 如果您将应用程序在UIWebView中加载的任何域添加到iOS父控件阻止列表中,您应该在应用程序日志中看到此错误(来自WebKit的WebFilter内部)。 It seems to invalidate the UIWebView in some way, so when you interact with it again, it crashes your whole app. 它似乎以某种方式使UIWebView无效,因此当您再次与它进行交互时,它会崩溃整个应用程序。 You can probably avoid the crash by switching to WKWebView. 您可以通过切换到WKWebView来避免崩溃。

WF: WebFilterEvaluator:addData: https://some-blocked-url.com is restricted: blacklisted

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM