We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2967

Summary: Disabling portrait orientations in Info.plist crashes application
Product: SDL Reporter: cedega.git
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2 CC: amaranth72
Version: don't know   
Hardware: iPhone/iPod touch   
OS: iOS (All)   
Attachments: Patch to fix crash when Info.plist orientations don't match the SDL window's orientation.

Description cedega.git 2015-04-30 09:37:14 UTC
Removing portrait orientations in Info.plist crashes the App on iOS devices:

<Error>: *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES' 

The crash only happens on physical devices (in this case, iPhone 4 iOS 7.1).

In addition, even if portrait + landscape mode is supported in Info.plist, the App refuses to rotate from portrait mode (portrait mode is locked).

Forcing correct orientations can be achieved manually by overwriting to:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

in SDL_uikitviewcontroller.m

SDL version is 2.0.4-9574.
Comment 1 Alex Szpakowski 2015-05-01 14:17:23 UTC
The supported orientations at runtime is based on the intersection of the orientations in Info.plist with the orientations that the SDL window supports.

If you don't create your SDL window with SDL_WINDOW_RESIZABLE, then the window will base its supported orientations on the width and height you pass in (unless you use SDL_HINT_ORIENTATIONS.)

For example, SDL_CreateWindow("", 0, 0, 480, 320, 0) would create a window that only supports portrait orientations.

If iOS can't find any common supported orientations between the window and Info.plist, then it triggers the exception you encountered.
Comment 2 Alex Szpakowski 2015-05-01 14:18:46 UTC
(In reply to Alex Szpakowski from comment #1)
> For example, SDL_CreateWindow("", 0, 0, 480, 320, 0) would create a window
> that only supports portrait orientations.

And by portrait I mean landscape (for that example)... heh.
Comment 3 Alex Szpakowski 2015-05-01 20:11:30 UTC
Created attachment 2146 [details]
Patch to fix crash when Info.plist orientations don't match the SDL window's orientation.

Here's a patch which makes the window choose exclusively from the Info.plist orientations if none of the orientations it would have chosen are listed in Info.plist.

This should prevent the crash issue.
Comment 4 Alex Szpakowski 2015-05-05 19:27:44 UTC
The patch has been applied in the SDL repository: https://hg.libsdl.org/SDL/rev/fceb5503cadf

Feel free to reopen the issue if that doesn't fix it for you.