Crash on viewDidLoad

I have seen a few reports of crashes like the following:

0   HSTracker                            0x000000010b816eaf HSTracker.TrackersPreferences.viewDidLoad() -> () (TrackersPreferences.swift:0)
1   HSTracker                            0x000000010b816ef8 @objc HSTracker.TrackersPreferences.viewDidLoad() -> () (<compiler-generated>:0)
2   AppKit                               0x00007ff814505a92 -[NSViewController _sendViewDidLoad] + 86
3   AppKit                               0x00007ff8144eded2 -[NSViewController _loadViewIfRequired] + 384
4   AppKit                               0x00007ff8144edd16 -[NSViewController view] + 22
5   HSTracker                            0x000000010b99e2a3 Preferences.PreferencesTabViewController.(setWindowFrame in _1B0415CEB51F45D735E92B4C0504C08B)(for: __C.NSViewController, animated: Swift.Bool) -> () (PreferencesTabViewController.swift:193)
6   HSTracker                            0x000000010b99e7e3 closure #1 (__C.NSAnimationContext) -> () in Preferences.PreferencesTabViewController.transition(from: __C.NSViewController, to: __C.NSViewController, options: __C.NSViewControllerTransitionOptions, completionHandler: () -> ()?) -> () (PreferencesTabViewController.swift:169)
7   HSTracker                            0x000000010b99f089 partial apply forwarder for closure #1 (__C.NSAnimationContext) -> () in Preferences.PreferencesTabViewController.transition(from: __C.NSViewController, to: __C.NSViewController, options: __C.NSViewControllerTransitionOptions, completionHandler: () -> ()?) -> () (<compiler-generated>:0)
8   HSTracker                            0x000000010b99f0c1 partial apply forwarder for reabstraction thunk helper from @callee_guaranteed (@guaranteed __C.NSAnimationContext) -> () to @escaping @callee_guaranteed (@guaranteed __C.NSAnimationContext) -> () (<compiler-generated>:0)
9   HSTracker                            0x000000010b99e8e8 reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed __C.NSAnimationContext) -> () to @callee_unowned @convention(block) (@unowned __C.NSAnimationContext) -> () (<compiler-generated>:0)
10  AppKit                               0x00007ff8144b01ab +[NSAnimationContext runAnimationGroup:] + 54
11  HSTracker                            0x000000010b99dfed Preferences.PreferencesTabViewController.(animateTabTransition in _1B0415CEB51F45D735E92B4C0504C08B)(index: Swift.Int, animated: Swift.Bool) -> () (PreferencesTabViewController.swift:165)
12  HSTracker                            0x000000010b99da1f Preferences.PreferencesTabViewController.activateTab(index: Swift.Int, animated: Swift.Bool) -> () (PreferencesTabViewController.swift:85)
13  HSTracker                            0x000000010b9a45c3 Preferences.ToolbarItemStyleViewController.(toolbarItemSelected in _7A80F77958D94D970CD625FA09110540)(__C.NSToolbarItem) -> () (ToolbarItemStyleViewController.swift:0)
14  HSTracker                            0x000000010b9a461f @objc Preferences.ToolbarItemStyleViewController.(toolbarItemSelected in _7A80F77958D94D970CD625FA09110540)(__C.NSToolbarItem) -> () (<compiler-generated>:0)
15  AppKit                               0x00007ff8147f302f -[NSToolbarButton sendAction:to:] + 106
16  AppKit                               0x00007ff81479092e -[NSToolbarItemViewer mouseDown:] + 5172
17  AppKit                               0x00007ff814692bc1 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4858
18  AppKit                               0x00007ff814606d7e -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2581
19  AppKit                               0x00007ff81460614e -[NSWindow(NSEventRouting) sendEvent:] + 351
20  HSTracker                            0x000000010b9a5429 @objc Preferences.UserInteractionPausableWindow.sendEvent(__C.NSEvent) -> () (Utilities.swift:92)
21  AppKit                               0x00007ff814604524 -[NSApplication(NSEvent) sendEvent:] + 351
22  AppKit                               0x00007ff8148bd18b -[NSApplication _handleEvent:] + 64
23  AppKit                               0x00007ff814485d3e -[NSApplication run] + 622
24  AppKit                               0x00007ff814459c97 NSApplicationMain + 816
25  HSTracker                            0x000000010b762fe9 main (AppDelegate.swift:21)
26  ???                                  0x000000011616152e 0x0 + 0

Decoding the crash location with xcrun atos -i always points to a line dereferencing an IBOutlet that is nil.

Is there an explanation for while would the outlet not be connected?

The preferences pane is shown here:

https://github.com/HearthSim/HSTracker/blob/master/HSTracker/AppDelegate.swift#L595

The above crash happens on the following line:

https://github.com/HearthSim/HSTracker/blob/master/HSTracker/UIs/Preferences/TrackersPreferences.swift#L44

Any help is appreciated.

Is there an explanation for while would the outlet not be connected?

In some cases, IBOutlet appears connected, but connection is corrupted.

In case, you should:

  • remove the connection
  • recreate it
  • do a Clean Build Folder

Note: it is good to reference the whole project, in case someone needs to look at it, but it is much better to also insert the code where the error occurs in the post.

Crash on viewDidLoad
 
 
Q