noodlewerk / Spaghetti

A Cocoa framework for object mapping to and from not-so-RESTful webservices.
BSD 2-Clause "Simplified" License
23 stars 5 forks source link

iOS7 crash when an NSFetchedResultsController updates according to the results of an NWSCall. #2

Closed SpacyRicochet closed 11 years ago

SpacyRicochet commented 11 years ago

When an NSFetchedResultsController updates after a _managedObjectContextDidChange caused by a finished NWSCall, the app crashes. Strangely enough, this only happens after the first app launch. During the first launch, the entire app functions as normal. This includes performing the call multiple times.

To reproduce: With project iWhisper, checkout develop branch. Run for the first time. App functions as normal. Note the fact that tapping on one of the routes and going back causes a new call to be performed, during which the app doesn't crash. Run for second time, enjoy the crash.

To make it stop: Comment either the getRoutesWithOwner call in the IWRouteListTableViewController's viewWillAppear or return nil in the fetchedResultsControllerForTableViewDataSource: method.

Crash log:

Incident Identifier: 98AAD388-24E7-4905-89D3-821A0A2056ED
CrashReporter Key:   d2351b57f828cd0a24fb5e13c99f1fa50e03299e
Hardware Model:      iPod5,1
Process:             iWhisper [1436]
Path:                /var/mobile/Applications/8AB4BCC3-164F-40F4-A0EC-21FFC2C60162/iWhisper.app/iWhisper
Identifier:          com.iwhisper.iWhisper
Version:             37 (1.3)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2013-08-15 16:38:03.785 +0200
OS Version:          iOS 7.0 (11A4449a)
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x2f62ff86 __exceptionPreprocess + 126
1   libobjc.A.dylib                 0x396036aa objc_exception_throw + 34
2   CoreFoundation                  0x2f56b712 -[__NSDictionaryM setObject:forKey:] + 814
3   CoreData                        0x2f3ad4f2 -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:] + 1218
4   CoreData                        0x2f3abe3e -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1590
5   CoreFoundation                  0x2f5f210c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 8
6   CoreFoundation                  0x2f566302 _CFXNotificationPost + 1714
7   Foundation                      0x2ff2b158 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
8   CoreData                        0x2f3ab7e6 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 74
9   CoreData                        0x2f3ab77e -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 294
10  CoreData                        0x2f3c8ad8 -[NSManagedObjectContext(_NSInternalChangeProcessing) _postRefreshedObjectsNotificationAndClearList] + 108
11  CoreData                        0x2f3aa3f4 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 3852
12  CoreData                        0x2f3a34f4 _performRunLoopAction + 312
13  CoreFoundation                  0x2f5fb1c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
14  CoreFoundation                  0x2f5f8b64 __CFRunLoopDoObservers + 280
15  CoreFoundation                  0x2f5f8ea6 __CFRunLoopRun + 726
16  CoreFoundation                  0x2f563cd2 CFRunLoopRunSpecific + 518
17  CoreFoundation                  0x2f563ab6 CFRunLoopRunInMode + 102
18  GraphicsServices                0x33fa92d6 GSEventRunModal + 134
19  UIKit                           0x31b6820c UIApplicationMain + 1132
20  iWhisper                        0x0007314c main (main.m:16)
21  libdyld.dylib                   0x39b27ab2 tlv_initializer + 2

<...snip...>
leovandriel commented 11 years ago

Hello Bruno and thank you for reporting this bug. One of our iOS programmers will have a look and get back to you asap (en groeten aan Michiel)

SpacyRicochet commented 11 years ago

(NL: Als hij weer terug is ;)

Been trying to figure it out here, but drawing a blank up to figuring out it was doing this after the NWSCall.

SpacyRicochet commented 11 years ago

Tracked down to an NSFetchedResultController issue where -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:] because of the use of a cache.

Setting the cache name of the fetchedResultsController in question to nil fixes the issue. Still not sure why it happens though.

jvdijk commented 11 years ago

English below

FetchedResultsControllers en CacheNames gaan niet goed samen: http://stackoverflow.com/questions/17931009/nsfetchedresultscontroller-sectionnamekeypath-inconsistent

FetchedResultsControllers and CacheNames goes not good together: http://stackoverflow.com/questions/17931009/nsfetchedresultscontroller-sectionnamekeypath-inconsistent

On 27 aug. 2013, at 15:54, Bruno Scheele notifications@github.com wrote:

Tracked down to an NSFetchedResultController issue where -[NSFetchedResultsController(PrivateMethods) _preprocessUpdatedObjects:insertsInfo:deletesInfo:updatesInfo:sectionsWithDeletes:newSectionNames:treatAsRefreshes:] because of the use of a cache.

Setting the cache name of the fetchedResultsController in question to nil fixes the issue. Still not sure why it happens though.

— Reply to this email directly or view it on GitHub.

SpacyRicochet commented 11 years ago

That actually is about the sectionNameKeyPath, which wasn't used. Can imagine that doesn't work properly either though.