Rightpoint / RaisinToast

A UIWindow subclass used to message information to the users of your app.
MIT License
83 stars 14 forks source link

Fix crash when keyboard tries to display an alert #34

Open cmds4410 opened 8 years ago

cmds4410 commented 8 years ago

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.

ZevEisenberg commented 8 years ago

Wasn’t this already fixed in https://github.com/Raizlabs/RaisinToast/commit/d7c2b80b483ad4c2178ff9559d3fee8b0ca1225f? Or is this a different issue?

cmds4410 commented 8 years ago

@ZevEisenberg This is a related, but separate issue. #31 Was a fix in the example app when it shows an alert, this is a fix for the library that should prevent the infinite loop in any situation, especially those caused by iOS.

adamhrz commented 8 years ago

We've got a fix for this in that didn't get pulled back in. I'll dig it out tomorrow and compare fixes.

On Wed, Oct 28, 2015 at 3:48 PM, Connor Smith notifications@github.com wrote:

@ZevEisenberg This is a related, but separate issue. #31 Was a fix in the example app when it shows an alert, this is a fix for the library that should prevent the infinite loop in any situation, especially those caused by iOS.

Reply to this email directly or view it on GitHub: https://github.com/Raizlabs/RaisinToast/pull/34#issuecomment-151969751

cmds4410 commented 8 years ago

@adamhrz Hey any update on this? 😃

adamhrz commented 8 years ago

Going to be a few days but will get it in

On Thu, Nov 19, 2015 at 6:01 PM, Connor Smith notifications@github.com wrote:

@adamhrz https://github.com/adamhrz Hey any update on this? 😃

— Reply to this email directly or view it on GitHub https://github.com/Raizlabs/RaisinToast/pull/34#issuecomment-158227738.

Adam Howitt, Senior Software Developer

Raizlabs Corporation: Mobile Strategy, Design, and Development www.raizlabs.com | adam.howitt@raizlabs.com | @earnshavian https://twitter.com/earnshavian