Skip to content

Getting crashes randomly with AlertController while presenting it on top of app window.  #9

@YamunaChebolu

Description

@YamunaChebolu

I am using the below code to set alert controller title, message and buttons (UIAlertController+Blocks)
+ (instancetype)showInViewController:(UIViewController *)viewController withTitle:(NSString *)title message:(NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles

Using below code to present the alertcontroller (UIAlertController+Window)

self.alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.alertWindow.rootViewController = [[UIViewController alloc] init]; self.alertWindow.tintColor = [UIApplication sharedApplication].delegate.window.tintColor; self.alertWindow.windowLevel = UIWindowLevelAlert + 1; [self.alertWindow makeKeyAndVisible]; [self.alertWindow.rootViewController presentViewController:self animated:animated completion:nil];

This crash occurs randomly. Below is the crash log reported in crashlytics.

Crashed: com.apple.main-thread
0 UIKit 0x1881fb788 sortByWindowLevel + 286
1 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
2 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
3 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
4 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
5 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
6 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
7 CoreFoundation 0x182336c30 __CFSimpleMergeSort + 244
8 CoreFoundation 0x182260ac4 CFSortIndexes + 480
9 CoreFoundation 0x18226068c -[NSMutableArray sortRange:options:usingComparator:] + 380
10 CoreFoundation 0x182273e48 -[NSMutableArray sortUsingFunction:context:] + 116
11 UIKit 0x1881fb73c +[UIWindow allWindowsIncludingInternalWindows:onlyVisibleWindows:forScreen:] + 212
12 UIKit 0x188237dec -[UIViewController _window] + 304
13 UIKit 0x188523fd0 -[UIViewController _parentTraitEnvironment] + 264
14 UIKit 0x188524060 -[UIViewController traitCollection] + 60
15 UIKit 0x1881bde8c __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 408
16 UIKit 0x1881bdbe8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 792
17 UIKit 0x1881c9ad0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1788
18 UIKit 0x1881c93bc -[UIView(Hierarchy) addSubview:] + 828
19 UIKit 0x1883427f4 -[UICollectionViewController loadView] + 1084
20 UIKit 0x1881c2074 -[UIViewController loadViewIfRequired] + 184
21 UIKit 0x1883423a0 -[UICollectionViewController collectionView] + 28
22 UIKit 0x18871ab4c -[_UIAlertControllerTextFieldViewController init] + 184
23 UIKit 0x188659360 _UIAlertControllerCommonInit + 416
24 UIKit 0x1886594b8 -[UIAlertController initWithNibName:bundle:] + 104
25 UIKit 0x188659534 +[UIAlertController alertControllerWithTitle:message:preferredStyle:] + 100
26 app_name 0x100455b7c +[UIAlertController(Blocks) showInViewController:withTitle:message:preferredStyle:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:popoverPresentationControllerBlock:tapBlock:] (UIAlertController+Blocks.m:47)
27 app_name 0x10045631c +[UIAlertController(Blocks) showAlertInViewController:withTitle:message:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:tapBlock:] (UIAlertController+Blocks.m:106)
28 app_name 0x1000d48f0 -[class_name textField:shouldChangeCharactersInRange:replacementString:]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions