I have an iOS application that accidentally hits the screen with a UIWebView. It seems that the accident occurs mainly on iPhone 5C devices (74% of the time) and 100% of the time on iOS 10.X.
Exception Message:
EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000028
From this low memory address, it seems to me that something was 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 cannot reproduce this catastrophe myself.
Since WebKit is open source, I found the code in which it crashes: WebCore :: FrameTree :: top . From a look at this code, I assume that m_thisFrame->tree() is NULL , but I'm not sure how to explain it. I am not sure which βframesβ and βtreesβ are in this context.
It can be seen from the return channel that there is some kind of timer that is fired, perhaps after the view controller or web view has already been released? Is this timer triggered by a JavaScript call to setTimeout ?
Also, I notice every time this failure occurs, I get a call [UIWebViewDelegate webView:didFailLoadWithError:] right before the failure. The most common errors returned in this deletion are:
- Frame interruption
- too many HTTP redirects
- Request timed out
But I have no analytics to correlate the error message with the failure, so I'm not sure if (if any) will explain it. When this delegate method fires, I show the user an error message in modal mode. Could this be due to the collapse? I tried to reproduce the errors "Frame overload is interrupted" and "too many HTTP redirects", but it does not crash for me in the simulator.
I already follow the recommendations of this answer (mostly) and call [webview stopLoading] in viewWillDisappear , and I call self.webView.delegate = nil in the dealloc containing the View Controller, but that didn't help.