IOS: WebKitLegacy Crash

After some relatively safe (as for me) changes, the application began to crash on some of the WebKitLegacy stuff. I see a lot of glitches in Fabric, but cannot find stable steps to reproduce. Does anyone know what could lead to these accidents? See Attached Images.

Some application screens use UIWebView to display content - I assume the problem is out there somewhere.

enter image description here enter image description here

+6
source share
2 answers

As far as I remember, this signal appeared when Webview received an update (for example, a response from an embedded image), but it could not be displayed because it was no longer used by the main stream. This means that when the ViewController is not displayed.

If so, you should be able to reproduce the problem by loading a web page with heavy content (for example, some online newspapers such as http://edition.cnn.com/ ) and rejecting the web view immediately after starting the download by clicking / call another ViewController.

How to fix it: indeed, you need to call the methods that you mentioned:

webview.delegate = nil; [webview stopLoading]; 

However, the place to do is the viewWillDisappear method, never on dealloc . The reason is simple: viewWillDisappear is called when the ViewController is about to lose control of the main thread. However, dealloc is called when the VC is about to be released in a heap. This can happen a few seconds after the application makes some precious time to fail or may never be called at all. Moving both methods should do the trick.

+1
source

UIWebView EXC_BAD_Address ... Received application signal First of all, you should think about webView.delegate = nil. But where?

My experience:

 - (void)dealloc{ /* Important Before releasing an instance of UIWebView for which you have set a delegate, you must first set the UIWebView delegate property to nil before disposing of the UIWebView instance. This can be done, for example, in the dealloc method where you dispose of the UIWebView. */ if (_webView.loading) { [self.webView stopLoading]; } _webView.delegate = nil; } 

if the ViewController is a child of another ViewController , you can initiate the removal of the ViewController view from the parent ViewController view using animation. At the same time, you can remove the ViewController from your parent and run its link. for now, the ViewController will be nil and the viewWillDisappear will never be named , which means the WebView delegate will never be cleaned ** Use dealloc and make sure your WebView always cleaned.

Other great ios links : EXC_BAD_ACCESS for Webview delegate

+1
source

All Articles