問題:
最近接到幾例啟動卡死,被watchdog kill掉的問題,都在ipad且系統(tǒng)版本為13.4.1上。排查崩潰日志后發(fā)現(xiàn)是鑰匙串操作問題,例如SecItemAdd調(diào)用后無響應。
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d?
代表主線程無響應,被watchdog殺掉了
具體原因:
Apple documented not correctly setting access control of the keychain could cause blocking on main thread. We added a new fix in the incoming release to always ensure we correctly set the right access control, instead of default value(kSecAttrAccessibleWhenUnlocked), that is too strict for our use case. We think this might be the reason other than calling it from another thread.
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.
等待直到調(diào)用applicationProtectedDataDidBecomeAvailable委托方法,然后再訪問鑰匙串。-無法解釋為何
在iOS中,對鑰匙串的調(diào)用是線程安全的,因此您還應該能夠在主線程之外執(zhí)行對鑰匙串API的調(diào)用,以避免任何阻塞請求鎖定您的UI。
It seems that there are circumstances where the security daemon becomes unresponsive。
守護進程無響應。
綜上:鑰匙串訪問本身是線程安全的,雖然耗時但主線程訪問本身不會有問題。大概率就是鑰匙串相關的安全守護進程無響應,屬于iOS系統(tǒng)自身的問題。
解決方案:
鑰匙串請求放異步線程,讓主線程可執(zhí)行下去。
作者:senlinwuran
鏈接:https://juejin.im/post/5ed5c4626fb9a047ee4c4f74
來源:掘金
著作權歸作者所有。商業(yè)轉載請聯(lián)系作者獲得授權,非商業(yè)轉載請注明出處。