I have looked through all the SO answers and everything seems to point to a divide by zero issue, however, I am not dividing by zero anywhere (at least that I can tell).

Total error I get:

> 
> 2017-08-17 10:08:49.760586-0500 APP[90643:6605106] **\* Assertion failure in -[NSLayoutConstraint \_setSymbolicConstant:constant:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1350/Layout.subproj/NSLayoutConstraint.m:711
>  2017-08-17 10:08:49.761100-0500 APP[90643:6605106] \*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSLayoutConstraint constant is not finite! That's illegal. constant:nan firstAnchor: secondAnchor:(null)'
>  \*\*\* First throw call stack:
>  (0x18ccaafe0 0x18b70c538 0x18ccaaeb4 0x18d743760 0x18d6e4b40 0x18d6e4a04 0x102ac2b7c 0x102ac28c4 0x102abddf4 0x102abe038 0x192df4838 0x192e8f9a4 0x18cba06c0 0x18cb976fc 0x192df4ac0 0x192df45a8 0x19312d080 0x193069594 0x19305b630 0x192dcf28c 0x18cc589a8 0x18cc56630 0x18cc56a7c 0x18cb86da4 0x18e5f1074 0x192e41c9c 0x100038ec8 0x18bb9559c)
>  libc++abi.dylib: terminating with uncaught exception of type NSException
> 
> 
> 

As it does talk about .width, it seems that a divide by zero might be the issue, though I have triple checked my code and only have one division anywhere in the code:

```
self.startButton.frame = CGRect(x:self.view.frame.midX - (self.view.frame.midX / 2),y:self.view.frame.midY - 20,width:self.view.frame.midX,height:40)

```

Which is only there to center the button.

The crash is INCONSISTENT (which is always frustrating!), meaning that I can often repeat the same action and it works fine before a crash (sometimes after 2-3 times, other times, it happens right away...)

Here's the scenario and code around the issue:

I'm in a tabBarController (which has several tabs with all functions working fine) and receive a push notification (various push notifications work fine for setting all actions and pages using this same code).

```
let vc = currentViewController.storyboard?.instantiateViewController(withIdentifier: "\(rcView)")
 if vc != nil {
    currentViewController.present(vc!, animated: true, completion: nil)
   }

```

This takes me to a UIViewController that includes a map, directions, various buttons, etc. (again, working great ).

Here is where we see the crash SOMETIMES....

When we click the 'Cancel' button on the controller

```
let cancelButton = UIButton(type: .system)
cancelButton.addTarget(self, action: #selector(self.cancelIt), for: .touchUpInside)

```

which goes to the cancelIt function

```
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)

let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "Home") as! UITabBarController
UIApplication.shared.keyWindow?.rootViewController = viewController
viewController.selectedIndex = 0

```

After this cancel, I can send another push notification and SOMETIMES it works, while other times, it crashes.

When it crashes, I get the error listed above and in AppDelegate.swift, a red line highlighting

```
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

```

with a "Thread 1: signal SIGABRT" (which I have seen before and usually means a duplicate name on the main storyboard)

I'm pretty sure this is all related to the less-than-elegant (IMHO) way of moving from the tabBarController to the UIViewController, though why is it so inconsistent?

Other ways of doing this switchover are welcome - I did a lot of research on how others do it and this seems to be the most clean, but working 'sometimes' isn't going to make the client happy!