WKWebView在acceleratedAnimationDidStart中崩溃

The*_*off 36 css webkit gpu ios wkwebview

我正在客户端的应用程序上发生崩溃,而不是很多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
Run Code Online (Sandbox Code Playgroud)

这是我们用来重现问题的一些示例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);
Run Code Online (Sandbox Code Playgroud)
        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;
        }
Run Code Online (Sandbox Code Playgroud)
    <body>
      <div class="hidden" id="mytest">
        This is sample test
      </div>
    </body>
Run Code Online (Sandbox Code Playgroud)

这对任何人来说都很熟悉吗?有什么东西我应该告诉网络工程师改变动画吗?

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