У меня проблемы с отладкой недавнего Cra sh. Мне удалось получить обратную связь от Firebase, но я не могу воспроизвести условия. Cra sh происходит, когда я нажимаю кнопку «Домой» и несколько раз возвращаюсь в приложение.
Вот трассировка стека и код, который я связал с операциями.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS
Crashed: com.apple.main-thread
0 Foundation 0x184732c94 __NSOQSchedule + 248
1 Foundation 0x18465ab50 -[NSOperationQueue setSuspended:] + 164
2 UIKitCore 0x18849e420 -[UIApplication _stopDeactivatingForReason:] + 1172
3 UIKitCore 0x187c17628 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 436
4 UIKitCore 0x187c1798c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 756
5 UIKitCore 0x187c17214 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 340
6 UIKitCore 0x187c1b930 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 196
7 UIKitCore 0x188001604 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 856
8 UIKitCore 0x1880fca0c _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 260
9 UIKitCore 0x187c1b66c __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 156
10 UIKitCore 0x1880fc8f4 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 108
И в классе AppDelegate:
let alertQueue = Foundation.OperationQueue()
func applicationDidFinishLaunching(_ application: UIApplication) {
...
alertQueue.isSuspended = true
alertQueue.maxConcurrentOperationCount = 1
...
}
func applicationDidBecomeActive(_ application: UIApplication) {
alertQueue.isSuspended = false
}
func applicationWillResignActive(_ application: UIApplication) {
alertQueue.isSuspended = true
}
Operation Class
class CustomOperation: Operation {
private var _finished = false
private var _executing = false
override var isAsynchronous: Bool {return true}
override var isExecuting: Bool {return _executing}
override var isFinished: Bool {return _finished}
override func start() {
guard !isCancelled else {
reportFinish()
return
}
reportStart()
}
override func cancel() {
self.reportFinish()
super.cancel()
}
private func reportStart() {
if !_executing {
willChangeValue(for: \.isExecuting)
_executing = true
didChangeValue(for: \.isExecuting)
}
}
private func reportFinish() {
let willChangeExecuting = _executing
let willChangeFinised = !_finished
if willChangeExecuting {
willChangeValue(for: \.isExecuting)
}
if willChangeFinised {
willChangeValue(for: \.isFinished)
}
if willChangeExecuting {
_executing = false
}
if willChangeFinised {
_finished = true
}
if willChangeExecuting {
didChangeValue(for: \.isExecuting)
}
if willChangeFinised {
didChangeValue(for: \.isFinished)
}
}
}