我们在iOS6中遇到随机崩溃,这是我们得到的崩溃堆栈:
0 libobjc.A.dylib 0x399d75b0 objc_msgSend + 15
1 CoreFoundation 0x31c945de ___CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
2 CoreFoundation 0x31c94290 ___CFRunLoopDoTimer + 272
3 CoreFoundation 0x31c92f00 ___CFRunLoopRun + 1232
4 CoreFoundation 0x31c05ebc CFRunLoopRunSpecific + 351
5 CoreFoundation 0x31c05d48 CFRunLoopRunInMode + 103
6 GraphicsServices 0x357dc2ea GSEventRunModal + 71
7 UIKit 0x33b1b300 UIApplicationMain + 1119
8 21 0x00224e96 _main(main.m:27)
9 libdyld.dylib 0x39e13b20 _start
SEGV_ACCERR
我们检查了相应的日志,崩溃恰好在应用程序启动后发生。
代码有点复杂。简而言之,这里只是在应用程序未启动时启动网络任务的计时器。
(void)startTimeOutDetect{
execOnMainThread(^{
@synchronized(self){
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(handleSyncTimeOut) object:nil];
[self performSelector:@selector(handleSyncTimeOut) withObject:nil afterDelay:70.f];
}
});
}
(void)cancelTimeOutDetect{
execOnMainThread(^{
@synchronized(self){
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(handleSyncTimeOut) object:nil];
}
});
}