Search Unity

UnityDefaultViewController should be used only if unity is set to autorotate

Discussion in 'iOS and tvOS' started by ababab5, Mar 28, 2015.

  1. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    I have this crash on iOS 8.2 (iPhone6 plus) when I build my roject (and Unity is set to "Auto Rotation"...):





    Somebody can help me ?

    Thank you very much.

    Best regards,

    AB
     
  2. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    Could you please submit a bug and attach a small reproduction project to it? Thank you
     
  3. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    I'm sorry but I solved it yet : I just changed the orientation setting in the build setting.

    Sorry
     
  4. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    I'm also experiencing this problem. The project is set to build with Auto Rotate as the desired orientation. The main menu selection screen will operate in either orientation. However, since this project is a set of mini-games, some designed for portrait and some for landscape, periodically the orientation will change and lock. If I'm in portrait, load one of the games that's landscape, and then rotate the device while the game is loading, I get the same crash as above.

    It's being caused by line 102 of the UnityViewControllerBase.mm file, in which it performs an assert to check for auto rotation. If I comment out this line in the Xcode project, the app works as expected, so it seems this assert is not behaving as intended. Is there a way to keep this line commented out as part of the build process, or is there another setting I can use to prevent the assert from failing? It is a requirement of these games that we be able to prevent auto-rotation at some times but not others.
     
  5. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    >>If I'm in portrait, load one of the games that's landscape, and then rotate the device while the game is loading, I get the same crash as above.
    that's kinda interesting - it should actually switch directly, bypassing "auto-rotating" view controller.
    can you bug report with small repro? (we dont need your mini-games, just setup - so empty scenes with orientation logic would suffice).
    And yes, i would say that if you tested, commenting assert should be more or less fine
     
  6. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    Sure thing, Alexey, I can file a bug report. In the mean time, is there a way to automate commenting of that assert so that it's part of the build process? We're using UCB for most of our builds so we can't really manually remove it each time.
     
  7. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    I found a good post-process example out there from one of the UCB guys and modified it to suit my needs. Posting it here in case it's helpful to someone with this specific problem.
     

    Attached Files:

  8. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    FYI you want to drop that script in an Editor folder somewhere in the project.
     
  9. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Thank you for this - just lost a day to this issue in a live app. Here's hoping I can get Apple to expedite the review of the fixed version!
     
  10. LindsayW

    LindsayW

    Joined:
    Nov 15, 2012
    Posts:
    1
    You deserve a medal! Had exactly the same problem (for the same reason, multiple mini-games :p). Also needed things to work with Cloud Build, so your automatic commenting script is perfect! So rare to come across a solution like this where someone has also gone to the effort of writing (AND SHARING) their fix like this. So rare that this is my first post here after so many years of lurking for solutions ;)

    Cheers!
     
  11. Cenda

    Cenda

    Joined:
    Jun 3, 2010
    Posts:
    66
    I have same problem, but PostBuildProcessor is not working :( Do you have any suggestion?

    @Alexey Here is code:

    Code (CSharp):
    1. void Awake() {
    2.  
    3. Screen.autorotateToLandscapeLeft = false;
    4. Screen.autorotateToLandscapeRight = false;
    5. Screen.autorotateToPortrait = false;
    6. Screen.autorotateToPortraitUpsideDown = false;
    7.  
    8. if( Screen.orientation != ScreenOrientation.LandscapeLeft ) {
    9. Screen.orientation = ScreenOrientation.LandscapeLeft;
    10. }
    11.  
    12. }
    I found that it is working in Start()
     
    Last edited: Nov 28, 2015
  12. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hey any solutions?
    I am in the same issue :(
     
  13. nastasache

    nastasache

    Joined:
    Jan 2, 2012
    Posts:
    74
    I think I am also experiencing the same problem, here is an excerpt from crash report:

    Version: 1 (1.8)
    Code Type: ARM-64 (Native)
    Parent Process: launchd [1]

    Date/Time: 2016-03-25 13:20:33.33 -0700
    Launch Time: 2016-03-25 13:20:32.32 -0700
    OS Version: iOS 9.3 (13E233)
    Report Version: 105

    Exception Type: EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Exception Note: EXC_CORPSE_NOTIFY
    Triggered by Thread: 0

    Filtered syslog:
    None found

    Last Exception Backtrace:
    0 CoreFoundation 0x18177ae38 0x181650000 + 1224248
    1 libobjc.A.dylib 0x180ddff80 0x180dd8000 + 32640
    2 CoreFoundation 0x18177ad08 0x181650000 + 1223944
    3 Foundation 0x182100124 0x18205c000 + 672036
    4 MyApplicationName 0x1000316c0 -[UnityDefaultViewController supportedInterfaceOrientations] (UnityViewControllerBaseiOS.mm:107)
    5 UIKit 0x186935a20 0x1868a8000 + 580128
    6 UIKit 0x18693f150 0x1868a8000 + 618832
    7 UIKit 0x18693f0c8 0x1868a8000 + 618696
    8 UIKit 0x18693dbb0 0x1868a8000 + 613296
    9 UIKit 0x1868b7910 0x1868a8000 + 63760
    10 UIKit 0x1868b6c40 0x1868a8000 + 60480
    11 Foundation 0x1820acd50 0x18205c000 + 331088
    12 UIKit 0x1868b6ac4 0x1868a8000 + 60100
    13 UIKit 0x1868c4578 0x1868a8000 + 116088
    14 MyApplicationName 0x10002fb5c -[UnityAppController(ViewHandling) showGameUI] (UnityAppController+ViewHandling.mm:169)
    15 MyApplicationName 0x10002c2d8 -[UnityAppController startUnity:] (UnityAppController.mm:117)
    16 Foundation 0x182142628 0x18205c000 + 943656
    17 CoreFoundation 0x18173181c 0x181650000 + 923676
    18 CoreFoundation 0x1817314c0 0x181650000 + 922816
    19 CoreFoundation 0x18172ebd4 0x181650000 + 912340
    20 CoreFoundation 0x181658d10 0x181650000 + 36112
    21 GraphicsServices 0x182f40088 0x182f34000 + 49288
    22 UIKit 0x186925f70 0x1868a8000 + 515952
    23 MyApplicationName 0x1000199cc main (main.mm:32)
    24 libdyld.dylib 0x1811f68b8 0x1811f4000 + 10424

    Looking at UnityViewControllerBaseiOS.mm:107 :

    NSAssert(UnityShouldAutorotate(), @"UnityDefaultViewController should be used only if unity is set to autorotate");

    But all builds succeeded on XCode :( with just warnings related, from Classes/UI/UnityAppController+ViewHandling.mm:

    Incompatible pointer types assigning to 'UnityViewControllerBase *' from 'UIViewController *'

    I need to change device orientation in my application at runtime, probably assigning Screen.Orientation to some values generate this crash.

    Any solution? I don't want to remove asserts from mm files.

    Thanks!

    I am using Unity 5.3.1f1, Xcode 7.2 (7C68)
     
    Last edited: Mar 26, 2016
  14. nastasache

    nastasache

    Joined:
    Jan 2, 2012
    Posts:
    74
  15. MechEthan

    MechEthan

    Joined:
    Mar 23, 2016
    Posts:
    166
    Updated the post-process commenting script that KAKE shared -- it fixes a few issues:
    • The filename containing the offending NSAssert changed in December 2015 with Unity 5.3.1 due to tvOS support being added -- the script now handles Unity versions before and after this change.
    • Changed it to work with local builds instead of UCB.
    • Added a log warning if it failed to replace the string.
    • The post-process script would keep re-commenting the line if you Build -> Appended. It no longer does this (but at the expense of a more fragile search string.)
    Hope this helps someone else!
     

    Attached Files:

  16. Yulian_Titov_21Pink

    Yulian_Titov_21Pink

    Joined:
    Sep 30, 2016
    Posts:
    1
    Hi,

    It looks like following issue could be reproduced via following code:

    Code (CSharp):
    1.  
    2. // Current orientation is Landscape and we want to set it as Portrait:
    3. Screen.orientation = ScreenOrientation.Portrait;
    4.  
    5. Screen.autorotateToLandscapeLeft = false;
    6. Screen.autorotateToLandscapeRight = false;
    7. Screen.autorotateToPortrait = true;
    8. Screen.autorotateToPortraitUpsideDown = true;
    9.  
    This issue was fixed in the following way: before Autorotate configuration we should set Screen.orientation to Autorotate (but not Portrait or Landscape):

    Code (CSharp):
    1.  
    2. // Current orientation is Landscape and we want to set it as Portrait:
    3. Screen.orientation = ScreenOrientation.AutoRotation;
    4.  
    5. Screen.autorotateToLandscapeLeft = false;
    6. Screen.autorotateToLandscapeRight = false;
    7. Screen.autorotateToPortrait = true;
    8. Screen.autorotateToPortraitUpsideDown = true;
    9.  
    Hope it will help somebody :)
     
    austinborden, mobadu and TheJimz like this.
  17. faraz-glu

    faraz-glu

    Joined:
    Sep 21, 2016
    Posts:
    6
    We are also seeing this crash in our live game on Unity 5.4.4p3. We are not able to repro, but it is definitely happening to users. Is anyone from Unity looking into a fix for this?

    Code (CSharp):
    1.    
    2. [B]Name[/B]
    3. NSInternalInconsistencyException
    4.  
    5. [B]Reason[/B]
    6. UnityDefaultViewController should be used only if unity is set to autorotate
    7.  
    8. [B]App Version[/B] 0.2.1 (15218)
    9. Download
    10. Crashed Thread
    11.  
    12. 0 CoreFoundation 0x0000000182c52db0 __exceptionPreprocess + 120
    13. 1    libobjc.A.dylib 0x00000001822b7f80 objc_exception_throw + 52
    14. 2    CoreFoundation 0x0000000182c52c80 +[NSException raise:format:arguments:] + 104
    15. 3    Foundation 0x00000001835d8154 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 108
    16. !    4    possum 0x0000000100101c00 -[UnityDefaultViewController supportedInterfaceOrientations] (UnityViewControllerBaseiOS.mm:112)
    17. 5    UIKit 0x0000000187e21b38 -[UIViewController __supportedInterfaceOrientations] + 700
    18. 6    UIKit 0x000000018808b55c -[UIApplicationRotationFollowingController supportedInterfaceOrientations] + 104
    19. 7    UIKit 0x0000000187e21b38 -[UIViewController __supportedInterfaceOrientations] + 700
    20. 8    UIKit 0x0000000187e2b268 -[UIViewController __withSupportedInterfaceOrientation:apply:] + 48
    21. 9    UIKit 0x0000000187e2b1e0 -[UIViewController setInterfaceOrientation:] + 136
    22. 10    UIKit 0x0000000187e29cc8 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 1156
    23. 11    UIKit 0x0000000187da3a10 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1368
    24. 12    UIKit 0x0000000187da2d40 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 148
    25. 13    UIKit 0x0000000187da2ba8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 500
    26. 14    UIKit 0x0000000187db0678 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1780
    27. 15    UIKit 0x0000000187daf7e8 -[UIWindow addRootViewControllerViewIfPossible] + 660
    28. 16    UIKit 0x0000000187e2149c -[UIWindow setRootViewController:] + 1072
    29. 17    UIKit 0x0000000187e75340 -[UITextEffectsWindow(UIObjectsForPerScreen) _initWithScreen:options:] + 660
    30. 18    UIKit 0x0000000187e74f60 +[_UIObjectPerScreen objectOfClass:forScreen:withOptions:createIfNecessary:] + 656
    31. 19    UIKit 0x00000001882b17a4 +[UITextEffectsWindow _sharedTextEffectsWindowforScreen:aboveStatusBar:allowHosted:matchesStatusBarOrientationOnAccess:] + 568
    32. 20    UIKit 0x0000000187e74ca0 +[UITextEffectsWindow sharedTextEffectsWindowForScreen:] + 152
    33. 21    UIKit 0x0000000187e74bdc -[UIPeripheralHost(UIKitInternal) containerWindow] + 192
    34. 22    UIKit 0x000000018843e320 -[UIPeripheralHost(UIKitInternal) containerRootController] + 16
    35. 23    UIKit 0x0000000187e630d8 -[UIPeripheralHost isUndocked] + 16
    36. 24    UIKit 0x0000000187eac104 +[UIPeripheralHost(UIKitInternal) visiblePeripheralFrame] + 44
    37. 25    UIKit 0x00000001881eda7c -[_UIKeyboardLayoutAlignmentView _matchInitialKeyboardFrame] + 32
    38. 26    UIKit 0x00000001881eda38 -[_UIKeyboardLayoutAlignmentView didMoveToWindow] + 428
    39. 27    UIKit 0x0000000187da3ac8 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1552
    40. 28    UIKit 0x0000000187da2d40 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 148
    41. 29    Foundation 0x0000000183584cc0 -[NSISEngine withBehaviors:performModifications:] + 164
    42. 30    UIKit 0x0000000187da2bc4 -[UIView(Hierarchy) _postMovedFromSuperview:] + 528
    43. 31    UIKit 0x0000000187db0678 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1780
    44. 32    UIKit 0x0000000188208070 -[_UIAlertControllerPresentationController presentationTransitionWillBegin] + 144
    45. 33    UIKit 0x0000000188109fb0 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1636
    46. 34    UIKit 0x00000001881080c8 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 328
    47. 35    UIKit 0x000000018805b0c8 _runAfterCACommitDeferredBlocks + 288
    48. 36    UIKit 0x0000000188068a80 _cleanUpAfterCAFlushAndRunDeferredBlocks + 88
    49. 37    UIKit 0x0000000187d9a5a4 _afterCACommitHandler + 92
    50. 38    CoreFoundation 0x0000000182c08728 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
    51. 39    CoreFoundation 0x0000000182c064cc __CFRunLoopDoObservers + 368
    52. 40    CoreFoundation 0x0000000182c068fc __CFRunLoopRun + 924
    53. 41    CoreFoundation 0x0000000182b30c50 CFRunLoopRunSpecific + 380
    54. 42    GraphicsServices 0x0000000184418088 GSEventRunModal + 176
    55. 43    UIKit 0x0000000187e12088 UIApplicationMain + 200
    56. 44    possum 0x00000001000d7510 main (main.mm:32)
     
  18. mason_c

    mason_c

    Joined:
    Mar 6, 2019
    Posts:
    2
    If you build with the unity boot splash screen disabled try building with it enabled. I found this made a difference for me. The screen orientation setting stuff might need to be called outside of awake
     
  19. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Does it make sense to get this exception if I have the autorotation disabled?
    My only view is portrait but im getting this crash.