奇怪的iOS UIWebView Crash称为WTF Crash

ina*_*eli 6 crash uiwebview ios

我在一些屏幕中使用UIWebViews,因为我需要一个完美的Html文本解析.

根据崩溃报告,在这些屏幕上发生了大量的崩溃,称为WTF崩溃.这是一个崩溃的痕迹

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
Run Code Online (Sandbox Code Playgroud)

此崩溃没有操作系统版本或设备关系.

我也不喜欢使用UIWebView.它像其他所有组件一样被添加到nib中,在实现文件中我使用它如下所示

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];
Run Code Online (Sandbox Code Playgroud)

有关如何解决WTF崩溃的任何建议?

编辑:这是htmlString的样子

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>
Run Code Online (Sandbox Code Playgroud)

Jan*_*Jan 1

我不知道你是如何创建 UIWebView 的。但我在 WTFCrash 上遇到了类似的问题,我能够通过确保在主线程上创建 UIWebView 来解决它:

- (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
}
Run Code Online (Sandbox Code Playgroud)