ios – CoreTelephony崩溃(不可重现)

这种崩溃只发生在生产中

Crashed Thread
0   
libobjc.A.dylib 0x000000019843fbd0 objc_msgSend + 16
1   
CoreTelephony 0x00000001886bac5c _ZL25_ServerConnectionCallbackP20__CTServerConnectionPK10__CFStringPK14__CFDictionaryPv + 48
2   
CoreTelephony 0x00000001886d1030 ___ZNK13CTServerState21sendNotification_syncE7CTEventPK10__CFStringPK14__CFDictionary_block_invoke14 + 28
3   
libdispatch.dylib 0x0000000198a713ac _dispatch_call_block_and_release + 20
4   
libdispatch.dylib 0x0000000198a7136c _dispatch_client_callout + 12
5   
libdispatch.dylib 0x0000000198a7b4c0 _dispatch_queue_drain + 1212
6   
libdispatch.dylib 0x0000000198a74474 _dispatch_queue_invoke + 128
7   
libdispatch.dylib 0x0000000198a7d224 _dispatch_root_queue_drain + 660
8   
libdispatch.dylib 0x0000000198a7e75c _dispatch_worker_thread3 + 104
9   
libsystem_pthread.dylib 0x0000000198c4d2e4 _pthread_wqthread + 812
10  
libsystem_pthread.dylib 0x0000000198c4cfa8 start_wqthread + 0

这个也是

Crashed Thread
0   
libobjc.A.dylib 0x306e1f46 objc_msgSend + 6
1   
CoreTelephony 0x2291fc95 ___ZNK13CTServerState21sendNotification_syncE7CTEventPK10__CFStringPK14__CFDictionary_block_invoke14 + 14
2   
libdispatch.dylib 0x30c662e3 _dispatch_call_block_and_release + 8
3   
libdispatch.dylib 0x30c6e729 _dispatch_queue_drain + 1466
4   
libdispatch.dylib 0x30c68aad _dispatch_queue_invoke + 82
5   
libdispatch.dylib 0x30c6ff9f _dispatch_root_queue_drain + 392
6   
libdispatch.dylib 0x30c713c3 _dispatch_worker_thread3 + 92
7   
libsystem_pthread.dylib 0x30dcddc1 _pthread_wqthread + 666
8   
libsystem_pthread.dylib 0x30dcdb14 start_wqthread + 6

我从日志中猜测这些只是在设备休眠后的一段时间内发生的.因为崩溃和最后一个活动日志之间的时间戳相隔至少10分钟.我们自己不使用coretelophony,但我们使用的一些框架确实将coretelephony作为依赖.谁知道如何复制这个,或者知道如何解决这个问题?

最佳答案 当CTTelephonyNetworkInfo在发布后收到通知时会发生此错误.相反,你应该使用:

   static CTTelephonyNetworkInfo *netInfo; static dispatch_once_t dispatchToken; if (!netInfo) { dispatch_once(&dispatchToken, ^{ netInfo = [[CTTelephonyNetworkInfo alloc] init]; }); }

因为,正如其他人所说:
“有一个iOS错误会导致CTTelephonyNetworkInfo类的实例在被解除分配后有时会收到通知.而不是实例化,使用和释放实例,而是必须保留并永远不释放它们以解决错误.”
更多信息here

点赞