RaisinToast icon indicating copy to clipboard operation
RaisinToast copied to clipboard

Fix crash when keyboard tries to display an alert

Open cmds4410 opened this issue 8 years ago • 5 comments

Demo project with crash here: https://www.dropbox.com/s/jqaaw9zb23ly4ew/RaisinToastKeyboardCrash.zip?dl=0

Repro steps:

  1. Reset content and settings of the simulator
  2. Run demo app
  3. Tap on the text field
  4. Show the software keyboard in the simulator (cmd + k)
  5. Tap the smiley button to bring up the emoji keyboard
  6. Tap the "ABC" button to bring back the regular keyboard

The keyboard will attempt to display an alert to inform the user about alternate keyboards: screen shot 2015-10-28 at 10 56 51 am

Instead, the app will crash on an infinite loop in - (UIInterfaceOrientationMask)supportedInterfaceOrientations because [UIApplication sharedApplication].keyWindow accessed in + (UIViewController *)topViewController is no longer the main app window.

The way I've addressed this is to use the app delegate's window instead of the key window, which in my testing are always the same value except for when the aforementioned alert is being displayed.

Caution: Not having written this library, I am concerned that there might be further implications of this change.

cmds4410 avatar Oct 28 '15 19:10 cmds4410