首页 文章

“WebThread”中的iOS UIWebView崩溃

提问于
浏览
8

有谁能帮我解决这个崩溃?它在加载时在某些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 回答

  • 2

    我看到你有iOs 5.0 . 您正在加载Office文档(docx,xls)的文件?

    如果是这样,那么你的情况与我的相同 . 此问题仅在具有5.0的系统(此处为iPad和iPad 2)上重现,并且在您尝试在完成加载文件之前停止 UIWebView 对象时会发生此问题 . 是否通过调用 stopLoadingloadRequest

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

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

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

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

    #0  0x00000010 in 0x00000010 ()
    
  • 2

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

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

    在加载完成后的后台 .

  • 7

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

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

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

相关问题