WKWebView在acceleratedAnimationDidStart中崩溃

35

我的客户端应用程序出现了故障,除了在WTFCrash处,我没有从堆栈跟踪中得到太多有用的信息。

我正在使用一个WKWebView实例来显示一个具有基于CSS的动画和视频的网页。该问题发生在iOS 8和9上的各种设备上(从iPhone 5c到6s以及类似范围的iPad)。

WKWebView在其自己的进程中运行,而不是应用程序的进程。当崩溃发生时,留下一个白色的图层覆盖在主应用程序上,使其无法访问,尽管其进程并未受到影响。

查看设备日志,我发现来自com.apple.WebKit.WebContent进程的崩溃,它们所有的崩溃线程都有完全相同的日志。

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   JavaScriptCore                  0x0000000184c9f22c WTFCrash + 72
1   JavaScriptCore                  0x0000000184c9f224 WTFCrash + 64
2   WebKit                          0x0000000188ecd850 WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(unsigned long long, WTF::String const&, double) + 0
3   WebCore                         0x0000000184f2e70c WebCore::ThreadTimers::sharedTimerFiredInternal() + 148
4   WebCore                         0x0000000184f2e64c WebCore::timerFired(__CFRunLoopTimer*, void*) + 36
5   CoreFoundation                  0x000000018107d81c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
6   CoreFoundation                  0x000000018107d4c0 __CFRunLoopDoTimer + 884
7   CoreFoundation                  0x000000018107abd4 __CFRunLoopRun + 1520
8   CoreFoundation                  0x0000000180fa4d10 CFRunLoopRunSpecific + 384
9   Foundation                      0x00000001819b4d8c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 308
10  Foundation                      0x0000000181a09ff8 -[NSRunLoop(NSRunLoop) run] + 88
11  libxpc.dylib                    0x0000000180d68cf8 _xpc_objc_main + 660
12  libxpc.dylib                    0x0000000180d6aa2c xpc_main + 200
13  com.apple.WebKit.WebContent     0x0000000100057924 0x100054000 + 14628
14  libdyld.dylib                   0x0000000180b428b8 start + 4
以下是我们用来复现问题的一些示例 HTML/CSS 代码:

        var initialWidth = 100;
        window.addEventListener('load', function() {
          var div = document.getElementById('mytest');
          div.className = '';
          setInterval(function() {
            initialWidth += 10;
            if (initialWidth > 1000) {
              initialWidth = 1;
            }
            div.style.height = initialWidth + 'px';
          }, 40);
        }, false);
        body {
          background-color: #4cb9e4;
        }
        
        div#mytest {
          position: absolute;
          top: 0;
          width: 100%;
          height: 5000px;
          background-color: rgba(0, 0, 0, 0.7);
          text-align: center;
          overflow-y: hidden;
          -webkit-transition-property: height;
          -moz-transition-property: height;
          transition-property: height;
          -webkit-transition-duration: 0.5s;
          -moz-transition-duration: 0.5s;
          transition-duration: 0.5s;
          -webkit-transition-timing-function: ease;
          -moz-transition-timing-function: ease;
          transition-timing-function: ease;
        }
        
        div#mytest.hidden {
          height: 0;
        }
    <body>
      <div class="hidden" id="mytest">
        This is sample test
      </div>
    </body>

这看起来是否让大家感到熟悉?关于动画方面,我应该告诉网页工程师改变些什么?


你能发布一下包含CSS和HTML的代码吗? - Holly
3
要得到有价值的回答,你确实需要提供更多信息。Web视图可能非常棘手且麻烦,你需要尽可能多的信息来诊断它们。 - Scriptable
你有没有找到这个问题的解决办法?我的应用程序中有一个用户从WKWebView获取WebContent崩溃。 - Darren
1个回答

1
你应该在主线程中创建webView。
- (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
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接