根据UIApplicationDidBecomeActiveNotification,我触发一个SecItemUpdate调用:
OSStatus itemError = SecItemUpdate((__bridge CFDictionaryRef)secItemSearchParams, (__bridge CFDictionaryRef)secItemNewData);
我有一个设备(64位+ iOS 7)需要大约10秒来评估这一行,它返回时没有错误(OSStatus = errSecSuccess)。
我一直得到一个8badf00d异常(“未能及时恢复”异常,请参阅附加的调用堆栈),所以作为补救措施,我将这个逻辑从主线程中移出。但是我不明白为什么SecItemUpdate花了这么多时间来评估!似乎KeyChain或其他一些资源尚未准备就绪。
任何线索?
Call stack:
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
com.MyApp123.MyApp123 failed to resume in time
Elapsed total CPU time (seconds): 3.670 (user 3.670, system 0.000), 15% CPU
Elapsed application CPU time (seconds): 0.022, 0% CPU
Thread 0:
0 libsystem_kernel.dylib 0x0000000193d49cdc semaphore_wait_trap + 8
1 libxpc.dylib 0x0000000193e006b0 xpc_connection_send_message_with_reply_sync + 180
2 Security 0x0000000189f1157c securityd_message_with_reply_sync + 92
3 Security 0x0000000189f21350 __SecItemUpdate_block_invoke + 300
4 Security 0x0000000189f20228 SecOSStatusWith + 28
5 Security 0x0000000189f211e0 SecItemUpdate + 136
6 MyApp123 0x000000010059472c +[WDKeyChainUtils setKeyChainData:forLabel:] (WDKeyChainUtils.m:39)
7 MyApp123 0x0000000100173e68 -[DateWatcher setLastSeenDate:] (DateWatcher.m:123)
8 MyApp123 0x0000000100173ae8 -[DateWatcher watchLogic] (DateWatcher.m:96)
9 MyApp123 0x0000000100173b68 -[DateWatcher watchOnAppBecomeActiveOrMainKeyDidBecomeAvailable:] (DateWatcher.m:101)
10 CoreFoundation 0x000000018711f5b0 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 16
11 CoreFoundation 0x000000018706c100 _CFXNotificationPost + 2060
12 Foundation 0x0000000187bfe744 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
13 UIKit 0x000000018a1b92e4 -[UIApplication _stopDeactivatingForReason:] + 424
14 UIKit 0x000000018a36161c -[UIApplication _handleApplicationResumeEvent:] + 1136
15 UIKit 0x000000018a13532c -[UIApplication handleEvent:withNewEvent:] + 1876
16 UIKit 0x000000018a134acc -[UIApplication sendEvent:] + 100
17 MyApp123 0x0000000100266738 -[WDApplication sendEvent:] (WDApplication.m:38)
18 UIKit 0x000000018a1a1040 _UIApplicationHandleEvent + 668
19 GraphicsServices 0x000000018cd53500 _PurpleEventCallback + 672
20 GraphicsServices 0x000000018cd5302c PurpleEventCallback + 44
21 CoreFoundation 0x000000018712ae8c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
22 CoreFoundation 0x000000018712adec __CFRunLoopDoSource1 + 440
23 CoreFoundation 0x0000000187129010 __CFRunLoopRun + 1616
24 CoreFoundation 0x0000000187069c1c CFRunLoopRunSpecific + 448
25 GraphicsServices 0x000000018cd51c08 GSEventRunModal + 164
26 UIKit 0x000000018a19afd8 UIApplicationMain + 1152
27 MyApp123 0x0000000100110dc8 main (main.m:17)
28 libdyld.dylib 0x0000000193c67a9c start + 0