According to Crashlytics, I have a very frequent crash in my application in +[UIViewAnimationState popAnimationState]
This only happens on iOS 10, but applies to iPhone and iPad.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000008
Crashed: com.apple.main-thread
0 UIKit 0x230d57ce +[UIViewAnimationState popAnimationState] + 93
1 UIKit 0x2336c79d -[UIViewAnimationState _runConstraintBasedLayoutAnimations] + 740
2 UIKit 0x230d4755 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 584
3 UIKit 0x232f8a4b +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:] + 168
4 UIKit 0x239b0329 -[UIAlertControllerVisualStyleAlert animateAlertControllerView:ofAlertController:forPresentation:inContainerView:descendantOfContainerView:duration:completionBlock:] + 536
5 UIKit 0x23682773 -[_UIAlertControllerAnimatedTransitioning _animateTransition:completionBlock:] + 808
6 UIKit 0x23682057 -[_UIAlertControllerAnimatedTransitioning animateTransition:] + 534
7 UIKit 0x233d8c43 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 3346
8 UIKit 0x2331e983 _runAfterCACommitDeferredBlocks + 276
9 UIKit 0x23311c93 _cleanUpAfterCAFlushAndRunDeferredBlocks + 524
10 UIKit 0x230938bd _afterCACommitHandler + 112
11 CoreFoundation 0x1de2f803 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
12 CoreFoundation 0x1de2da55 __CFRunLoopDoObservers + 282
13 CoreFoundation 0x1de2e017 __CFRunLoopRun + 1358
14 CoreFoundation 0x1dd811af CFRunLoopRunSpecific + 470
15 CoreFoundation 0x1dd80fd1 CFRunLoopRunInMode + 104
16 GraphicsServices 0x1f52bb41 GSEventRunModal + 80
17 UIKit 0x23103a53 UIApplicationMain + 150
18 My App 0x10dbaf main (main.m:14)
19 libdyld.dylib 0x1d56e4eb start + 2
At first, I had no idea what caused this crash, but after a few months I had enough user reports that I managed to narrow down to this Swift code:
let alert : UIAlertController = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.alert);
alert.addTextField(configurationHandler: { (textField : UITextField) in
});
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (action : UIAlertAction) in
}));
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler:nil));
myViewController.present(alert, animated: true, completion: nil);
This is the presence of a text field, which apparently causes it - if I comment on this line, it works fine.
Although this code is located in Swift, there is an https://stackoverflow.com/a/165752/ ... (also unanswered), which was Objective-C.
source
share