3

I am receiving this error, and have no idea what may be causing it. This is happening in iOS 8.2 on both iPhone and iPad.

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_PROTECTION_FAILURE at 0x00554ff4 raw
0 libobjc.A.dylib   lookUpImpOrForward + 3
4 libobjc.A.dylib   -[NSObject respondsToSelector:] + 38
5 UIKit -[UIWindow _supportedInterfaceOrientationsForRootViewController] + 56
6 UIKit -[_UIFallbackPresentationViewController supportedInterfaceOrientations] + 60
7 UIKit -[_UIFallbackPresentationViewController supportedInterfaceOrientations] + 60
...
510 UIKit -[_UIFallbackPresentationViewController supportedInterfaceOrientations] + 60

I read somewere that this should solve these kind of issues, but it did not work.

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if ( IDIOM == IPAD ) {
        return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;

    } else {
        return UIInterfaceOrientationMaskPortrait;
    }
}
picciano
  • 22,341
  • 9
  • 69
  • 82
rob180
  • 901
  • 1
  • 9
  • 29

3 Answers3

2

I ended up contacting apple about this issue. According to them is related with Game Center. Apple changed some things on it and the old way the Game Center was initialised would generate random crashes. Added a Game Center Manger to my game and these random crashes stopped.

rob180
  • 901
  • 1
  • 9
  • 29
  • Could you please clarify what exactly was causing crashes? I'm using some legacy code to init GC (the C++ library) and it's working well, however is generating those crashes. Thx. – Hedin Oct 13 '15 at 04:50
  • I am not 100% sure, but i was pretty sure is was due to the view being presented on random locations. Why don't use the framework above? It solved all my issues. – rob180 Oct 13 '15 at 09:26
1

The below code works fine with me.

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

return UIInterfaceOrientationMaskLandscape;

} 

If it didn't solve your problem,I think some other parts of your code is buggy.

  • You can create an empty project and try the code (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window on that see if the problem happens just to isolate the bugger

  • Check the variables IDIOM and IPAD are set correctly in your code

#define IDIOM UI_USER_INTERFACE_IDIOM()

#define IPAD UIUserInterfaceIdiomPad

  • EXC_BAD_ACCESS is caused by an illegal memory access you might be accessing a variable that is deallocated.

  • Check all pointers, especially object pointers, to make sure they're initialized. If you are using xib make sure you've set up properly, with all the necessary connections.

  • if none of this works then try to locate the error with NSLog() statements and find the line that’s causing the error then set the breakpoint and examine all the variables and objects in them to see anything is not as it supposed to be.

Hope this helps. Feel free to ask me if the problem still remains unsolved

Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241
  • if you check the question i have that method and it work fine. The issue is that for some reason the rotation sometimes will enter an infinite loop trowing that error. The bug does not happen so frequently. Currently has affected 0.1% of my users. Just wanted to know what is causing that loop. – rob180 Mar 26 '15 at 11:36
  • @rob180 - are you able to reproduce the issue ? If you could then we can probably run the app from xcode and set break points and isloate the issue. Have you found the preconditions that causing the issue ? symbolicate the crashlogs and see if you can get some useful information from that ? – Durai Amuthan.H Mar 26 '15 at 12:20
  • The problem is that i cant reproduce it. I happen so rarely that is impossible to track it. – rob180 Mar 26 '15 at 12:24
  • In 3 places orienations has to be handled to work properly 1) Make sure you have put the orientations correctly in .plist or Target Summary Screen 2) You have put then orientation handling code in app delegate so no worries about it 3) Make sure you have handled the orientations in your all view controllers Here is a sample code just in case – Durai Amuthan.H Mar 26 '15 at 12:48
  • `- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; }` – Durai Amuthan.H Mar 26 '15 at 12:51
  • EXC_BAD_ACCESS (SIGBUS) KERN_PROTECTION_FAILURE means that the virtual address we're accessing is wrong.So there is a memory leak.you must be dereferencing a NULL pointer, other than this crash does not happen.Tools like STATIC ANALYZER will help you on this likewise try to ENABLE ZOMBIE OBJECT in XCODE these are tools that'll help you catch the bugs that are missed by default xcode build tool. – Durai Amuthan.H Mar 26 '15 at 13:45
  • From what i read this error was a stack-overflow and not a NULL pointer, but i may be wrong. As for code, why do i need to have it on all controllers? having it on app delegate should be enough. But i will try STATIC ANALYZER and ZOMBIE to check. – rob180 Mar 30 '15 at 07:51
-1

You have to add the following method in ur Viewcontroller

-(NSUInteger)supportedInterfaceOrientations{
    return yes for supported orientations
}
KkRao
  • 1
  • As said above, i have added `InterfaceOrientations` to the AppDelegate, what should do the same thing. – rob180 Mar 24 '15 at 09:36