iOS的UIWebView崩溃在“WebThread”

任何人能够帮助我与这次崩溃? 它会在加载时在一些UIWebView实例之间来回切换。

崩溃通常稍有不同,但它总是与“WebThread”崩溃类似的堆栈跟踪。

这里是两个崩溃的相关部分:

date/时间:2011-11-08 14:29:01.165 -0500
操作系统版本:iPhone OS 5.0(9A334)
报告版本:104

exceptiontypes:EXC_BAD_ACCESS(SIGSEGV)
exception代码:0x0000006处的KERN_INVALID_ADDRESS
坠毁的线程:4

线程4名称:WebThread
线程4崩溃:
 0  0x00000006 0 + 6
 1 WebCore 0x32a36154  -  [QuickLookHandleAsDelegate连接:didReceiveData:lengthReceived:] + 72
 2 QuickLook 0x30bee2c2  -  [QLThreadInvoker connectionDidReceiveDataLengthReceived:] + 90
 3 CoreFoundation 0x3537a226  -  [NSObject performSelector:withObject:] + 38
 4基础0x32ce2752 __NSThreadPerformPerform + 346
 5 CoreFoundation 0x353efafe __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 10
 6 CoreFoundation 0x353ef2ca __CFRunLoopDoSources0 + 210
 7 CoreFoundation 0x353ee070 __CFRunLoopRun + 648
 8 CoreFoundation 0x353714d8 CFRunLoopRunSpecific + 296
 9 CoreFoundation 0x353713a0 CFRunLoopRunInMode + 100
 10 WebCore 0x324c912a _ZL12RunWebThreadPv + 398
 11 libsystem_c.dylib 0x35ba1c18 _pthread_start + 316
 12 libsystem_c.dylib 0x35ba1ad4 thread_start + 4
date/时间:2011-11-08 15:09:01.410 -0500
操作系统版本:iPhone OS 5.0(9A334)
报告版本:104

exceptiontypes:EXC_BAD_ACCESS(SIGSEGV)
exception代码:0x0000034处的KERN_INVALID_ADDRESS
坠毁的线程:4

线程4名称:WebThread
线程4崩溃:
 0  0x00000034 0 + 52
 1 CoreFoundation 0x3537a226  -  [NSObject performSelector:withObject:] + 38
 2基础0x32ce2752 __NSThreadPerformPerform + 346
 3 CoreFoundation 0x353efafe __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 10
 4 CoreFoundation 0x353ef2ca __CFRunLoopDoSources0 + 210
 5 CoreFoundation 0x353ee070 __CFRunLoopRun + 648
 6 CoreFoundation 0x353714d8 CFRunLoopRunSpecific + 296
 7 CoreFoundation 0x353713a0 CFRunLoopRunInMode + 100
 8 WebCore 0x324c912a _ZL12RunWebThreadPv + 398
 9 libsystem_c.dylib 0x35ba1c18 _pthread_start + 316
 10 libsystem_c.dylib 0x35ba1ad4 thread_start + 4

我看到你有iOs 5.0。 您正在加载Office文档(docx,xl​​s)的文件?

如果是这样,那么你的情况和我的一样。 这个问题只在具有5.0(这里是iPad和iPad 2)的系统上重现,并且当你试图在加载文件之前停止UIWebView对象时,就会出现这个问题。 无论是通过调用stopLoading还是loadRequest

txt文件不会发生这种情况。

如果是这样的话,它起源于WebThread从行开始:

 #1 0x34912158 in -[QuickLookHandleAsDelegate connection:didReceiveData:lengthReceived:] () 

并跳转到一些随机指针,如:

 #0 0x00000010 in 0x00000010 () 

如果您的UIWebView位于后台,请检查您的UIWebViewDelegate委托是否仍然有效(即未释放)。 这个问题可能是由webview试图调用你的委托引起的

 - (void)webViewDidFinishLoad:(UIWebView *)webView; 

在后台加载完成后。

要展开@ K1w1Geek的答案,问题可能是用户在试图发送委托callback之前正在closuresWeb视图,并且因为它不存在而崩溃。 这并不一定与加载特定文档types有关,因为我只是在导航Salesforce网站时遇到了这个崩溃。

所以,如果你有一个closuresbutton,尝试停止加载,并在closures之前将委托设置为零:

 - (IBAction)btnCloseWebviewTap:(id)sender{ [_webView stopLoading]; _webView.delegate = nil; [self dismissViewControllerAnimated:YES completion:nil]; }