“WebThread”中的iOS UIWebView崩溃

时间:2011-11-11 21:37:00

标签: ios uiwebview

任何能够帮助我解决这次崩溃的人?它在加载时在某些UIWebView实例之间来回切换时间歇性地发生。

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

以下是两次崩溃的相关部分:

Date/Time:       2011-11-08 14:29:01.165 -0500
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000006
Crashed Thread:  4

Thread 4 name:  WebThread
Thread 4 Crashed:
0   ???                             0x00000006 0 + 6
1   WebCore                         0x32a36154 -[QuickLookHandleAsDelegate connection:didReceiveData:lengthReceived:] + 72
2   QuickLook                       0x30bee2c2 -[QLThreadInvoker connectionDidReceiveDataLengthReceived:] + 90
3   CoreFoundation                  0x3537a226 -[NSObject performSelector:withObject:] + 38
4   Foundation                      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/Time:       2011-11-08 15:09:01.410 -0500
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000034
Crashed Thread:  4

Thread 4 name:  WebThread
Thread 4 Crashed:
0   ???                             0x00000034 0 + 52
1   CoreFoundation                  0x3537a226 -[NSObject performSelector:withObject:] + 38
2   Foundation                      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

3 个答案:

答案 0 :(得分:7)

我看到你有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 ()

答案 1 :(得分:3)

要扩展@ K1w1Geek的答案,问题可能是用户在尝试发送委托回调之前关闭Web视图并且因为它不存在而崩溃。这不一定与加载特定文档类型有关,因为我在浏览Salesforce网站时遇到此崩溃。

因此,如果您有关闭按钮,请尝试停止加载并在关闭前将委托设置为nil:

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

答案 2 :(得分:2)

如果您的UIWebView在后台,请检查您的UIWebViewDelegate委托是否仍然有效(即未发布)。此问题可能是由于webview尝试使用

调用您的委托
- (void)webViewDidFinishLoad:(UIWebView *)webView;

在加载完成后的后台。