Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIKit: [UIViewController mutableChildViewControllers] crash?

I recently received a crash report from itunes connect. Actually it's the only crash report I got from thousands of users, yet. It's an iPod4,1 device. Interesting parts are:

Date/Time:       2012-02-27 22:53:27.596 +0800
OS Version:      iPhone OS 5.0.1 (9A405)
Report Version:  104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x338958bf __exceptionPreprocess + 163
1   libobjc.A.dylib                 0x303891e5 objc_exception_throw + 33
2   UIKit                           0x31259749 -[UIViewController mutableChildViewControllers] + 1
3   UIKit                           0x31259349 -[UINavigationController pushViewController:animated:] + 37
4   MyApp                           0x000081e5 -[MyListController tableView:didSelectRowAtIndexPath:] (MyListController.m:207)
5   UIKit                           0x312d3565 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 945
6   UIKit                           0x3134bce7 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 159

It seems that the crash occurs when a row from a table view is selected, and a new view controller is pushed into navigation. According to my code, the new view controller is created already, so the crash occurred in UINavigationController.

It doesn't look like the fault of the code I wrote. And I wonder if I'm correct on this? How do I debug this problem?

like image 848
He Shiming Avatar asked Mar 18 '12 04:03

He Shiming


1 Answers

It sounds like the user got a low-memory warning. UINavigationControllers will retain their views, whereas tabbed ones will pop off the invisible ones. However, the low memory code is still getting called. Check your warning handlers prior to reaching that spot. Also, test by hitting "Simulate Memory Warning" under the hardware menu at all entry and exit points. http://forums.macrumors.com/showthread.php?t=876419 shows a mess of what happens when you don't. iphonedevsdk.com/forum/iphone-sdk-development/14225-uinavigationcontrollers-and-didreceivememorywarning.html has a nice comment or so on how to handle this.

I'm betting your view controller loads something and caused the memory warning. Ensure the user can't just stack tons of items on top of each other, and make sure your app is profiled to remove as many leaks as necessary to keep the app up.

The above may not be on the mark, but should be related.

Final note, don't use ARC. Something that disallows calling superclass functions is bound to screw up. If you understand bridging Core Foundation, then perhaps ARC is fine. I personally avoid it at all costs b/c memory becomes randomly handled by Apple's under-the-hood. I've seen their stuff fail way too much

like image 178
Stephen J Avatar answered Nov 13 '22 05:11

Stephen J