Attempts to present controller after alert always fail

Originator:jon
Number:rdar://34822982 Date Originated:04-Oct-2017 06:56 PM
Status:Open Resolved:
Product:watchOS + SDK Product Version:4.0
Classification:UI/Usability Reproducible:Always
 
Summary:
Calling WKInterfaceController.presentController(withName:context:) in the action of presentAlert(withTitle:message:preferredStyle:actions:) always fails with console output: Warning: Attempt to present <SPModalViewController: 0x7c1ad170> on <SPInterfaceViewController: 0x7cbe8800> whose view is not in the window hierarchy!

Steps to Reproduce:
1. Clone https://github.com/jshier/AlertVsModal
2. Run in watch simulator
3. Click “Present with Alert” button.
4. See alert, click “Okay” button.
5. See warning in Xcode output.

Expected Results:
Controller should be presented properly, as it did in watchOS 2 and 3.

Actual Results:
No controller presented, warning printed.

Version:
4.0

Notes:
Adding a dispatch main around the controller presentation fixes it on watchOS 4. The demo project has a button demonstrating that.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!