Random UISearchDisplayController Crash (iOS 7) - ios

I've been trying to fix a crash that around 50% of my users are having. The crash began after I implemented a UISearchDisplayController (ie. added a search bar to a table view), but I haven't been able to reproduce the crash, not even once. According to my users, they instantly crash (or freeze) when they open the table view that has the UISearchDisplayController.
According to Crashlytics, the crash is happening at:
-[UISearchDisplayController _updateTableHeaderBackgroundViewInTableView:amountScrolledUnder:]
I've created the UITableView programmatically, but I've added the UISearchBar/UISearchDisplayController mostly via IB.
Regarding the "table header background view" that the crash seems to be referring to, I was doing two things previously. Firstly, I was setting the table views background view to nil:
[self.tableView setBackgroundView:nil];
Secondly, I was also doing this:
- (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section
{
if (aTableView != nil && self.searchDisplayController != nil)
{
if (self.searchDisplayController.isActive)
{
return nil;
}
else
{
return [super sectionAtIndex:section].headerTitle;
}
}
else
{
return [super sectionAtIndex:section].headerTitle;
}
}
I've since then change the background view to a __strong UIView with a frame size of CGZero, meaning I've just added a strong, empty view to the background.
Additionally, in the second piece of code, instead of returning nil, I'm now returning an empty string, #"".
I haven't pushed these changes to my users yet, because I want to be sure before I do so. Tried to google the UISearchDisplayController function but didn't really find anything, so I'm guessing it's an iOS 7-specific issue, which makes it even harder to track down, especially since I can't reproduce it.
Anyway, I'm hoping that someone has either experienced this kind of problem themselves, or that someone has some sort of idea on what could be causing this.
UPDATE: Here's the full crash.
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x0000000191f179d0 objc_msgSend + 16
1 UIKit 0x0000000188f63820 -[UISearchDisplayController _updateTableHeaderBackgroundViewInTableView:amountScrolledUnder:] + 164
2 UIKit 0x0000000188f63394 -[UISearchBar _didMoveFromWindow:toWindow:] + 312
3 UIKit 0x0000000188e6e42c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
4 UIKit 0x0000000188e9280c -[UIScrollView _didMoveFromWindow:toWindow:] + 68
5 UIKit 0x0000000188e6dba0 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 148
6 UIKit 0x0000000188e6d998 -[UIView(Hierarchy) _postMovedFromSuperview:] + 292
7 UIKit 0x0000000188e7c4ec -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1628
8 UIKit 0x000000018906af44 -[_UIParallaxDimmingView didMoveToWindow] + 144
9 UIKit 0x0000000188e6e768 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1512
10 UIKit 0x0000000188e6e42c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
11 UIKit 0x0000000188e6dba0 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 148
12 UIKit 0x0000000188e6d998 -[UIView(Hierarchy) _postMovedFromSuperview:] + 292
13 UIKit 0x0000000188e7c4ec -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1628
14 UIKit 0x000000018906a67c __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 1636
15 UIKit 0x0000000188e82bb8 +[UIView(Animation) performWithoutAnimation:] + 88
16 UIKit 0x0000000189069d54 -[_UINavigationParallaxTransition animateTransition:] + 828
17 UIKit 0x0000000189022078 -[UINavigationController _startCustomTransition:] + 2724
18 UIKit 0x0000000188f2c794 -[UINavigationController _startDeferredTransitionIfNeeded:] + 464
19 UIKit 0x0000000188f2c564 -[UINavigationController __viewWillLayoutSubviews] + 56
20 UIKit 0x0000000188f2c4e4 -[UILayoutContainerView layoutSubviews] + 200
21 UIKit 0x0000000188e6ed78 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 348
22 QuartzCore 0x0000000188a6b0cc -[CALayer layoutSublayers] + 184
23 QuartzCore 0x0000000188a65c94 CA::Layer::layout_if_needed(CA::Transaction*) + 300
24 QuartzCore 0x0000000188a65b4c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
25 QuartzCore 0x0000000188a653d4 CA::Context::commit_transaction(CA::Transaction*) + 280
26 QuartzCore 0x0000000188a65178 CA::Transaction::commit() + 424
27 QuartzCore 0x0000000188a5ea30 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
28 CoreFoundation 0x0000000185f5f7e0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
29 CoreFoundation 0x0000000185f5ca68 __CFRunLoopDoObservers + 372
30 CoreFoundation 0x0000000185f5cdf4 __CFRunLoopRun + 764
31 CoreFoundation 0x0000000185e9db38 CFRunLoopRunSpecific + 452
32 GraphicsServices 0x000000018b8c3830 GSEventRunModal + 168
33 UIKit 0x0000000188edc0e8 UIApplicationMain + 1156
34 Flash Reader 0x00000001000904dc main + 17 (main.m:17)
35 libdyld.dylib 0x0000000192507aa0 start + 4
UPDATE 2:
It seems like this is only happening on an iPhone 5S and that would also explain why I'm unable to reproduce this. I have a feeling that it's related to this block of code:
CGRect newBounds = self.tableView.bounds;
if (self.tableView.bounds.origin.y < 44)
{
newBounds.origin.y = newBounds.origin.y + self.searchDisplayController.searchBar.bounds.size.height;
self.tableView.bounds = newBounds;
}
// new for iOS 7
if (self.tableView != nil && self.staticContentSections.count > 0)
{
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:0 animated:YES];
}
I'm hoping that this is what causes the crash, because if so, I'm hoping to fix this by just doing this in viewWillAppear:
self.edgesForExtendedLayout = UIRectEdgeNone;
self.tableView.contentOffset = CGPointMake(0, 44);
UPDATE 3:
Well, that didn't fix it. This is still happening, either randomly or each time when the user has an iPhone 5S. It doesn't happen in the 5S simulator, but I can't debug it any further since I don't own a 5S. I'm starting to think that this is an iOS 7 bug, not a bug with the app itself.

I got the crash in iOS 8.0. I fixed it by setting searchBar.delegate = nil in dealloc (deinit) of the view controller.

Related

UICollectionViewData updateItemCounts Crash

I'm getting crashes from deep inside Apple's layout code for a UICollectionViewFlowLayout and I have no idea how to address these (stack trace below). Any suggestions would be greatly appreciated.
Details:
Unfortunately I can't reproduce the issue
The issue isn't frequent (it happens in less than 0.1% of sessions) but it's our #1 crash
#0. Crashed: com.apple.main-thread
0 libsystem_platform.dylib 0x1879490d4 __bzero + 36
1 UIKit 0x18e824e40 -[UICollectionViewData _updateItemCounts] + 544
2 UIKit 0x18e824e40 -[UICollectionViewData _updateItemCounts] + 544
3 UIKit 0x18e8e67e0 -[UICollectionViewData numberOfSections] + 28
4 UIKit 0x18f086bc0 -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:] + 612
5 UIKit 0x18f088834 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 152
6 UIKit 0x18e8e66b4 -[UICollectionViewFlowLayout prepareLayout] + 224
7 UIKit 0x18e7cf574 -[UICollectionViewData _prepareToLoadData] + 164
8 UIKit 0x18e7ceb5c -[UICollectionViewData validateLayoutInRect:] + 100
9 UIKit 0x18e7ce55c -[UICollectionView layoutSubviews] + 212
10 UIKit 0x18e76fa80 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1196
11 QuartzCore 0x18bc1d9d8 -[CALayer layoutSublayers] + 148
12 QuartzCore 0x18bc124cc CA::Layer::layout_if_needed(CA::Transaction*) + 292
13 QuartzCore 0x18bc1238c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
14 QuartzCore 0x18bb8f3e0 CA::Context::commit_transaction(CA::Transaction*) + 252
15 QuartzCore 0x18bbb6a68 CA::Transaction::commit() + 512
16 QuartzCore 0x18bbb7488 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 120
17 CoreFoundation 0x18886a0c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
18 CoreFoundation 0x188867cf0 __CFRunLoopDoObservers + 372
19 CoreFoundation 0x188868180 __CFRunLoopRun + 1024
20 CoreFoundation 0x1887962b8 CFRunLoopRunSpecific + 444
21 GraphicsServices 0x18a24a198 GSEventRunModal + 180
22 UIKit 0x18e7dd7fc -[UIApplication _run] + 684
23 UIKit 0x18e7d8534 UIApplicationMain + 208
24 AppName Mobile 0x1000333e8 main (main.m:16)
25 libdispatch.dylib 0x1877795b8 (Missing)
We finally found this one. It wasn't the performBatchUpdates issue reported on a lot of other cards. The root cause was one our data sources would return a negative number for item count. The SDK is using an unsigned int, so setting a negative rolled over, and would try to allocate billions of cells (34 GB of virtual memory and counting). It would eventually crash.
There is a rampant problem with item counts and performBatchUpdates. Specifically, you may run into discrepancies and an OS assert if these are not in sync. An assert is not a crash.
I do suspect that this is what you encountered here, and if so, this question may be a duplicate of:
Nightmare with performBatchUpdates crash
How to solve this CollectionView crash
UICollectionView performBatchUpdates crash
crashing at performBatchUpdates of collection view
Assert or not, a defensive approach is to guard the item count as excellently outlined in Fang-Pen Lin's(†) UICollectionView invalid number of items crash problem and solution blog post:
func updateItems(updates: [ItemUpdate]) {
collectionView.performBatchUpdates({
for update in updates {
switch update {
case .Add(let index):
collectionView.insertItemsAtIndexPaths([NSIndexPath(forItem: index, inSection: 0)])
itemCount += 1
case .Delete(let index):
collectionView.deleteItemsAtIndexPaths([NSIndexPath(forItem: index, inSection: 0)])
itemCount -= 1
}
}
}, completion: nil)
}
† Full Credit

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000002 on UITableView reloadData

I've had this problem for a while and it's driving me nuts. This is reported by Crashlytics but only for a few users. I'm unable to recreate the problem myself.
I'm using a SplitViewController and this occurs after a user adds data within a UIViewController and touch the save button, which then returns to the SplitViewController to perform the method 'saveItemEntry' shown below.
I've tried a suggestion from a previous post which was to wrap the [self.tableView reloadData] with dispatch_async(dispatch_get_main_queue(), ^(void), but that actually made it worse. It isn't like the data takes ages to load, it doesn't, so I can't see that multi-tasking will help, but I'm open to advice on whether I should be doing that.
I'm really not clear on how to interperupt the crash info. If someone can and can suggest what might be causing this that would be awesome.
If more info is needed please let me know.
Here's the crash details:
Here's the Raw stuff..
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x20407ae2 objc_msgSend + 1
1 CoreFoundation 0x20b8391b -[NSDictionary descriptionWithLocale:indent:] + 310
2 Foundation 0x2136fe2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x20c011a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x20bff255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x20c17559 _CFLogvEx2 + 96
6 CoreFoundation 0x20c179af _CFLogvEx3 + 118
7 Foundation 0x214374f7 _NSLogv + 126
8 Foundation 0x2137e79d NSLog + 28
9 UIKit 0x24eac5fb -[UITableView reloadData] + 1818
10 Simple Meeting Minutes 0xfb859 -[MMDetailTableVC saveItemEntry:] (MMDetailTableVC.m:1423)
11 Simple Meeting Minutes 0x10becf -[MMItemViewController saveButtonAction:] (MMItemViewController.m:526)
12 UIKit 0x24dfd771 -[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x24f7ec71 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 140
14 UIKit 0x24dfd771 -[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x24dfd701 -[UIControl sendAction:to:forEvent:] + 64
16 UIKit 0x24de561f -[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x24de574b -[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x24dfd051 -[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x24dfccbf -[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x24df55d7 -[UIWindow sendEvent:] + 642
21 UIKit 0x24dc6119 -[UIApplication sendEvent:] + 204
22 UIKit 0x24dc4757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x20bf1257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x20bf0e47 __CFRunLoopDoSources0 + 454
25 CoreFoundation 0x20bef1af __CFRunLoopRun + 806
26 CoreFoundation 0x20b41bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x20b419ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x21dbbaf9 GSEventRunModal + 160
29 UIKit 0x24e2dfb5 UIApplicationMain + 144
30 Simple Meeting Minutes 0xf5d6f main (main.m:16)
31 libdispatch.dylib 0x207f4873 (Missing)
and here's my code in this particular area..
- (void)saveItemEntry:(MMitem *)item{
if (item)
{
// save item to the sqlite3 database file
NSString *resultStr = [self.meetingModel saveItem:item];
if ([resultStr isEqualToString:#"OK"])
{
// all good so close form and refresh data
[self dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
// or if there is an error result then display message
}
else if ([resultStr isEqualToString:#"DescriptionNotesMissing"])
{
[self showAlert:#"Missing Description or Notes" :#"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
// for any other error do nothing
}
}

Reporting crash on UITableview reloadData

I'm getting a crash report from Crashlytics that is always in the same place but I'm unable to replicate the crash.
It seems to be only users on iOS 9 and only very occasionally. I'm not sure if it's a code issue or something else. The last line mentions libdispatch.dylib as being missing, again, not sure if relevant.
Crashlytics indicates that the crash occurs at MMDetailTableVC.m line 1407, which is the reloadData line.
Here's what is reported:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000001
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x20f0fae2 objc_msgSend + 1
1 CoreFoundation 0x2168b91b -[NSDictionary descriptionWithLocale:indent:] + 310
2 Foundation 0x21e77e2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x217091a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x21707255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x2171f559 _CFLogvEx2 + 96
6 CoreFoundation 0x2171f9af _CFLogvEx3 + 118
7 Foundation 0x21f3f4f7 _NSLogv + 126
8 Foundation 0x21e8679d NSLog + 28
9 UIKit 0x259b45fb -[UITableView reloadData] + 1818
10 Simple Meeting Minutes 0x91fff -[MMDetailTableVC saveItemEntry:] (MMDetailTableVC.m:1407)
11 Simple Meeting Minutes 0xa2edf -[MMItemViewController saveButtonAction:] (MMItemViewController.m:526)
12 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x25a86c71 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 140
14 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x25905701 -[UIControl sendAction:to:forEvent:] + 64
16 UIKit 0x258ed61f -[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x258ed74b -[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x25905051 -[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x25904cbf -[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x258fd5d7 -[UIWindow sendEvent:] + 642
21 UIKit 0x258ce119 -[UIApplication sendEvent:] + 204
22 UIKit 0x258cc757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x216f9257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x216f8e47 __CFRunLoopDoSources0 + 454
25 CoreFoundation 0x216f71af __CFRunLoopRun + 806
26 CoreFoundation 0x21649bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x216499ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x228c3af9 GSEventRunModal + 160
29 UIKit 0x25935fb5 UIApplicationMain + 144
30 Simple Meeting Minutes 0x8c59f main (main.m:16)
31 libdispatch.dylib 0x212fc873 (Missing)
And here's my code for saveItemEntry that always seems to be the place where the crash occurs.
- (void)saveItemEntry:(MMitem *)item{
if (item)
{
NSString *resultStr = [self.meetingModel saveItem:item];
if ([resultStr isEqualToString:#"OK"])
{
// all good so close form and refresh data
[_itemViewController dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
// or if there is an error result then display message
}
else if ([resultStr isEqualToString:#"DescriptionNotesMissing"])
{
[self showAlert:#"Missing Description or Notes" :#"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
// for any other error do nothing
}
}
We don't know if you are calling this method in main thread or not.
And also tableview is taking time in reloading it's cell. So it would be great, if you can add these codes in dispatch_get_main_queue
dispatch_async(dispatch_get_main_queue(), ^(void){
[_itemViewController dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
}
and
dispatch_async(dispatch_get_main_queue(), ^(void){
[self showAlert:#"Missing Description or Notes" :#"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
It will be much safe, if we are working on refreshing the UI from any notification or delegation with dispatch_async(dispatch_get_main_queue(), ^(void){
Hooray - finally found the reason for this elusive problem. The crash was being due to the user being in edit mode within a UITextfield within a cell in the table when the reloadData was being called (as a result of the user tapping elsewhere or rotating the iPad, which also called ReloadData).
I fixed the issue by preceeding any [self.tableView ReloadData] with [self.view endEditing:YES] to ensure that the keyboard was dismissed and cells were not in an edit mode.
Does make sense but what a nasty trap.

crash with insertObject:atIndex: object cannot be nil but no array

I'm fighting with a crash in my app but I can't find where it happens.
I'm working with last version of MZFormSheetController. When I receive a remote push I present a basic MZFormSheetController, it was working nice but from one day to the other it starts crashing with a weird stack trace :
Fatal Exception: NSInvalidArgumentException
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2bfc2fef __exceptionPreprocess + 126
1 libobjc.A.dylib 0x3a274c8b objc_exception_throw + 38
2 CoreFoundation 0x2bedcefb -[__NSArrayM insertObject:atIndex:] + 638
3 UIKit 0x2fb6289f __workaround10030904InvokeWithTarget_block_invoke + 14
4 UIKit 0x2f8b2ab1 +[UIView _performSystemAppearanceModifications:] + 32
5 UIKit 0x2f780639 workaround10030904InvokeWithTarget + 704
6 UIKit 0x2fb5ff3b applyInvocationsToTarget + 1242
7 UIKit 0x2f6bdd8f +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 1262
8 UIKit 0x2f6bd89b +[_UIAppearance _applyInvocationsTo:window:] + 30
9 UIKit 0x2f8bc353 __88-[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:]_block_invoke + 54
10 UIKit 0x2f8bc2cb -[UIView(Internal) _performUpdatesForPossibleChangesOfIdiom:orScreen:traverseHierarchy:] + 262
11 UIKit 0x2f61cf07 -[UIView(Internal) _didChangeFromIdiom:onScreen:traverseHierarchy:] + 30
12 UIKit 0x2f633f0f -[UIScrollView _didChangeFromIdiom:onScreen:traverseHierarchy:] + 46
13 UIKit 0x2f8bc1b7 -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] + 138
14 UIKit 0x2f61497d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1316
15 UIKit 0x2f633dfb -[UIScrollView _didMoveFromWindow:toWindow:] + 50
16 UIKit 0x2f6146fb -[UIView(Internal) _didMoveFromWindow:toWindow:] + 674
17 UIKit 0x2f6146fb -[UIView(Internal) _didMoveFromWindow:toWindow:] + 674
18 UIKit 0x2f613fa7 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 114
19 UIKit 0x2f613ec1 -[UIView(Hierarchy) _postMovedFromSuperview:] + 428
20 UIKit 0x2f61e72b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1498
21 UIKit 0x2f61e14b -[UIView(Hierarchy) addSubview:] + 30
22 UIKit 0x2f61db69 -[UIWindow addRootViewControllerViewIfPossible] + 432
23 UIKit 0x2f61b3a1 -[UIWindow _setHidden:forced:] + 272
24 UIKit 0x2f6864a1 -[UIWindow makeKeyAndVisible] + 48
25 Project 0x000f382d -[MZFormSheetController presentAnimated:completionHandler:] (MZFormSheetController.m:509)
26 Project 0x0021b879 __60+[ARDPopupManager showFormsheet:animated:completionHandler:]_block_invoke_2 (ARDPopupManager.m:46)
27 libdispatch.dylib 0x3a7e9ecd _dispatch_barrier_sync_f_slow_invoke + 372
28 libdispatch.dylib 0x3a7df2cf _dispatch_client_callout + 22
29 libdispatch.dylib 0x3a7e2d2f _dispatch_main_queue_callback_4CF + 1330
30 CoreFoundation 0x2bf88609 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
31 CoreFoundation 0x2bf86d09 __CFRunLoopRun + 1512
32 CoreFoundation 0x2bed3201 CFRunLoopRunSpecific + 476
33 CoreFoundation 0x2bed3013 CFRunLoopRunInMode + 106
34 GraphicsServices 0x337b2201 GSEventRunModal + 136
35 UIKit 0x2f677a59 UIApplicationMain + 1440
36 Project 0x0007a88d main (main.m:14)
37 libdyld.dylib 0x3a800aaf start + 2
Of course I understand the crash but the exception breakpoint stops at this line :
[self.formSheetWindow makeKeyAndVisible];
In MZFormSheetController library and the MZFormSheetController is presented from my code like :
[formsheet presentAnimated:animated completionHandler:nil];
I added an All Exception Breakpoint but it does not point to an addObject: or insertObject:atIndex: method. Maybe it is elsewhere but I can't figure it out. I can't find the NSArray causing this crash.
Finally found : in the view controller presented in form sheet controller I added an UITextView and in my AppDelegate I wrote [[UITextView appearance] setKeyboardAppearance:UIKeyboardAppearanceDark]; and it crashes when I present the UITextView. So I had to set keyboard appearance individually on each UITextView instances storyboard or code...
I think it will solve problem.
YourViewController *objVc = [[YourViewController alloc] init]; // or you can use initWithNib
// Your remaining code
MZFormSheetController *formSheet = [[MZFormSheetController alloc]initWithViewController:objVc];
formSheet.transitionStyle = MZFormSheetTransitionStyleSlideFromBottom; //try different style
formSheet.presentedFormSheetSize = CGSizeMake(320, self.view.frame.size.height);
formSheet.willPresentCompletionHandler = ^(UIViewController *presentedFSViewController)
{
presentedFSViewController.view.autoresizingMask = presentedFSViewController.view.autoresizingMask | UIViewAutoresizingFlexibleWidth;
};
formSheet.shouldCenterVertically = YES;
[formSheet presentAnimated:YES completionHandler:^(UIViewController *presentedFSViewController){ }];

UIApplication sendAction:to:from:forEvent: iOS7 no user code

I have a crash that is occurring on iOS7 only. The app is compiled against 6.1 sdk. I can not reproduce this myself but I can see from crash reports that it is occurring for some users. The problem is there is no user code in the stack trace so it is proving difficult to track down:
Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0x13
0 libobjc.A.dylib objc_msgSend + 5
1 UIKit -[UIApplication sendAction:to:from:forEvent:] + 90
2 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
3 UIKit -[UIControl sendAction:to:forEvent:] + 44
4 UIKit -[UIControl _sendActionsForEvents:withEvent:] + 374
5 UIKit -[UIControl touchesEnded:withEvent:] + 590
6 UIKit -[UIWindow _sendTouchesForEvent:] + 528
7 UIKit -[UIWindow sendEvent:] + 832
8 UIKit -[UIApplication sendEvent:] + 196
9 UIKit _UIApplicationHandleEventQueue + 7096
10 ... CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
16 UIKit UIApplicationMain + 1136
I have tried enabling zombies and performing various actions in the app but that didn't flag anything.
Update
I think this might have morphed in to [UIPickerView _updateSelectedRows], EXC_BAD_ACCESS under iOS 7.1 . I will investigate further.
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x39576626 objc_msgSend + 5
1 UIKit 0x3187b12f -[UIPickerView _updateSelectedRows] + 54
2 UIKit 0x3187b26f -[UIPickerView didMoveToWindow] + 78
3 UIKit 0x3160ad37 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1358
4 UIKit 0x3160aaa5 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 700
5 UIKit 0x3160a40d __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 112
6 UIKit 0x3160a263 -[UIView(Hierarchy) _postMovedFromSuperview:] + 250
7 UIKit 0x318a2a27 __UIViewWasRemovedFromSuperview + 218
8 UIKit 0x31609187 -[UIView(Hierarchy) removeFromSuperview] + 270
9 UIKit 0x316cf26f -[UIPeripheralHost(UIKitInternal) adjustHostViewForTransitionCompletion:] + 310
10 UIKit 0x31a6ca8b __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1364 + 318
11 UIKit 0x3164378d -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 284
12 UIKit 0x316433d7 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 178
13 UIKit 0x316432ef -[UIViewAnimationState animationDidStop:finished:] + 66
14 QuartzCore 0x3128de0b CA::Layer::run_animation_callbacks(void*) + 234
15 libdispatch.dylib 0x39a55d3f _dispatch_client_callout + 22
16 libdispatch.dylib 0x39a586c3 _dispatch_main_queue_callback_4CF + 278
17 CoreFoundation 0x2eda6679 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
18 CoreFoundation 0x2eda4f45 __CFRunLoopRun + 1308
19 CoreFoundation 0x2ed0f7a9 CFRunLoopRunSpecific + 524
20 CoreFoundation 0x2ed0f58b CFRunLoopRunInMode + 106
21 GraphicsServices 0x33c6c6d3 GSEventRunModal + 138
22 UIKit 0x3166e891 UIApplicationMain + 1136
I had the almost identical crash log with our project we were able to track to an animation.
The problem was that we animated a UIPickerView on and off the screen. If the ViewController that owned the UIPickerView was popped and dealloced during the animation. We solved this by removing the UIPickerView from the superview in the animation completion block.
[UIView animateWithDuration:0.5f animations:^{
//Set the destination frame of the PickerView
} completion:^(BOOL finished) {
[self.pickerView removeFromSuperview];
}];
I don't know about other crash reporting tools, but Crashlytics includes the CLS_LOG() macro:
http://support.crashlytics.com/knowledgebase/articles/92519-how-do-i-use-logging
During development, it behaves as NSLog() but in the field, the log statements are included in crash reports. So I suggest replacing your debugging statements with CLS_LOG or start peppering the code in question with lots of statements that capture the user actions, then deploy a new version of your app.
(Old question, but I recently ran into something similar and would like to document this.)
All I just received a similar crash with a UIPicker. Turns out that I forgot to set the delegate to nil before deallocating it. The problem only presented when running with breakpoints enabled. Hope this helps someone else.
Try removing arm64 from:
Project > BuildSettings > Architectures> Valid Architectures
and rebuilding you app.
You might also need to set Build Active Architectures Only to NO for it to work.

Resources