iOS UIWebView crash in “WebThread”

前端 未结 3 1873
长情又很酷
长情又很酷 2020-12-09 22:23

Anyone able to help me out with this crash? It happens intermittently when switching back and forth between some UIWebView instances while they are loading.

The cra

相关标签:
3条回答
  • 2020-12-09 22:35

    I see that you have iOs 5.0. Are the files that you're loading Office documents (docx, xls)?

    If so, then your case is the same as mine. This problem reproduces only on systems with 5.0 (iPad and iPad 2 here), and happens when you try to stop UIWebView object before it finishes loading the file. Whether it's by calling stopLoading or loadRequest

    This doesn't happen with txt files.

    And if it does, it originates in WebThread starting from line:

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

    and jumping to some random pointers like:

    #0  0x00000010 in 0x00000010 ()
    
    0 讨论(0)
  • 2020-12-09 22:56

    Check that your UIWebViewDelegate delegate is still valid (ie. not released) if your UIWebView is in the background. This problem may be caused by the webview trying to call your delegate with

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

    in the background after loading has completed.

    0 讨论(0)
  • 2020-12-09 23:02

    To expand on @K1w1Geek's answer, the problem may be that the user is closing the web view just before it tries to send a delegate callback and it crashes because it doesn't exist. This doesn't necessarily have to be related to loading a particular document type because I'm experiencing this crash just navigating a Salesforce website.

    So if you have a close button, try to stop loading and set the delegate to nil before closing:

    - (IBAction)btnCloseWebviewTap:(id)sender{
        [_webView stopLoading];
        _webView.delegate = nil;
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
    0 讨论(0)
提交回复
热议问题