DSBridge-IOS
DSBridge-IOS copied to clipboard
defaultText中如果不携带_dscbstub就会引起崩溃
[DWKWebView webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:]
defaultText中如果不携带_dscbstub就会引起崩溃 请问这是JS那边还是iOS端引起的,怎么去修改
我看了npm安装的dsbridge的源码,当第三个参数(cb)为函数(function)时才会有_dscbstub参数,请问一下这个参数是做什么用的呢? 为什么不带这个参数,IOS就会奔溃呢? 请问一下作者怎么解决这个问题~
@iblocker 你是怎么触发的?我在本地测试了一下,没有问题啊: 在JavaScript中:
prompt("你好","默认文本")
运行后效果:
@lijun1243939149 因为为了支持同步调用,js和Native通信是通过拦截prompt输入框来实现的,为了区分网页中正常的prompt调用和用于通信的调用,dsbridge通过添加存根标记来区分。
@wendux @iblocker 我也在这个方法中crash了 😭, 问题还没定位到,调试不会crash,打出企业release包就会crash.
crash堆栈如下: Date/Time: 2019-02-15 19:26:03.5828 +0800 Launch Time: 2019-02-15 19:25:56.9731 +0800 OS Version: iPhone OS 12.1 (16B92) Baseband Version: 3.11.00 Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000002119b9ca0 Termination Signal: Trace/BPT trap: 5 Termination Reason: Namespace SIGNAL, Code 0x5 Terminating Process: exc handler [3167] Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 CoreFoundation 0x00000002119b9ca0 getAtomTarget + 136 1 CoreFoundation 0x00000002119b1614 forwarding + 992 2 CoreFoundation 0x00000002119b1614 forwarding + 992 3 CoreFoundation 0x00000002119b345c _CF_forwarding_prep_0 + 92 4 Foundation 0x0000000212394910 +[_NSJSONReader validForJSON:depth:allowFragments:] + 100 5 Foundation 0x00000002124df460 __51+[_NSJSONReader validForJSON:depth:allowFragments:]_block_invoke + 112 6 CoreFoundation 0x000000021189200c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 232 7 Foundation 0x0000000212394974 +[_NSJSONReader validForJSON:depth:allowFragments:] + 200 8 dsBridge 0x0000000109fbbf6c +[JSBUtil objToJsonString:] + 32620 (JSBUtil.m:18) 9 dsBridge 0x0000000109fba668 -[DWKWebView call::] + 26216 (DWKWebView.m:323) 10 dsBridge 0x0000000109fb8f44 -[DWKWebView webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:] + 20292 (DWKWebView.m:0) 11 WebKit 0x000000022148e41c WebKit::UIDelegate::UIClient::runJavaScriptPrompt(WebKit::WebPageProxy*, WTF::String const&, WTF::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, WTF::Function<void + 1713180 (WTF::String const&)>&&) + 416 12 WebKit 0x000000022158dd50 WebKit::WebPageProxy::runJavaScriptPrompt(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::String const&, WTF::CompletionHandler<void + 2760016 (WTF::String const&)>&&) + 200 13 WebKit 0x00000002215b2420 void IPC::handleMessageDelayed<Messages::WebPageProxy::RunJavaScriptPrompt, WebKit::WebPageProxy, void (WebKit::WebPageProxy::)(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::String const&, WTF::CompletionHandler<void (WTF::String const&)>&&)>(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_deleteIPC::Encoder >&, WebKit::WebPageProxy, void (WebKit::WebPageProxy::)(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::String const&, WTF::CompletionHandler<void + 2909216 (WTF::String const&)>&&)) + 192 14 WebKit 0x0000000221397af4 IPC::MessageReceiverMap::dispatchSyncMessage+ 703220 (IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_deleteIPC::Encoder >&) + 128 15 WebKit 0x0000000221612424 WebKit::WebProcessProxy::didReceiveSyncMessage+ 3302436 (IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_deleteIPC::Encoder >&) + 36 16 WebKit 0x000000022135cfc4 IPC::Connection::dispatchSyncMessage+ 462788 (IPC::Decoder&) + 196 17 WebKit 0x000000022135a20c IPC::Connection::dispatchMessage+ 451084 (std::__1::unique_ptr<IPC::Decoder, std::__1::default_deleteIPC::Decoder >) + 140 18 WebKit 0x000000022135c9c0 IPC::Connection::dispatchIncomingMessages+ 461248 () + 752 19 JavaScriptCore 0x0000000218cb7d0c WTF::RunLoop::performWork+ 220428 () + 276 20 JavaScriptCore 0x0000000218cb7fd4 WTF::RunLoop::performWork+ 221140 (void) + 36 21 CoreFoundation 0x000000021193c1cc CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24 22 CoreFoundation 0x000000021193c14c __CFRunLoopDoSource0 + 88 23 CoreFoundation 0x000000021193ba30 __CFRunLoopDoSources0 + 176 24 CoreFoundation 0x00000002119368fc __CFRunLoopRun + 1040 25 CoreFoundation 0x00000002119361cc CFRunLoopRunSpecific + 436 26 GraphicsServices 0x0000000213bad584 GSEventRunModal + 100 27 UIKitCore 0x000000023ebad054 UIApplicationMain + 212 28 T3Go 0x0000000104e74980 main + 35200 (AppDelegate.swift:32) 29 libdyld.dylib 0x00000002113f6bb4 start + 4
crash的现象发生在: iOS 12的手机中, iOS 11的手机中目前没有crash。并且调试的时候,无法复现,打包成release包,装在iOS12的手机中,大概率会出现。
我的崩溃日志是这样的 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[DWKWebView webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:] was not called'
Last Exception Backtrace:
我这边的WKWebView继承了这个,但是没有用里面的js的时候,也会崩溃
最新版本的不会崩溃了 但是方法调用不到 是因为这个参数的问题 异步方式调用会有这个参数,同步方式没有这个参数,客户端应该和H5约定好 使用同步还是异步调用