我有一个使用UIWebView和HTML5 websockets构建的iOS应用程序。该应用程序经历了看似随机的崩溃。它发生在用户与其交互时,以及在用户与应用程序之间没有交互的寿命测试期间。
所有的崩溃日志都有以下内容:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000
线程日志包含:
Thread XX name: WebCore: Worker
Thread XX Crashed:
0 WebCore 0x36c8c7a0 WebCore::UserGestureIndicator::processingUserGesture() + 20
1 WebCore 0x36d7070a WebCore::DOMTimer::DOMTimer(WebCore::ScriptExecutionContext*, WTF::PassOwnPtr<WebCore::ScheduledAction>, int, bool) + 74
2 WebCore 0x36d70616 WebCore::DOMTimer::install(WebCore::ScriptExecutionContext*, WTF::PassOwnPtr<WebCore::ScheduledAction>, int, bool) + 46
3 WebCore 0x3753ae7e WebCore::WorkerContext::setTimeout(WTF::PassOwnPtr<WebCore::ScheduledAction>, int) + 30
4 WebCore 0x3731ac02 WebCore::JSWorkerContext::setTimeout(JSC::ExecState*) + 194
5 WebCore 0x37318ff6 WebCore::jsWorkerContextPrototypeFunctionSetTimeout(JSC::ExecState*) + 110
6 JavaScriptCore 0x2fa9a1d8 llint_native_call_trampoline + 62
7 JavaScriptCore 0x2faa355a JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 66
8 WebCore 0x36db0b16 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 558
9 WebCore 0x36d6ebba WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow>&) + 482
10 WebCore 0x36c6da2a WebCore::EventTarget::fireEventListeners(WebCore::Event*) + 174
11 WebCore 0x36e28824 WebCore::EventTarget::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) + 60
12 WebCore 0x3753e596 WebCore::MessageWorkerContextTask::performTask(WebCore::ScriptExecutionContext*) + 222
13 WebCore 0x3753ec6e WebCore::WorkerRunLoop::runInMode(WebCore::WorkerContext*, WebCore::ModePredicate const&, WebCore::WorkerRunLoop::WaitMode) + 158
14 WebCore 0x3753eb94 WebCore::WorkerRunLoop::run(WebCore::WorkerContext*) + 60
15 WebCore 0x37540d64 WebCore::WorkerThread::workerThread() + 432
16 JavaScriptCore 0x2fa4ba68 WTF::wtfThreadEntryPoint(void*) + 12
17 libsystem_pthread.dylib 0x397b6c5a _pthread_body + 138
18 libsystem_pthread.dylib 0x397b6bca _pthread_start + 98
19 libsystem_pthread.dylib 0x397b4ccc thread_start + 4
我设法在抛出时捕获了异常,从我所能断定的情况来看,它看起来像是一个框架错误。请参阅附加的屏幕截图。
我读到的大多数内容似乎都表明web视图是在委托触发之前被释放的,但在我的代码中没有任何地方是释放的!
有没有人遇到过这种或类似的情况?任何帮助都是非常感谢的!
更新
在联系开发人员支持后,我已经向Apple提交了错误报告。他们的工程师确认这是一个bug。
发布于 2017-07-06 13:38:07
在我的例子中,我也有类似的问题。
正如许多人所说的,这可能是由于WebView委托方法在webview被释放时调用造成的。
为了解决这个问题,我们需要将委托设置为nil,并在指定的方法上停止webview请求
您必须添加以下代码行
-(void)viewDidUnload{
[super viewDidUnload];
webViewRef.delegate = nil;
[webViewRef stopLoading];
}
-(void)backBtnClicked{
webViewRef.delegate = nil;
[webViewRef stopLoading];
}
希望能对你有所帮助。
https://stackoverflow.com/questions/20862757
复制相似问题