I’m testing my app via TestFlight at the minute. Out of about 10,000 sessions, I have 6 crashes reported in sentry with the above title, when the app is backgrounded. Crash reports from TestFlight offer very little to go on:
Sentry offers a little bit more info, with the title/description of:
SIGABRT
Cannot form weak reference to instance (0x1055809f0) of class UIWindow. It is possible that this object was over-released, or is in the process of deallocation. > objc[6171]: Cannot form weak reference to instance (0x1055809f0) of class UIWindow. It is possible that this object was over-released, or is in the process of deallocation.
And breadcrumbs showing it happened after the app was backgrounded:
The only thing that I do consistently with the window when backgrounding is cover the screen with another window to protect users private info (financial data)
Inside SceneDelegate’s sceneDidEnterBackground
I run this
func showPrivacyProtectionWindow() {
guard let windowScene = self.window?.windowScene else {
return
}
privacyProtectionWindowVisible = true
privacyProtectionWindow = UIWindow(windowScene: windowScene)
privacyProtectionWindow?.rootViewController = UIStoryboard(name: "Login", bundle: nil).instantiateInitialViewController() ?? UIViewController()
privacyProtectionWindow?.windowLevel = .alert + 1
privacyProtectionWindow?.makeKeyAndVisible()
}
This covers the screen in a company logo, and upon returning to the app, forces the user to enter a passcode. Once done its removed via:
func hidePrivacyProtectionWindow() {
UIView.animate(withDuration: 0.3) { [weak self] in
self?.privacyProtectionWindow?.alpha = 0
} completion: { [weak self] finish in
self?.privacyProtectionWindow = nil
self?.privacyProtectionWindowVisible = false
self?.dismissedPrivacyProtectionWindow = true
}
}
This is the only thing I can think of that might be causing the issue. But it works 99.9999% of the time and I can’t reproduce the issue. Anyone have any idea/guidance on what might be causing this and how to address it?