简体   繁体   中英

Weird iOS UIWebView Crash called WTF Crash

I am using UIWebViews in some of the screens, because I need a perfect Html text parsing.

According to crash reports a huge number of crashes, called WTF Crash, occur on these screens. Here is a trace of that crash

Crashed: WebThread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000bbadbeef

Thread : Crashed: WebThread
0  JavaScriptCore                 0x184fd2710 WTFCrash + 72
1  JavaScriptCore                 0x184fd2708 WTFCrash + 64
2  WebCore                        0x1852b7d78 <redacted> + 362
3  WebCore                        0x1852b7bec <redacted> + 44
4  CoreFoundation                 0x1817d8588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
5  CoreFoundation                 0x1817d632c __CFRunLoopDoObservers + 372
6  CoreFoundation                 0x1817d6674 __CFRunLoopRun + 696
7  CoreFoundation                 0x181705680 CFRunLoopRunSpecific + 384
8  WebCore                        0x1852b5998 <redacted> + 456
9  libsystem_pthread.dylib        0x18148bb28 <redacted> + 156
10 libsystem_pthread.dylib        0x18148ba8c _pthread_start + 154
11 libsystem_pthread.dylib        0x181489028 thread_start + 4

There is no OS version, or device relation on this crash.

I am not doing anything fancy on using UIWebView as well. It is added to nib like every other component, and in the implementation file I use it like the following

self.webView.scrollView.scrollEnabled = NO;
self.webView.scrollView.bounces = NO;
self.webView.opaque = NO;
self.webView.backgroundColor = [UIColor clearColor];
self.webView.delegate = self;
[self.webView loadHTMLString:htmlString baseURL:nil];

Any suggestions on how to solve WTF Crash?

Edit: Here is how htmlString looks like

Printing description of htmlString:
<html><body style="font-family:HelveticaNeue; font-size:10; background-color:#E5E4E4; text-align:left; color:#696969 ">test string</body></html>

I don't know how you are creating your UIWebView. But I was having a similiar issue with a WTFCrash and I was able to solve it by making sure that the UIWebView was being created on the main thread:

- (void)createWebView{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self createWebView];
        });
        return;
    }
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
    //Rest of my code
}

Are you debugging your web view with Safari? If yes, the crash should be gone after you quit Safari.

I was facing a similar crash with WKWebView, and I was sure the same code worked happily 3 days ago. hlung 's comments saved me, you can find it HERE .

For your reference, following is a piece of the crash log in my case.

 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000dbbdfb10 Triggered by Thread: 0 Filtered syslog: None found Thread 0 Crashed: 0 JavaScriptCore 0x225d74c6 WTF::HashSet<JSC::MarkedArgumentBuffer*, WTF::PtrHash<JSC::MarkedArgumentBuffer*>, WTF::HashTraits<JSC::MarkedArgumentBuffer*> >::remove(JSC::MarkedArgumentBuffer* const&) + 54 1 JavaScriptCore 0x22620b41 JSC::VM::~VM() + 211 2 JavaScriptCore 0x22197e57 JSC::JSLockHolder::~JSLockHolder() + 73 3 JavaScriptCore 0x2248defd JSContextGroupRelease + 61 4 JavaScriptCore 0x2250e37d -[JSVirtualMachine dealloc] + 27 5 libobjc.A.dylib 0x1dac5195 objc_object::sidetable_release(bool) + 239 6 JavaScriptCore 0x2248d261 -[JSContext dealloc] + 125 7 libobjc.A.dylib 0x1dac5195 objc_object::sidetable_release(bool) + 239 8 JavaScriptCore 0x226470af WTF::RunLoop::TimerBase::timerFired(__CFRunLoopTimer*, void*) + 25 9 CoreFoundation 0x1e807357 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15 10 CoreFoundation 0x1e807029 __CFRunLoopDoTimer + 897 11 CoreFoundation 0x1e8069e1 __CFRunLoopDoTimers + 221 12 CoreFoundation 0x1e804cc5 __CFRunLoopRun + 1365 13 CoreFoundation 0x1e754073 CFRunLoopRunSpecific + 487 14 CoreFoundation 0x1e753e81 CFRunLoopRunInMode + 105 15 GraphicsServices 0x1ff00bfd GSEventRunModal + 157 16 UIKit 0x2390e82f -[UIApplication _run] + 575 17 UIKit 0x23908f61 UIApplicationMain + 151 18 MyApp 0x00488b29 0x2c000 + 4573993 19 libdyld.dylib 0x1df1e50b start + 3 

WebKit, the engine behind Web Views, can raise a crash when it sees a memory problem. These are identified by the special Hex Word 0x00000000bbadbeef as you have found.

The web page you are visiting seems trivial, so it is a surprise that you are having problems. I recommend you follow the WebKit debugging facilities described at: https://webkit.org/debugging-webkit/#ios-simulator

Please update your question with any logs or insights this reveals.

It was a Google Ads issue, already fixed for sure on version 7.35.0 of October, 17 and newer versions.

You should be able to fix the issue updating your pod.

From the Google Mobile Ads SDK Developers Team mailing:

"The issue has been fixed by the team and it should go live in an upcoming SDK release (release notes)." (August, 20)

"Issue has been fixed and live already." (October, 17)

Source: https://groups.google.com/d/msg/google-admob-ads-sdk/XL35wo6mQts/R2LlGZDxBwAJ

Release Notes: https://developers.google.com/admob/ios/rel-notes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM