Presenting form sheet modals can lead to a crash (for devices with regular size class in Landscape)

Originator:kwridan
Number:rdar://50397263 Date Originated:May 2, 2019
Status:Open Resolved:
Product:iOS + SDK Product Version:
Classification:Crash Reproducible:Always
 
Area:
UIKit

Summary:

Presenting a `.formSheet` modal view controller that supports all / default orientations from a view controller that has `.portrait` as the only supported orientation can lead to a crash. This occurs only on devices that have a regular size class in Landscape.

Steps to Reproduce:

(Note - original radar has a sample application attached, the following section has been modified to provide clarity on open radar without the sample application)

- Create a single view application
- Embed the main view controller within a navigation controller
- Set the supported orientations of the main view controller as `.portrait`
- Create another view controller - modal view controller
- Leave the supported orientations of the modal view controller set to default (i.e. don't override it)
- Add a button to the main view controller's view to trigger the presentation of the modal view controller with a `.formSheet` `modalPresentationStyle`

```swift
    @IBAction func didTapPresent(_ sender: UIButton) {
        let modalViewController = ModalViewController()
        modalViewController.modalPresentationStyle = .formSheet
        present(modalViewController, animated: true, completion: nil)
    }

```

- Launch the sample application on a Plus device (or XS Max / XR)
- Rotate the device / simulator to landscape
- Tap the button

Expected Results:

The app should not crash

Actual Results:

The app crashes (hits an internal UIKit assert)

```
[Assert] transitionViewForCurrentTransition is not set! (<_UIFullscreenPresentationController: 0x7ff9be4023d0>)
```

Version/Build:

- iPhone 7 plus (iOS 12.1) / iPhone XS Max (iOS 12.1)
- Xcode Version 10.2 (10E125)

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!