WkWebView 崩溃

最近在做APP的时候,有时候当打开WebView(WKWebView)的时候, App 只会在我的设备上崩溃环境为 Mac OS 10.12.1 + Xcode 8.2 + iOS 10.2.1, 删掉App、 重启手机、 重启Xcode、 移除DerivedData都不能解决这个问题, 最后重启电脑才解决。

堆栈错误如下:

* thread #1: tid = 0x11a50, 0x00000001937306f0 JavaScriptCore`JSC::JSGlobalObject::~JSGlobalObject() + 36, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10a2abe28)
    frame #0: 0x00000001937306f0 JavaScriptCore`JSC::JSGlobalObject::~JSGlobalObject() + 36
    frame #1: 0x00000001937306b4 JavaScriptCore`JSC::Heap::FinalizerOwner::finalize(JSC::Handle, void*) + 24
    frame #2: 0x0000000193f15fe0 JavaScriptCore`JSC::WeakBlock::lastChanceToFinalize() + 80
    frame #3: 0x0000000193daaeb4 JavaScriptCore`JSC::MarkedBlock::lastChanceToFinalize() + 40
    frame #4: 0x0000000193daa2e8 JavaScriptCore`JSC::MarkedAllocator::lastChanceToFinalize() + 96
  * frame #5: 0x0000000193dab670 JavaScriptCore`void JSC::MarkedSpace::forEachAllocator() + 92
    frame #6: 0x0000000193bdb7dc JavaScriptCore`JSC::Heap::lastChanceToFinalize() + 128
    frame #7: 0x0000000193ebf310 JavaScriptCore`JSC::VM::~VM() + 220
    frame #8: 0x00000001936852d4 JavaScriptCore`JSC::JSLockHolder::~JSLockHolder() + 84
    frame #9: 0x0000000193caf648 JavaScriptCore`JSContextGroupRelease + 80
    frame #10: 0x0000000193d5a8d4 JavaScriptCore`-[JSVirtualMachine dealloc] + 36
    frame #11: 0x0000000193cae958 JavaScriptCore`-[JSContext dealloc] + 140
    frame #12: 0x0000000193f40d58 JavaScriptCore`WTF::RunLoop::TimerBase::timerFired(__CFRunLoopTimer*, void*) + 44
    frame #13: 0x000000018f7271d8 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
    frame #14: 0x000000018f726eec CoreFoundation`__CFRunLoopDoTimer + 872
    frame #15: 0x000000018f7267a8 CoreFoundation`__CFRunLoopDoTimers + 244
    frame #16: 0x000000018f7243a4 CoreFoundation`__CFRunLoopRun + 1572
    frame #17: 0x000000018f6522b8 CoreFoundation`CFRunLoopRunSpecific + 444
    frame #18: 0x0000000191106198 GraphicsServices`GSEventRunModal + 180
    frame #19: 0x00000001956997fc UIKit`-[UIApplication _run] + 684
    frame #20: 0x0000000195694534 UIKit`UIApplicationMain + 208
    frame #21: 0x00000001001da8b4 TravelApp`main(argc=1, argv=0x000000016fd83940) + 124 at main.m:14
    frame #22: 0x000000018e6355b8 libdyld.dylib`start + 4

最后再一次偶然的情况下,才发现问题的根源是 Safari Web Insepector

原因是我使用这个工具Debug App中的网页内容, 打开Safari 中的Develop Tool, 并且仅当Automatically Show Web Inspector for JSContexts 被勾选的情况下才会出现。

WkWebView 崩溃_第1张图片
Paste_Image.png

严重怀疑这个是iOS 10.2.1的Bug, 因为在之前并没有出现过。

你可能感兴趣的:(WkWebView 崩溃)