项目常见崩溃8(陆续更新)

2018-01-01  本文已影响249人  bigParis

今天介绍一个WKUIDelegate引起的崩溃

崩溃堆栈

Thread 0 (crashed)
 0  CoreFoundation!__exceptionPreprocess + 0x7c
    Found by: given as instruction pointer in context
 1  libobjc.A.dylib!objc_exception_throw + 0x34
    Found by: previous frame's frame pointer
 2  CoreFoundation!+[NSException raise:format:] + 0x70
    Found by: previous frame's frame pointer
 3  WebKit!WebKit::CompletionHandlerCallChecker::~CompletionHandlerCallChecker() + 0x8c
    Found by: previous frame's frame pointer
 4  WebKit!WTF::ThreadSafeRefCounted<WebKit::CompletionHandlerCallChecker>::deref() const + 0x24
    Found by: previous frame's frame pointer
 5  WebKit!WTF::BlockPtr<void ()> WTF::BlockPtr<void ()>::fromCallable<WebKit::UIDelegate::UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, WTF::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, WTF::Function<void ()>&&)::$_1>(WebKit::UIDelegate::UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, WTF::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, WTF::Function<void ()>&&)::$_1)::'lambda'(void const*)::__invoke(void const*) + 0x1c
    Found by: previous frame's frame pointer
 6  libsystem_blocks.dylib!_Block_release + 0x9c
    Found by: previous frame's frame pointer
 7  WebKit!WebKit::UIDelegate::UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, WTF::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, WTF::Function<void ()>&&) + 0x190
    Found by: previous frame's frame pointer
 8  WebKit!WebKit::WebPageProxy::runJavaScriptAlert(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::Ref<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply>&&) + 0x90
    Found by: previous frame's frame pointer
 9  WebKit!void IPC::handleMessageDelayed<Messages::WebPageProxy::RunJavaScriptAlert, WebKit::WebPageProxy, void (WebKit::WebPageProxy::*)(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::Ref<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply>&&)>(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_delete<IPC::Encoder> >&, WebKit::WebPageProxy*, void (WebKit::WebPageProxy::*)(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::Ref<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply>&&)) + 0xa0
    Found by: previous frame's frame pointer
10  WebKit!IPC::MessageReceiverMap::dispatchSyncMessage(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_delete<IPC::Encoder> >&) + 0x7c
    Found by: previous frame's frame pointer
11  WebKit!WebKit::WebProcessProxy::didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_delete<IPC::Encoder> >&) + 0x20
    Found by: previous frame's frame pointer
12  WebKit!IPC::Connection::dispatchSyncMessage(IPC::Decoder&) + 0xc0
    Found by: previous frame's frame pointer
13  WebKit!IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) + 0x88
    Found by: previous frame's frame pointer
14  WebKit!IPC::Connection::dispatchOneMessage() + 0xe4
    Found by: previous frame's frame pointer
15  JavaScriptCore!WTF::RunLoop::performWork() + 0xc4
    Found by: previous frame's frame pointer
16  JavaScriptCore!WTF::RunLoop::performWork(void*) + 0x20
    Found by: previous frame's frame pointer
17  CoreFoundation!__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 0x14
    Found by: previous frame's frame pointer
18  CoreFoundation!__CFRunLoopDoSource0 + 0x54
    Found by: previous frame's frame pointer
19  CoreFoundation!__CFRunLoopDoSources0 + 0xc8
    Found by: previous frame's frame pointer
20  CoreFoundation!__CFRunLoopRun + 0x414
    Found by: previous frame's frame pointer
21  CoreFoundation!CFRunLoopRunSpecific + 0x1b0
    Found by: previous frame's frame pointer
22  GraphicsServices!GSEventRunModal + 0x60
    Found by: previous frame's frame pointer
23  UIKit!UIApplicationMain + 0xcc
    Found by: previous frame's frame pointer
24  yyxunhuan!main [main.mm : 16 + 0x10]
    Found by: previous frame's frame pointer
25  libdyld.dylib!start + 0x0
    Found by: previous frame's frame pointer

runJavaScriptAlert是关键点, 这里提示是js里调alert出问题了, 且崩溃的时候控制台会输出

12-31 12:56:09.585     Exception Name: NSInternalInconsistencyException
12-31 12:56:09.588     Exception Reason: Completion handler passed to -[MFWebViewDelegateHandler webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:] was not called

也就是说WKUIDelegate传给我们的block:completionHandler, 我们没有回调, 这里就导致了崩溃, 实际上在使用WKWebView的时候, 有很多类似的情况, 不使用系统传给我们的block系统就死给你看, 没太看懂为什么苹果要这样做, 但是开发的时候一定要注意, 确保各个路径下completionHandler都要使用到.

上一篇下一篇

猜你喜欢

热点阅读