问题:
最近接到几例启动卡死,被watchdog kill掉的问题,都在ipad且系统版本为13.4.1上。排查崩溃日志后发现是钥匙串操作问题,例如SecItemAdd调用后无响应。
具体原因:
Without any code it's difficult to give you concrete feedback, but my guess is that you're attempting to access the Keychain from the main thread before it's available, locking up the application.
在主线程可用之前从主线程访问keychain,从而锁定了应用程序。
Wait until the applicationProtectedDataDidBecomeAvailable delegate method is called before accessing the keychain. Calls to the keychain are thread-safe in iOS, so you should also be able to perform calls to keychain APIs off the main thread to avoid any blocking requests from locking up your UI.
等待直到调用applicationProtectedDataDidBecomeAvailable委托方法,然后再访问钥匙串。-无法解释为何
在iOS中,对钥匙串的调用是线程安全的,因此您还应该能够在主线程之外执行对钥匙串API的调用,以避免任何阻塞请求锁定您的UI。
It seems that there are circumstances where the security daemon becomes unresponsive。
守护进程无响应。
综上:钥匙串访问本身是线程安全的,虽然耗时但主线程访问本身不会有问题。大概率就是钥匙串相关的安全守护进程无响应,属于iOS系统自身的问题。
解决方案:
钥匙串请求放异步线程,让主线程可执行下去。