Crash viewDidMoveToWindow:shouldAppearOrDisappear: on iOS 10 - ios

Since a while my app crashes in production but It has been impossible to reproduce this error in debug mode.
The error in Crashlytics is:
UIKit
-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
SIGABRT ABORT 0x00000001825d4d74
Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x1825d4d74 __abort_with_payload + 8
1 libsystem_kernel.dylib 0x1825d1480 abort_with_payload_wrapper_internal + 100
2 libsystem_kernel.dylib 0x1825d141c abort_with_payload_wrapper_internal + 34
3 libobjc.A.dylib 0x18203fed8 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 112
4 libobjc.A.dylib 0x18203fe30 __objc_error + 42
5 libobjc.A.dylib 0x182052cd4 weak_entry_insert(weak_table_t*, weak_entry_t*) + 318
6 libobjc.A.dylib 0x182058664 objc_initWeak + 324
7 UIKit 0x1894ce1bc -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 2068
8 UIKit 0x18944db5c -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1352
9 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
10 UIKit 0x189471714 -[UIScrollView _didMoveFromWindow:toWindow:] + 92
11 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
12 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
13 UIKit 0x189471714 -[UIScrollView _didMoveFromWindow:toWindow:] + 92
14 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
15 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
16 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
17 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
18 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
19 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
20 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
21 UIKit 0x18944d8e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
22 UIKit 0x18944cd90 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 156
23 Foundation 0x184034510 -[NSISEngine withBehaviors:performModifications:] + 168
24 UIKit 0x18944cc04 -[UIView(Hierarchy) _postMovedFromSuperview:] + 820
25 UIKit 0x18974a078 __UIViewWasRemovedFromSuperview + 172
26 UIKit 0x18944bc80 -[UIView(Hierarchy) removeFromSuperview] + 512
27 UIKit 0x1897a23dc __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke.629 + 1044
28 UIKit 0x18979c4fc -[UIPresentationController transitionDidFinish:] + 124
29 UIKit 0x18990afc8 -[_UICurrentContextPresentationController transitionDidFinish:] + 40
30 UIKit 0x1897a012c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 188
31 UIKit 0x189578ad4 -[_UIViewControllerTransitionContext completeTransition:] + 116
32 UIKit 0x1895788c0 -[UITransitionView notifyDidCompleteTransition:] + 252
33 UIKit 0x1895783dc -[UITransitionView _didCompleteTransition:] + 1240
34 UIKit 0x189577ef0 -[UITransitionView _transitionDidStop:finished:] + 124
35 UIKit 0x189489b48 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
36 UIKit 0x189489988 -[UIViewAnimationState animationDidStop:finished:] + 160
37 QuartzCore 0x186912404 CA::Layer::run_animation_callbacks(void*) + 260
38 libdispatch.dylib 0x1824911c0 _dispatch_client_callout + 16
39 libdispatch.dylib 0x182495d6c _dispatch_main_queue_callback_4CF + 1000
40 CoreFoundation 0x1835b5f2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
41 CoreFoundation 0x1835b3b18 __CFRunLoopRun + 1660
42 CoreFoundation 0x1834e2048 CFRunLoopRunSpecific + 444
43 GraphicsServices 0x184f65198 GSEventRunModal + 180
44 UIKit 0x1894bc628 -[UIApplication _run] + 684
45 UIKit 0x1894b7360 UIApplicationMain + 208
46 <App Name> 0x100081590 main (main.m:14)
47 libdispatch.dylib 0x1824c45b8 (Missing)
Most of the logs show that the user had between 1% and 3% of RAM memory free but there are some with more than 10%.
Also my app tracks errors using Sentry but this error is not in Sentry only in Fabric.
Most of my users use iOS 10 but still there are who use iOS 9 and this crash seems that not affect these users. So it seems it is related to iOS 10.
Also I have searched here but I have not could find a solution even a clue. Someone could help me to find a clue?
EDIT
Regarding the comments the new code introduced that it is related with UIViewController is:
- (IBAction)tapClose:(id)sender {
[self close];
}
- (void)close {
_dismissing = YES;
CGFloat height = self.view.superview.frame.size.height;
[UIView animateWithDuration:0.2 animations:^{
[self.view setFrame:CGRectMake(0, height, self.view.frame.size.width, self.view.frame.size.height)];
_overlay.alpha = 0;
} completion:^(BOOL finished) {
if (finished) {
[self.view removeFromSuperview];
[_overlay removeFromSuperview];
if (self.blockWhenClose) {
self.blockWhenClose();
}
}
}];
}
- (void)showIn:(UIViewController *)viewcontroller {
CGRect frame = viewcontroller.view.frame;
CGFloat height = [self calculateHeight:frame.size.height / 2];
[self.view setFrame:CGRectMake(0, frame.size.height, frame.size.width, height)];
[_overlay setFrame:frame];
_overlay.alpha = 0;
[viewcontroller addChildViewController:self];
[viewcontroller.view addSubview:_overlay];
[viewcontroller.view addSubview:self.view];
[self didMoveToParentViewController:viewcontroller];
[UIView animateWithDuration:_duration animations:^{
_overlay.alpha = 1;
[self.view setFrame:CGRectMake(0, frame.size.height - height, frame.size.width, height)];
}];
_show = YES;
}
But I do not know where exactly the crash occurs.

For me this started with iOS 14
The problem was, I had code where the view of a controller (A) was added as a subview to another controller(B) without holding a reference to the controller(A) itself. the controller(A) was deallocated and next time the view is about to appear or disappear, it tries to notify the controller(A) which causes a crashes.
Solution:
Manually hold a reference to the controller
OR addChildViewController which does the above for you

Related

iOS 8 Tap on UITextView freezes the app

I have an old code, without ARC, without Autolayout and I am constructing theUITableViewCell programmatically. TheUITableViewCell contains aUITextView. The cell is constructed properly but when I tap on theUITextView for editing the app freezes and after some time it exists (I think it's because it's taking a lot of CPU Time). This only happens with iOS 8, other versions it works fine.
I debugged and I do getUIKeyboardWillShowNotification notification but the keyboard does not show up and I can't do anything after this.
Below is the code
// Register notification when the keyboard will be show
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
// Register notification when the keyboard will be hide
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
CGRect frame = CGRectMake(MIN_X,(LABEL_HEIGHT + VERTICAL_PADDING) + 2,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT);
self.roundRectView = [[RoundRectView alloc]initWithFrame:frame];
self.roundRectView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:roundRectView];
inputTextView = [[UITextView alloc] initWithFrame:frame];
inputTextView.editable = YES;
inputTextView.delegate = self;
if(self.parameter.selectedValue == nil || [self.parameter.selectedValue length] == 0){
inputTextView.text = self.parameter.label;
}
else{
inputTextView.text = self.parameter.selectedValue;
}
inputTextView.backgroundColor = [UIColor clearColor];
inputTextView.textAlignment = UITextAlignmentLeft;
inputTextView.font = [UIFont fontWithName:#"HelveticaNeue" size:15.0];
inputTextView.textColor = [UIColor grayColor];
inputTextView.scrollEnabled = NO;
inputTextView.bounces = NO;
inputTextView.autocorrectionType = UITextAutocorrectionTypeNo;
[self.contentView addSubview:inputTextView];
Below is theUIKeyboardWillShowNotification handler :-
-(void) keyboardWillShow:(NSNotification *)note{
if([self.inputTextView isFirstResponder]) {
// Get the keyboard size
CGRect keyboardBounds;
[[note.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] getValue: &keyboardBounds];
// Detect orientation
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGRect frame = self.parentTableView.frame;
// Start animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.3f];
// Reduce size of the Table view
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
frame.size.height -= keyboardBounds.size.height-100;
else
frame.size.height -= keyboardBounds.size.width-100;
// Apply new size of table view
self.parentTableView.frame = frame;
// Scroll the table view to see the TextField just above the keyboard
if (self.inputTextView)
{
CGRect textFieldRect = [self.parentTableView convertRect:self.inputTextView.bounds fromView:self.inputTextView];
[self.parentTableView scrollRectToVisible:textFieldRect animated:NO];
}
[UIView commitAnimations];
}}
Below is the crash report. My app name is "My App"
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
com.myapp.app failed to exit in time
Elapsed total CPU time (seconds): 8.070 (user 8.070, system 0.000), 66% CPU
Elapsed application CPU time (seconds): 5.689, 47% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 QuartzCore 0x27e013ca x_hash_table_lookup + 62
1 QuartzCore 0x27e10c60 CAMediaTimingCopyRenderTiming + 120
2 QuartzCore 0x27e0fd4a CA::Layer::add_animation(CAAnimation*, __CFString const*) + 650
3 QuartzCore 0x27e0f876 -[CALayer addAnimation:forKey:] + 478
4 UIKit 0x28673c4c __67-[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:]_block_invoke + 376
5 UIKit 0x28673a98 -[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:] + 544
6 QuartzCore 0x27e02788 CA::Layer::end_change(CA::Transaction*, unsigned int, objc_object*) + 92
7 QuartzCore 0x27e03322 CA::Layer::set_bounds(CA::Rect const&, bool) + 522
8 QuartzCore 0x27e03046 -[CALayer setBounds:] + 106
9 QuartzCore 0x27e0407a -[CALayer setFrame:] + 538
10 UIKit 0x283dcfde -[UIView(Geometry) setFrame:] + 250
11 UIKit 0x283f7408 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 804
12 UIKit 0x283f70d2 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 254
13 CoreFoundation 0x24e6506e __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 86
14 CoreFoundation 0x24e64f68 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 200
15 UIKit 0x283e7bea -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
16 UIKit 0x283dd0f2 -[UIView(Geometry) setFrame:] + 526
17 UIKit 0x28469320 -[UILayoutContainerView setFrame:] + 56
18 UIKit 0x283f7408 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 804
19 UIKit 0x283f70d2 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 254
20 CoreFoundation 0x24e6506e __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 86
21 CoreFoundation 0x24e64f68 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 200
22 UIKit 0x283e7bea -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
23 UIKit 0x28429b40 -[UIView(Geometry) setBounds:] + 476
24 UIKit 0x288b7ad8 -[UIDropShadowView setBounds:] + 124
25 UIKit 0x287cdf84 -[_UIFormSheetPresentationController containerViewWillLayoutSubviews] + 272
26 UIKit 0x283e0154 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 440
27 QuartzCore 0x27e0bf60 -[CALayer layoutSublayers] + 132
28 QuartzCore 0x27e0794c CA::Layer::layout_if_needed(CA::Transaction*) + 356
29 UIKit 0x283f28e6 -[UIView(Hierarchy) layoutBelowIfNeeded] + 134
30 UIKit 0x28413d22 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 474
31 UIKit 0x28413b3e +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:] + 62
32 UIKit 0x287cdb44 -[_UIFormSheetPresentationController _changeLayoutModeToAvoidKeyboard:] + 220
33 CoreFoundation 0x24ef6f12 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
34 CoreFoundation 0x24e51e48 _CFXNotificationPost + 1796
35 Foundation 0x25b86e5c -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
36 UIKit 0x28a44b94 -[UIInputWindowController postStartNotifications:withInfo:] + 412
37 UIKit 0x28a45fb4 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke579 + 396
38 UIKit 0x28413d22 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 474
39 UIKit 0x284d579e +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:animations:start:completion:] + 62
40 UIKit 0x284a093a -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 166
41 UIKit 0x28a45d18 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 828
42 UIKit 0x28a49584 -[UIInputWindowController setPlacement:starting:completion:] + 44
43 UIKit 0x28a4913a -[UIInputWindowController setInputViewSet:] + 610
44 UIKit 0x28a457aa -[UIInputWindowController performOperations:withAnimationStyle:] + 38
45 UIKit 0x28498102 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1010
46 UIKit 0x2845b7f0 -[UIResponder becomeFirstResponder] + 404
47 UIKit 0x2845bab6 -[UIView(Hierarchy) becomeFirstResponder] + 102
48 UIKit 0x2857ab6a -[UITextView becomeFirstResponder] + 70
49 UIKit 0x2857aa6a -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 170
50 UIKit 0x2857a36a -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 1994
51 UIKit 0x285601aa _UIGestureRecognizerSendActions + 290
52 UIKit 0x2840ec98 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 664
53 UIKit 0x28823a8c ___UIGestureRecognizerUpdate_block_invoke661 + 44
54 UIKit 0x283d8512 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 214
55 UIKit 0x283d648a _UIGestureRecognizerUpdate + 2946
56 UIKit 0x2840d088 -[UIWindow _sendGesturesForEvent:] + 780
57 UIKit 0x2840c958 -[UIWindow sendEvent:] + 516
58 UIKit 0x283e30e0 -[UIApplication sendEvent:] + 192
59 My App 0x0023e95a 0x28000 + 2189658
60 UIKit 0x28656b9e _UIApplicationHandleEventFromQueueEvent + 13870
61 UIKit 0x283e1b22 _UIApplicationHandleEventQueue + 1290
62 CoreFoundation 0x24f04fd4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
63 CoreFoundation 0x24f043e6 __CFRunLoopDoSources0 + 218
64 CoreFoundation 0x24f02a64 __CFRunLoopRun + 764
65 CoreFoundation 0x24e4fb2c CFRunLoopRunSpecific + 472
66 CoreFoundation 0x24e4f93e CFRunLoopRunInMode + 102
67 GraphicsServices 0x2c1d504c GSEventRunModal + 132
68 UIKit 0x28441f1c UIApplicationMain + 1436
69 My App 0x0002e56e 0x28000 + 25966
70 My App 0x0002e4f4 0x28000 + 25844
Posting my solution if anyone faces same issue.
The TextView was in an view controller which was presented modally using UIModalPresentationFormSheet presentation style. After I changed to UIModalPresentationPageSheet it worked fine. This means the Form sheet caused some problem while popping up the keyboard.

Foundation -[NSConcreteMapTable assign:key:value:isNew:] Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS at

I have a crash that happens only in IOS 7, I cannot reproduce it but it happens a lot. Does some one have an answer or at least have any idea where the problem can be.
I've allready removed all the warnings regarding ios7 and the crash still occurs.
Log is attached.
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x3b43c626 objc_msgSend + 5
1 Foundation 0x315a9681 -[NSConcreteMapTable assign:key:value:isNew:] + 68
2 Foundation 0x315a95fb -[NSConcreteMapTable setObject:forKey:] + 82
3 Foundation 0x315ecaf7 -[NSISEngine setRowWithHead:body:] + 30
4 Foundation 0x315ef5d1 -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 388
5 Foundation 0x315ed325 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 236
6 Foundation 0x315efd9f -[NSISEngine tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] + 226
7 Foundation 0x315eb5fd -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 692
8 Foundation 0x315eb23b -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 286
9 Foundation 0x315e8f6d -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 232
10 Foundation 0x315f47ed -[NSLayoutConstraint _addToEngine:] + 28
11 UIKit 0x33591c55 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 332
12 Foundation 0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
13 UIKit 0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
14 UIKit 0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
15 UIKit 0x33591bbb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 178
16 Foundation 0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
17 UIKit 0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
18 UIKit 0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
19 UIKit 0x33591bbb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 178
20 Foundation 0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
21 UIKit 0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
22 UIKit 0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
23 UIKit 0x33591bbb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 178
24 Foundation 0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
25 UIKit 0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
26 UIKit 0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
27 UIKit 0x3349de33 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 82
28 Foundation 0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
29 UIKit 0x3349dcd3 -[UIView(Hierarchy) _postMovedFromSuperview:] + 298
30 UIKit 0x334aaa4f -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1414
31 UIKit 0x334aa4bf -[UIView(Hierarchy) addSubview:] + 30
32 UIKit 0x3358bdb7 -[UITransitionView transition:fromView:toView:removeFromView:] + 978
33 UIKit 0x335cbf3f -[UITransitionView transition:fromView:toView:] + 30
34 UIKit 0x335cbf15 -[UITransitionView transition:toView:] + 104
35 UIKit 0x335cb03b -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 1106
36 UIKit 0x335cabdf -[UITabBarController transitionFromViewController:toViewController:] + 38
37 UIKit 0x335caab7 -[UITabBarController _setSelectedViewController:] + 258
38 UIKit 0x33694dd5 -[UITabBarController _tabBarItemClicked:] + 272
39 UIKit 0x334d4037 -[UIApplication sendAction:to:from:forEvent:] + 90
40 UIKit 0x334d3fd7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
41 UIKit 0x33694c8b -[UITabBar _sendAction:withEvent:] + 370
42 UIKit 0x334d4037 -[UIApplication sendAction:to:from:forEvent:] + 90
43 UIKit 0x334d3fd7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
44 UIKit 0x334d3fb1 -[UIControl sendAction:to:forEvent:] + 44
45 UIKit 0x334bf717 -[UIControl _sendActionsForEvents:withEvent:] + 374
46 UIKit 0x336949ab -[UITabBar(Static) _buttonUp:] + 118
47 UIKit 0x334d4037 -[UIApplication sendAction:to:from:forEvent:] + 90
48 UIKit 0x334d3fd7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
49 UIKit 0x334d3fb1 -[UIControl sendAction:to:forEvent:] + 44
50 UIKit 0x334bf717 -[UIControl _sendActionsForEvents:withEvent:] + 374
51 UIKit 0x334d3a2f -[UIControl touchesEnded:withEvent:] + 590
52 UIKit 0x334d3701 -[UIWindow _sendTouchesForEvent:] + 528
53 UIKit 0x334ce6cb -[UIWindow sendEvent:] + 758
54 UIKit 0x334a38cd -[UIApplication sendEvent:] + 196
55 UIKit 0x334a1f77 _UIApplicationHandleEventQueue + 7102
56 CoreFoundation 0x30c4d20b __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
57 CoreFoundation 0x30c4c6db __CFRunLoopDoSources0 + 206
58 CoreFoundation 0x30c4aecf __CFRunLoopRun + 622
59 CoreFoundation 0x30bb5ebf CFRunLoopRunSpecific + 522
60 CoreFoundation 0x30bb5ca3 CFRunLoopRunInMode + 106
61 GraphicsServices 0x35abb663 GSEventRunModal + 138
62 UIKit 0x3350214d UIApplicationMain + 1136
I get the same issue. The strange thing is it only occurs in 3.5inch devices (ip4, ip4S), os7.x. works fine on ip5.
UPDATE: our team found the root cause. It's because we use this animation in code.
[UIView animateWithDuration:0.4f delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{
self.transform = CGAffineTransformMakeScale(sx,sy);
} completion:^(BOOL finished) {
self.hidden = !visible;
}];
to fix the bug, we avoid to run the animation if iOS <8.0
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) {
[UIView animateWithDuration:0.4f delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{
self.transform = CGAffineTransformMakeScale(sx,sy);
} completion:^(BOOL finished) {
if (finished) {
self.hidden = !visible;
}
}];
} else {
self.transform = CGAffineTransformMakeScale(sx,sy);
self.hidden = !visible;
}
Hope this help!
Thanks for who ever responded.
I solved it by removing the keyboard (resignFirstResponder) before poping the view controller.
In that screen I had 2 textfields that one of them was connected to the keyboard(inpuAccessoryView)and the other just activated the first one (I was developing a chat), when poping the view controller something probably went wrong.
Hope this will help someone.
I had a similar crash, except it happened when I did removeFromSuperview on a UIView that was created while inside a network callback. [NSISEngine withBehaviors:performModifications:] was where it started to go wrong after removeFromSuperview
eg. inside handleReadStreamEvent
if (!CFReadStreamSetClient( inputStream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered | kCFStreamEventOpenCompleted
, handleReadStreamEvent, &context ) )
It seems any view that was created while inside this callback, crashed when it was removed from the superview - most of the time.
I ended up using this whenever I was making any UIView changes when inside the callback.
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;
The same happened when inside a looptimer callback
CFRunLoopAddTimer( CFRunLoopGetMain(), timeoutTimer, kCFRunLoopCommonModes);

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){ }];

SpriteKit crash on transitionWithView

I have several crash reports with Collection <__NSArrayM: 0x12345678> was mutated while being enumerated. However in my testing I cannot reproduce the error.
This seems be triggered via a chain of events when I transition to a different SKView.
[UIView transitionWithView:window
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[UIView setAnimationsEnabled:NO];
[fromView removeFromSuperview];
[window addSubview:toView];
window.rootViewController = nextViewController;
[UIView setAnimationsEnabled:YES];
}
completion:NULL];
I have read that this error can happen when you remove nodes from their parent during enumeration of child nodes but I don't believe I am doing this here, and the full stack trace below doesn't seem to indicate it either.
I don't know why [SKNode setPaused:] would cause child nodes to be added or removed, and there doesn't appear to be any indication of this happening in other threads either.
Full Stacktrace
0 CoreFoundation 0x2f896fd3 __exceptionPreprocess + 131
1 libobjc.A.dylib 0x3a37bccf objc_exception_throw + 36
2 CoreFoundation 0x2f896ad1 __NSFastEnumerationMutationHandler + 126
3 SpriteKit 0x31fb926b -[SKNode setPaused:] + 792
4 SpriteKit 0x31f95309 -[SKScene setPaused:] + 134
5 SpriteKit 0x31fa7b63 -[SKView renderCallback:] + 648
6 SpriteKit 0x31fa9301 -[SKView layoutSubviews] + 474
7 UIKit 0x320b2d79 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 378
8 QuartzCore 0x31d3062b -[CALayer layoutSublayers] + 140
9 QuartzCore 0x31d2be3b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 348
10 QuartzCore 0x31d5acdd -[CALayer layoutIfNeeded] + 138
11 UIKit 0x3212f183 -[UIViewController window:setupWithInterfaceOrientation:] + 240
12 UIKit 0x3212d7a3 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 3496
13 UIKit 0x3212c9f3 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 44
14 UIKit 0x3212c97b -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 92
15 UIKit 0x3212c913 -[UIWindow _setRotatableViewOrientation:duration:force:] + 40
16 UIKit 0x32124f89 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 106
17 UIKit 0x320b9127 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 380
18 UIKit 0x3212c661 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 694
19 UIKit 0x3212c125 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 162
20 UIKit 0x320be065 -[UIWindow addRootViewControllerViewIfPossible] + 458
21 UIKit 0x32124133 -[UIWindow setRootViewController:] + 760
22 the-app 0x000baf0d 0x000b2000 + 36621
23 UIKit 0x320e83c5 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 494
24 UIKit 0x3234c3f9 +[UIView(UIViewAnimationWithBlocks) transitionWithView:duration:options:animations:completion:] + 58
25 the-app 0x000bae67 0x000b2000 + 36455
26 the-app 0x000bacf7 0x000b2000 + 36087
27 UIKit 0x320e8057 -[UIApplication sendAction:to:from:forEvent:] + 88
28 UIKit 0x320e7ff7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 28
29 UIKit 0x320e7fd1 -[UIControl sendAction:to:forEvent:] + 42
30 UIKit 0x320d3737 -[UIControl _sendActionsForEvents:withEvent:] + 372
31 UIKit 0x320e7a4f -[UIControl touchesEnded:withEvent:] + 588
32 UIKit 0x320e7721 -[UIWindow _sendTouchesForEvent:] + 526
33 UIKit 0x320e26eb -[UIWindow sendEvent:] + 756
34 UIKit 0x320b78ed -[UIApplication sendEvent:] + 194
35 UIKit 0x320b5f97 _UIApplicationHandleEventQueue + 7100
36 CoreFoundation 0x2f86225b __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
37 CoreFoundation 0x2f86172b __CFRunLoopDoSources0 + 204
38 CoreFoundation 0x2f85ff1f __CFRunLoopRun + 620
39 CoreFoundation 0x2f7caf0f CFRunLoopRunSpecific + 520
40 CoreFoundation 0x2f7cacf3 CFRunLoopRunInMode + 104
41 GraphicsServices 0x346c4663 GSEventRunModal + 136
42 UIKit 0x3211616d UIApplicationMain + 1134
43 the-app 0x000b9267 0x000b2000 + 29287
44 libdyld.dylib 0x3a888ab7 start + 0

Crash when installing the app on ipad, works fine in simulator

I am gettting the below issue in my application (Pls help me):
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [1.07157e-08 nan]'
*** Call stack at first throw:
(
0 CoreFoundation 0x3126a64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32b12c5d objc_exception_throw + 24
2 CoreFoundation 0x3126a491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x3126a4cb +[NSException raise:format:] + 34
4 QuartzCore 0x32c6f61d _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 140
5 QuartzCore 0x32c6f58b -[CALayer setPosition:] + 38
6 QuartzCore 0x32c6f4d7 -[CALayer setFrame:] + 390
7 UIKit 0x35a31455 -[UIView(Geometry) setFrame:] + 188
8 UIKit 0x35a51743 UIViewCommonInitWithFrame + 594
9 UIKit 0x35a514a1 -[UIView initWithFrame:] + 84
10 CaCaCard 0x0000683b -[CaCaCardsAppViewController shouldAutorotateToInterfaceOrientation:] + 510
11 UIKit 0x35a6eead -[UIViewController _isSupportedInterfaceOrientation:] + 48
12 UIKit 0x35a6ee6f -[UINavigationController _doesTopViewControllerSupportInterfaceOrientation:] + 46
13 UIKit 0x35a6ee37 -[UINavigationController shouldAutorotateToInterfaceOrientation:] + 14
14 UIKit 0x35a6edbf -[UINavigationController _isSupportedInterfaceOrientation:] + 54
15 UIKit 0x35a6fbbb -[UIViewController window:shouldAutorotateToInterfaceOrientation:] + 46
16 UIKit 0x35a6f857 -[UIWindow _shouldAutorotateToInterfaceOrientation:] + 194
17 UIKit 0x35a6f4a3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 366
18 UIKit 0x35a6f0ad -[UIWindow setDelegate:] + 168
19 UIKit 0x35a6efa9 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 64
20 UIKit 0x35a6d611 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 460
21 UIKit 0x35a6d3e5 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 36
22 UIKit 0x35a4c5a7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 506
23 UIKit 0x35a4c32f -[UIView(Hierarchy) _postMovedFromSuperview:] + 106
24 UIKit 0x35a31c1b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 678
25 UIKit 0x35a3196b -[UIView(Hierarchy) addSubview:] + 22
26 CaCaCard 0x00004bcf -[CaCaCardsAppAppDelegate application:didFinishLaunchingWithOptions:] + 318
27 UIKit 0x35a61821 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772
28 UIKit 0x35a5bb65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
29 UIKit 0x35a307d7 -[UIApplication handleEvent:withNewEvent:] + 1114
30 UIKit 0x35a30215 -[UIApplication sendEvent:] + 44
31 UIKit 0x35a2fc53 _UIApplicationHandleEvent + 5090
32 GraphicsServices 0x31d37e77 PurpleEventCallback + 666
33 CoreFoundation 0x31241a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
34 CoreFoundation 0x3124383f __CFRunLoopDoSource1 + 166
35 CoreFoundation 0x3124460d __CFRunLoopRun + 520
36 CoreFoundation 0x311d4ec3 CFRunLoopRunSpecific + 230
37 CoreFoundation 0x311d4dcb CFRunLoopRunInMode + 58
38 UIKit 0x35a5ad49 -[UIApplication _run] + 372
39 UIKit 0x35a58807 UIApplicationMain + 670
40 CaCaCard 0x000028e7 main + 70
41 CaCaCard 0x0000289c start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcod
eDebuggerSupport.dylib (file not found).
(gdb)
-(void) viewWillAppear:(BOOL)animated
//-----------------------------------
{
if ( self.interfaceOrientation == UIInterfaceOrientationPortrait ||
self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
{
[NSThread sleepForTimeInterval:0.5];
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight];
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[UIView commitAnimations];
}
fontSelected = NO;
}
The problem is an invalid frame size you are setting at some point. Probably a rect with a zero value somewhere.
From your code I would suspect you are getting some unexpected values back when you are asking for the screen size.
Also don't use those old animation functions. Use the block based animation. It's much better.

Resources