应用程序运行一段时间后,我收到一个SIGBART信号。 我怀疑它与在后台运行的计时器有关。
这是我用来调用循环计时器的代码:
Timer.scheduledTimer(timeInterval: 20 , target: self, selector: #selector(self.scheduledEventHandler), userInfo: nil, repeats: true)
这是处理程序:
@objc func scheduledEventHandler()
{
print("got event")
}
最后,这是堆栈跟踪:
thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00007fff5182cfce libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x0000000100fbb1b4 libsystem_pthread.dylib`pthread_kill + 333
frame #2: 0x00007fff5178930a libsystem_c.dylib`abort + 127
frame #3: 0x00007fff4f76bf8f libc++abi.dylib`abort_message + 245
frame #4: 0x00007fff4f76c12b libc++abi.dylib`default_terminate_handler() + 265
frame #5: 0x00007fff50af0eab libobjc.A.dylib`_objc_terminate() + 105
frame #6: 0x00007fff4f7877c9 libc++abi.dylib`std::__terminate(void (*)()) + 8
frame #7: 0x00007fff4f787478 libc++abi.dylib`__cxa_rethrow + 99
frame #8: 0x00007fff50aef139 libobjc.A.dylib`objc_exception_rethrow + 40
frame #9: 0x00007fff2a0f703e CoreFoundation`CFRunLoopRunSpecific + 638
frame #10: 0x00007fff29416866 HIToolbox`RunCurrentEventLoopInMode + 286
frame #11: 0x00007fff294165d6 HIToolbox`ReceiveNextEventCommon + 613
frame #12: 0x00007fff29416354 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
frame #13: 0x00007fff27713a23 AppKit`_DPSNextEvent + 2085
frame #14: 0x00007fff27ea8e6c AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
frame #15: 0x00007fff27708831 AppKit`-[NSApplication run] + 764
frame #16: 0x00007fff276d79d2 AppKit`NSApplicationMain + 804
frame #17: 0x0000000100034d2d App`main at AppDelegate.swift:15
frame #18: 0x00007fff516dd145 libdyld.dylib`start + 1
frame #19: 0x00007fff516dd145 libdyld.dylib`start + 1
*请注意,此任务在大多数情况下运行良好(很少崩溃)。
我会感谢任何建议,以便更好地了解此类崩溃的原因。