Search Issue Tracker

Fixed in 2017.2.0f3

Fixed in 5.4, 5.5, 5.6, 2017.1

Votes

200

Found in

5.4.0f3

Issue ID

835745

Regression

No

[iOS] Changing the screen orientation via a script sometimes results in corrupted view on iOS 10

iOS

-

When the orientation of the screen is changed via a script (with Screen.orientation) on iOS 10 devices, sometimes the screen remains in portrait orientation, but the game view gets flipped and goes over the edge of the screen and leaves black area in the bottom part of the screen.

Steps to reproduce:
1) Open the attached project.
2) Build 'MainScene' for iOS.
3) Run on an iOS 10 device.
4) Press the 'Switch to landscape' UI button.

If the button is clicked 2-3 seconds after launch - the rotation should fail - black area appears at the bottom of the screen, half of the game view is not visible. If it does not, quit the app completely, re-launch it and repeat step 5). This occurs with both Metal and OpenGLES on iOS 10.

Reproduced on:
5.5.0b5, 5.4.1p3, 5.3.6p6

Devices:
iPhone 7 iOS 10 - reproduced
iPhone 7 iOS 10.1 - reproduced
iPhone 7 Plus iOS 10.0.2 - reproduced
iPhone 5 iOS 10 - not reproduced
iPad Mini 2 iOS 10 - not reproduced
iPhone 5S iOS 9.2.1 - not reproduced
It should also be reproducible on iPhone 6.
iPhone 6S iOS 10.2 - reproducible

------------------------

Fixed in 2017.1.0b10, 5.6.2p1, 5.5.4p1, 5.4.5p4

Comments (96)

  1. 5ba75621e96f1b44463991d93a933fe6?d=mm

    Mohammad-Faisal-Aleem

    Dec 05, 2016 22:36

    Does anybody have found a proper fix for it. Have unity fixed this issue in some version above 5.4.x series? I am also stuck in this. It should have been answered or handled till now.

  2. 4b38dae05c4e294ee8362ec988231815?d=mm

    matbou

    Dec 01, 2016 11:27

    Got the same issue using Unity 5.4.2f2.
    It's a really severe issue for us. Please fix.

  3. 354e882a407bfcd2ebb89e43d26c5c63?d=mm

    FSpark

    Nov 30, 2016 17:56

    In case this helps anyone - I raised a similar issue where the iOS device (iOS 10) the UI appeared locked and display distorted on resuming app after extended sleep (see https://fogbugz.unity3d.com/default.asp?846895_82ts9nnt8gm5rp25 ).

    The quick workaround I used was to modify the Unity generated UnityAppController.mm:

    - (void)applicationWillEnterForeground:(UIApplication*)application
    {
    ::printf("-> applicationWillEnterForeground()\n");

    // applicationWillEnterForeground: might sometimes arrive *before* actually initing unity (e.g. locking on startup)
    if(_unityAppReady)
    {
    // if we were showing video before going to background - the view size may be changed while we are in background
    [GetAppController().unityView recreateGLESSurfaceIfNeeded];
    }


    //
    // Bug workaround:
    // On returning from device sleep mode, Unity UI is lock and will not respond
    // If the device is rotated, Unity will 'wake up'
    // So force landscape orientation to wake up Unity
    //
    [[UIDevice currentDevice] orientation];
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    switch( [[UIDevice currentDevice] orientation] )
    {
    case UIDeviceOrientationPortrait:
    value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    break;


    case UIDeviceOrientationPortraitUpsideDown:
    value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
    break;
    case UIDeviceOrientationLandscapeLeft:
    value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
    break;


    case UIDeviceOrientationLandscapeRight:
    value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
    break;
    default:
    // setting to portrait does not work
    // value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    // but forcing the device into landscape mode and then allow it to auto-correct works
    value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
    break;
    };
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
    }

  4. 3e1043a130b785a00a76bf2538600b31?d=mm

    jimmyzhao

    Nov 30, 2016 08:42

    Reproduced this issue in iphon5s, iphone6, etc. with Unity 5.3.4f1

    pls fix..

  5. Fba2e8386dbb30f45bb601de037fd29a?d=mm

    Krellumdaed

    Nov 23, 2016 01:57

    On a current game we are developing we are seeing a solid color full screen when we run on new iPhone 7 Plus. Have people seen this problem manifest as it hanging with the background color filled in but before the full opening scene has been rendered?

  6. Cb24cf86df5d9e36d9f064a13cea28b3?d=mm

    Sigmund1

    Nov 15, 2016 04:41

    Workaround: In the info.plist file, go to "Supported Orientations" and add portrait (I also move it to index 1 instead of 0). This will fix the screen issue but mess the splash screen up on some devices. This fix worked for me, so from what I can tell if you make a portrait version of your Splash Screen art (Rotate it 90 degrees).

    I added both images to the splash screen in Unity Player Editor and they appeared in my Xcode project file. Go to "Launchscreen-iPhone.xib", once you have selected a canvas and the XIB has loaded, click the bottom where the screen measurements are. This will open the device and orientation selector menu make sure you have it set to portrait.

    Now head to the hierarchy and and create a new View and call it something like "ViewP" (you can add things to the xib by using the toolbox in the bottom right, for those who don't use Xcode), on the right enter the attributes selector, scroll to the bottom where it says "Installed", uncheck that and hit the small plus symbol to the right, if you have the view set to portrait, just click Add Variation, this will set the view to only activate in portrait screen.

    From there add an Image View and change the "Image" option in the attributes selector to your portrait image. I'm not 100% on what I did with the constraints but essentially what you want is to have it stay the same through all the different screen sizes, from there you should be good!.

    Hope this helps folks. Cheers.

  7. Cb24cf86df5d9e36d9f064a13cea28b3?d=mm

    Sigmund1

    Nov 15, 2016 02:10

    Having the same issue with + devices in Unity 5.4.2f2 personal edition. Currently testing a work around in Xcode. Will re-comment if the test is successful

  8. 13db2970a528603271106a85e6e5a55f?d=mm

    ptblk

    Nov 14, 2016 05:01

    Guys please vote for this to be solved, dont just comment

  9. 04e20b857efa08ac303dea5b90ba318f?d=mm

    punkrockchicken

    Oct 30, 2016 19:45

    Having the same awkward issue!

  10. 13db2970a528603271106a85e6e5a55f?d=mm

    ptblk

    Oct 25, 2016 12:01

    Please fix, this is a stupid issue that should not exist

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.