0

Using Fabrics crash analytics or "Crashlytics" I am getting a large amount of crashes (I assume BAD_ACCESS) from the following method/property :

lazy var managedObjectModel: NSManagedObjectModel = {
    // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
    var modelURL = NSBundle.mainBundle().URLForResource("<app_name>", withExtension: "momd")
    return NSManagedObjectModel(contentsOfURL: modelURL!)!
}()

By large amount I mean 275 crashes for 150 users in just one day. It is working fine on most devices but I did have the issue once with my simulator and I reset the contents and restarted my machine and the error went away.

I am hoping there is a better solution than having to tell people who are calling our tech support.

Returned by fabric

Crashed: com.apple.main-thread
0  <app_name>                     0x100082f9c specialized AppDelegate.(persistentStoreCoordinator.getter).(closure #1) (AppDelegate.swift:314)
1  <app_name>                     0x10007e678 AppDelegate.saveContext() -> () (AppDelegate.swift:340)
2  <app_name>                     0x10007e014 @objc AppDelegate.applicationWillTerminate(UIApplication) -> () (AppDelegate.swift)
3  UIKit                          0x1949f0d48 -[UIApplication _terminateWithStatus:] + 244
4  UIKit                          0x194bef268 __102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke.2093 + 792
5  UIKit                          0x194bf2a18 _runAfterCACommitDeferredBlocks + 292
6  UIKit                          0x194be4ab4 _cleanUpAfterCAFlushAndRunDeferredBlocks + 528
7  UIKit                          0x194958724 _afterCACommitHandler + 132
8  CoreFoundation                 0x18e7e49a0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
9  CoreFoundation                 0x18e7e2628 __CFRunLoopDoObservers + 372
10 CoreFoundation                 0x18e7e2a74 __CFRunLoopRun + 956
11 CoreFoundation                 0x18e712d94 CFRunLoopRunSpecific + 424
12 GraphicsServices               0x19017c074 GSEventRunModal + 100
13 UIKit                          0x1949cb130 UIApplicationMain + 208
14 <app_name>                     0x100069940 main (AppDelegate.swift:43)
15 libdyld.dylib                  0x18d72159c start + 4

Has anyone else run into this issue? We are using Swift 2.3 currently converting to Swift 3.1.

The function is called when applicationWillTerminate() is called. The modelURL is nil.

Jason F
  • 309
  • 4
  • 11

1 Answers1

0

I also observed similar situation in my app. I once or twice had this error on simulator.

According to my observations it's happens when user swipes app from App Switcher (and removes it from memory). My guess is that Bundle.main becomes unavailable earlier and app cannot finish something.

I didn't have any contact from users that observed that. It looks like that they can't observe this because they just killed the app. So it's probably harmless (even if annoying).

franiis
  • 1,378
  • 1
  • 18
  • 33