gpt4 book ai didi

ios - WKWebView 在 acceleratedAnimationDidStart 中崩溃

转载 作者:IT王子 更新时间:2023-10-29 07:42:56 28 4
gpt4 key购买 nike

我在客户端的应用程序上发生了崩溃,除了在 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>

有人觉得这很眼熟吗?关于动画,有什么我应该告诉网络工程师更改的吗?

最佳答案

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

关于ios - WKWebView 在 acceleratedAnimationDidStart 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37172795/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com