crashed on -[KKJSBridgeModuleRegister generateInstanceFromMetaClass:]
wjiuxing opened this issue · 5 comments
wjiuxing commented
目前只遇见过一次,iPhone X, iOS 14.1(18A8395)
#13 Thread SIGABRT
0 libsystem_kernel.dylib | __pthread_kill + 8
1 libsystem_pthread.dylib | pthread_kill + 212
2 libsystem_c.dylib | abort + 100
3 libsystem_malloc.dylib | 0x000000019c5b4000 + 118832
4 libsystem_malloc.dylib | 0x000000019c5b4000 + 119272
5 libsystem_malloc.dylib | free + 432
6 CoreFoundation | 0x000000018db6b000 + 1541900
7 CoreFoundation | 0x000000018db6b000 + 43576
8 匿了 | -[KKJSBridgeModuleRegister generateInstanceFromMetaClass:] (KKJSBridgeModuleRegister.m:0)
9 匿了 | -[KKJSBridgeMessageDispatcher dispatchCallbackMessageInQueue:] (KKJSBridgeMessageDispatcher.m:0)
10 匿了 | __55-[KKJSBridgeMessageDispatcher dispatchCallbackMessage:]_block_invoke (KKJSBridgeMessageDispatcher.m:59)
11 Foundation | 0x000000018ee04000 + 1187016
12 Foundation | 0x000000018ee04000 + 125720
13 Foundation | 0x000000018ee04000 + 1195904
14 Foundation | 0x000000018ee04000 + 124884
15 Foundation | 0x000000018ee04000 + 1198456
16 Foundation | 0x000000018ee04000 + 1197124
17 libdispatch.dylib | 0x000000018d85d000 + 277688
18 libdispatch.dylib | 0x000000018d85d000 + 397952
19 libdispatch.dylib | 0x000000018d85d000 + 236548
20 libdispatch.dylib | 0x000000018d85d000 + 234348
21 libdispatch.dylib | 0x000000018d85d000 + 287832
22 libdispatch.dylib | 0x000000018d85d000 + 289784
23 libsystem_pthread.dylib | _pthread_wqthread + 212
wjiuxing commented
又有一次,在 iOS 9.2.1(13D15) 设备上。
#13 Thread SIGSEGV
SEGV_ACCERR
0 libobjc.A.dylib | objc_msgSend + 8
1 CoreFoundation | -[__NSDictionaryM objectForKey:] + 148
2 匿了 | -[KKJSBridgeModuleRegister generateInstanceFromMetaClass:] (KKJSBridgeModuleRegister.m:0)
3 匿了 | -[KKJSBridgeMessageDispatcher dispatchCallbackMessageInQueue:] (KKJSBridgeMessageDispatcher.m:0)
4 匿了 | __55-[KKJSBridgeMessageDispatcher dispatchCallbackMessage:]_block_invoke (KKJSBridgeMessageDispatcher.m:59)
5 Foundation | ___NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
6 Foundation | -[NSBlockOperation main] + 96
7 Foundation | -[__NSOperationInternal _start:] + 604
8 Foundation | ___NSOQSchedule_f + 224
9 libdispatch.dylib | __dispatch_client_callout + 16
10 libdispatch.dylib | __dispatch_queue_drain + 864
11 libdispatch.dylib | __dispatch_queue_invoke + 464
12 libdispatch.dylib | __dispatch_root_queue_drain + 728
13 libdispatch.dylib | __dispatch_worker_thread3 + 112
14 libsystem_pthread.dylib | _pthread_wqthread + 1092
karosLi commented
嗯,知道问题了,感谢。最近有点忙。
karosLi commented
KKJSBridge 1.2.2 已经修复了
wjiuxing commented
非常感谢,辛苦了!
我在 fork 里修改了一次(见 wjiuxing/KKJSBridge commit b9d6b39),没有做详细的性能测试,粗略地看没啥影响。
我觉得在 KKJSBridgeMessageDispatcher
中 的 dispatchQueue
必要性不是很大,所以我把线程相关的去掉了,理由如下:
<WKScriptMessageHandler>
在主线程里回调到方法 userContentController:didReceiveScriptMessage:
并解析成 KKJSBridgeMessage
对象,在 dispatcher 里做一次线程调度,根据 KKJSBridgeMessage
找到具体的 module 与消息转发[1],然后再切换到主线程去调用 module 的方法。
为了 [1] 这件小事做了两次线程调度,有点得不偿失的感觉。
情况可能因项目而异,待我下个版本试试。
再次感谢
karosLi commented
嗯,主要考虑到还有 event 要处理,所以就统一单独放在一个队列里了。