Search Issue Tracker
By Design
Votes
3
Found in
2017.4.17f1
Issue ID
1124167
Regression
No
[iOS] Crash when calling native UIViewController that changes orientation settings
Steps:
1. Build and run the attached project for iOS ("OrientationCrashExample.zip")
2. In Player: tick a mark on "Lock to current orientation"
3. Press button "Present Modal View Controller [...]"
Result: player crashes.
Reproduced with: 2019.1.0a14, 2018.1.0b3, 2017.4.19f1, 2017.3.0p3, 2017.2.1p2.
Not reproduced with: 2017.1.3f1.
Tested with:
iPad Pro 10.5 (iOS10.3.3) - reproduced
iPhone X (iOS11.3.1) - reproduced
iPhone 7 Plus (iOS11.1.1) - reproduced
iPhone XS Max (iOS12.0) - reproduced
VLNQA00078 Motorola Nexus 6 7.1.1 Snapdragon 805 APQ8084AB Adreno (TM) 420 OpenGL ES 3.2 ZX1G22F7N7 - not reproduced
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Clear Dynamic Data On Build does not clear data after a clean build when the Atlas Population Mode is set to "Dynamic" or "Dynamic OS"
- A tile from the wrong layer gets selected in the Tile Palette when an Aseprite file with multiple layers is imported as a Tile Set
- Particle geometry is inverted, billboard is not lit, not receiving shadows in cubemap reflection when Render Alignment is set to View
- Menu bar list orders change when Domain Reload is performed
- Unity Hub Module icons wrap poorly when they occupy two rows
Resolution Note (2018.3.X):
It appears that this exception is normal iOS behavior. Asking to change to an unsupported orientation is not allowed by the OS. In the provided sample it looks like the issue lies in ModalViewControllerLauncher.m (supportedInterfaceOrientations). Since it is not in the engine code there isn't anything that we can do to resolve the issue.
I can think of two solutions.
1. Check that the parent view controller supports the orientation that you need to rotate to before doing so. Something like this:
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
if (self.requirePortrait)
{
if ((self.parentViewController.supportedInterfaceOrientations & UIInterfaceOrientationMaskPortrait) ||
(self.parentViewController.supportedInterfaceOrientations & UIInterfaceOrientationMaskPortraitUpsideDown))
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationPortraitUpsideDown;
else
return UIInterfaceOrientationMaskAll;
}
else
{
return UIInterfaceOrientationMaskLandscape; // this covers both landscapes
}
}
2. Subclass UIImagePickerController and override supportedInterfaceOrientations. See here for more information on this technique. https://stackoverflow.com/questions/19374237/using-uiimagepickercontroller-in-landscape-orientation
It sounds like that may not always work but is worth trying out.