开发者

iPhone crash during navigation controller animation, what are my options?

开发者 https://www.devze.com 2023-02-01 13:43 出处:网络
Been hunting down an intermittent crash in my app.Finally unlocked the secrets to symbolocating my crash report, and this is what I found:

Been hunting down an intermittent crash in my app. Finally unlocked the secrets to symbolocating my crash report, and this is what I found:

Incident Identifier: BFCE991E-5F9C-4F04-89AD-A0060EDE73D1
CrashReporter Key:   263d1a93e7ce2d75b397b6ef42b1bc4f29d22f9d
Hardware Model:      iPhone2,1
Process:         Wine Brain [2787]
Path:            /var/mobile/Applications/197DA851-3F8A-486E-8675-74B521A1FD72/Wine Brain.app/Wine Brain
Identifier:      Wine Brain
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2010-12-26 19:21:21.551 -0500
OS Version:      iPhone OS 4.2.1 (8C148a)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000d
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                 0x3199f464 objc_msgSend + 16
1   Wine Brain                      0x0000a0b4 0x1000 + 37044
2   CoreFoundation                  0x31436f74 -[NSObject(NSObject) release] + 24
3   libobjc.A.dylib                 0x319a0812 objc_setProperty + 114
4   UIKit                           0x338f74a0 -[UINavigationController setDisappearingViewController:] + 24
5   UIKit                           0x338f7478 -[UINavigationController _clearLastOperation] + 40
6   UIKit                           0x338f7394 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 556
7   UIKit                           0x338f7128 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 204
8   UIKit                           0x338f6dee -[UINavigationTransitionView _cleanupTransition] + 450
9   UIKit                           0x338f6c18 -[UINavigationTransitionView _navigationTransitionDidStop] + 36
10  UIKit                           0x338b4330 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
11  UIKit                           0x338c0c0e -[UIViewAnimationState animationDidStop:finished:] + 34
12  QuartzCore                      0x30a89ea2 run_animation_callbacks(double, void*) + 286
13  QuartzCore                      0x30a89d44 CA::timer_callback(__CFRunLoopTimer*, void*) + 116
14  CoreFoundation                  0x3148709c __CFRUNLOOP_I开发者_如何学编程S_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
15  CoreFoundation                  0x31486b54 __CFRunLoopDoTimer + 844
16  CoreFoundation                  0x314581ae __CFRunLoopRun + 1082
17  CoreFoundation                  0x31457c80 CFRunLoopRunSpecific + 224
18  CoreFoundation                  0x31457b88 CFRunLoopRunInMode + 52
19  GraphicsServices                0x35d664a4 GSEventRunModal + 108
20  GraphicsServices                0x35d66550 GSEventRun + 56
21  UIKit                           0x338d5322 -[UIApplication _run] + 406
22  UIKit                           0x338d2e8c UIApplicationMain + 664
23  Wine Brain                      0x000021ba 0x1000 + 4538
24  Wine Brain                      0x00002184 0x1000 + 4484

As you can see, this is all happening in library code, during an animation for a navigation view controller transition. It seems to happen on a navigate back.

Any ideas on what might cause this that I have control over and what to look for?

Update after some answers

I have this "pattern" whereby I re-use a view controller to show the results of different queries. My code has, say 3 pointers to FetchedResultsController instances, and it has a property currentResults that points to the one being used at the time.

.h file:

@interface MyViewController : UITableViewController <NSFetchedResultsControllerDelegate> {

  NSFetchedResultsController *controller1;
  NSFetchedResultsController *controller2;
  NSFetchedResultsController *controller3;

  // and other things unrelated
}

@property (nonatomic, retain) NSFetchedResultsController *currentController;

.m file:

-(void)clearAll {
  [controller1 release];
  controller1 = nil
  [controller2 release];
  controller2 = nil
  [controller3 release];
  controller3 = nil
}

When the caller is going to display my view controller, it firsts configures it for the particulars:

-(void)setupForSearch1 {
  self.currentController = [self controller1];
}
- (NSFetchedResultsController *)controller1 {

  NSFetchedResultsController *aController = [[[NSFetchedResultsController alloc] 
                                                 initWithFetchRequest:fetchRequest
                                                managedObjectContext:self.managedObjectContext 
                                                 sectionNameKeyPath:@"titleFirstLetter" 
                                                 cacheName:nil] autorelease];
  // error handling omitted for brevity
  controller1 = [aController retain];
  return controller1;
}    

So, it's actually hard for me to know for sure if I'm doing the right thing; in setupForSearch1, when I assign to the currentController propertly, I believe a release is done on the old reference. And, I've done a release on it in clearAll. But, since I do have two references to it, this seems OK to me.


I get these kind of errors when I release an object i should not - check your release actions.


It looks like the view controller that is about to go away during this animation is over-released. Check to make sure you're not releasing your view controllers too many times.


Whether the .xib mapped correctly? Check your didSelectRowAtIndexPath: part for any issues if you use tableView.


I recently came across this as I was having the same issue, and this answer did not really help me at all.

What turned out to be the problem was that in the view that was being popped from the UINavigationController, there was a variable for a view that was being set each time.

 resultsVC = [[ResultsTableViewController alloc]initWithSearchResults:self.resultsArray];
 [self.view addSubview:resultsVC.view];

That view would overwrite the previous one, even if it already existed, and add it to the subView. If the old view still existed, it was creating an orphaned view and causing the crash. the solution was to make sure that if that view existed, to remove it from the superview before re-creating it.

    [resultsVC.view removeFromSuperview];
    resultsVC = nil;

Hope this helps someone that comes after me! thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消