I'm seeing a mysterious crash from Crashlytics that I can't determine the cause of. Any possible guidance would be appreciated.
In my HomeViewController class in the viewWillAppear method, I'm calling the following method:
func showSplash() {
view.bringSubview(toFront: splashView)
self.navigationController?.isNavigationBarHidden = true
UIApplication.shared.setStatusBarHidden(true, with: UIStatusBarAnimation.none)
splashVC = self.storyboard!.instantiateViewController(withIdentifier: "SplashViewController") as? SplashViewController
if splashVC != nil && splashView != nil {
splashVC!.delegate = self
splashVC!.view.frame = splashView.bounds
addChildViewController(splashVC!) // CRASHING ON THIS LINE
splashView.addSubview(splashVC!.view)
splashVC!.didMove(toParentViewController: self)
}
}
Crashlytics is reporting that for a small number of users, it's crashing on the addChildViewController() line in the above method, and it's crashing multiple times for this small subset of users. I'm unable to reproduce. Here's the log from Crashlytics:
Crashed: Thread
0 TSMNJ 0x10009e5b4 HomeViewController.showSplash() -> () (HomeViewController.swift:173)
1 TSMNJ 0x1000a7c34 specialized HomeViewController.viewWillAppear(Bool) -> () (HomeViewController.swift:125)
2 TSMNJ 0x10009d838 @objc HomeViewController.viewWillAppear(Bool) -> () (HomeViewController.swift)
3 UIKit 0x19351a754 -[UIViewController _setViewAppearState:isAnimating:] + 624
4 UIKit 0x19351a4cc -[UIViewController __viewWillAppear:] + 156
5 UIKit 0x1935bb740 -[UINavigationController _startTransition:fromViewController:toViewController:] + 752
6 UIKit 0x1935baf28 -[UINavigationController _startDeferredTransitionIfNeeded:] + 856
7 UIKit 0x1935baadc -[UINavigationController __viewWillLayoutSubviews] + 64
8 UIKit 0x1935baa40 -[UILayoutContainerView layoutSubviews] + 188
9 UIKit 0x1934ffa80 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1196
10 QuartzCore 0x1909ad9d8 -[CALayer layoutSublayers] + 148
11 QuartzCore 0x1909a24cc CA::Layer::layout_if_needed(CA::Transaction*) + 292
12 QuartzCore 0x1909a238c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
13 QuartzCore 0x19091f3e0 CA::Context::commit_transaction(CA::Transaction*) + 252
14 QuartzCore 0x190946a68 CA::Transaction::commit() + 512
15 QuartzCore 0x190947488 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 120
16 CoreFoundation 0x18d5fa0c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
17 CoreFoundation 0x18d5f7cf0 __CFRunLoopDoObservers + 372
18 CoreFoundation 0x18d5262d8 CFRunLoopRunSpecific + 476
19 UIKit 0x19356d7b0 -[UIApplication _run] + 608
20 UIKit 0x193568534 UIApplicationMain + 208
21 TSMNJ 0x1000750e8 main (AppDelegate.swift:20)
22 libdispatch.dylib 0x18c5095b8 (Missing)