Everyplay records video, but crashes when i tap on "Share" and "View profile" - everyplay

I am using everyplay to record my game play, and players can share the video at the result screen.
The recording, sharing and viewing of profile on the iPad is working fine, but every iPhone build (4, 4S, 5) will crash when I tap on the "share", "view everyplay profile" button at the Everyplay page.
We tracked what is happening when we tapped on those 2 buttons.
2013-08-01 10:29:19.489 ZombieBlackout[6602:907] Video Updated
2013-08-01 10:29:20.786 ZombieBlackout[6602:907] everyplayRecordingStopped
2013-08-01 10:29:20.788 ZombieBlackout[6602:907] everyplayShown
2013-08-01 10:29:22.393 ZombieBlackout[6602:907] Audio route change while recording was stopped.
2013-08-01 10:29:22.394 ZombieBlackout[6602:907] A route change occurred that does not require stopping application audio.
2013-08-01 10:29:22.451 ZombieBlackout[6602:907] Audio route change while recording was stopped.
2013-08-01 10:29:22.453 ZombieBlackout[6602:907] A route change occurred that does not require stopping application audio.
2013-08-01 10:29:27.488 ZombieBlackout[6602:907] Video Updated
2013-08-01 10:29:35.383 ZombieBlackout[6602:907] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
*** First throw call stack:
(0x3304f3e7 0x3ad40963 0x3304f307 0x34ec688f 0x3506b0c9 0x3f388d 0x3f0dad 0x3e1e5b 0x3e1d4b 0x3b15a793 0x3b15a5db 0x3b15de45 0x330231b1 0x32f9623d 0x32f960c9 0x36b7433b 0x34eb22b9 0xb1503 0xb02b8)
libc++abi.dylib: terminate called throwing an exception
And I don't think it is because our build is on the iPhone, because I tried Nimble Quest on iPhone and I am able to tap on the stated 2 buttons.
I am using Cocos2dx, the way we code is ready for Android. I am wondering if there is a problem with cocos2dx with Everyplay.
Please advise.
Thanks

I assume your game is landscape only. In that case you have two options how to fix this.
Option 1:
Add UISupportedInterfaceOrientations array into your game's info.plist with items UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight and UIInterfaceOrientationPortraitUpsideDown. You can easily do this from xCode by checking all Supported Interface Orientations from your project summary page or by editing the info.plist file manually.
Option 2:
Add the following method to your application's AppDelegate.m file:
// IOS 6
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
In both cases you must also make sure that you have added the landscape only orientation handling code to your game's UIViewController.
// IOS 5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
// IOS 6
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

Related

iOS: Switching apps after user clicks ADBannerView causes OpenGL crash

I have a GLKViewController subclass implementation, with an ADBannerView as a subview. Ads load and render just fine. The OpenGL application also works fine. When you click on an Ad, the popup appears. The GLKViewController has the default pause-on-resign behavior enabled.
If you set a breakpoint on GLKViewController's setPaused, you will notice that setPaused:NO gets called if you switch away from your app (double-tap home and pick another app) while the ad popup is visible. The behavior only occurs when an ADBannerView popup is visible, not if you switch away from the app otherwise.
I am able to reproduce the above behavior with even the default OpenGL template app generated by Xcode 7 in iOS 9.1.
1) Is this normal?
2) For me this causes consistent reproducible crashes because after setPaused:NO is called, the GLKViewController is redrawn, which causes OpenGL operations to occur while the app is in the background. The app is (correctly) killed at this point.
My current workaround is to discard calls to setPaused:NO as follows when the application is not active. This appears to work fine but why this is happening at all is confusing me.
- (void)setPaused:(BOOL)paused
{
long appState = (long)[UIApplication sharedApplication].applicationState;
if (!paused && (appState != 0)) {
NSLog(#"setPaused - REJECTING Unpause; %ld", appState);
return;
}
[super setPaused:paused];
}

How to disable iPhone 'app not active' flashing banner

My app checks the GPS while my app is not the active app and I use AVAudioplayer too in background.
It works fine and stays in the background doing its thing, but ios7 displays this red top banner with my app name flashing on it when it is not the active app.
How can I disable this banner, it is annoying to use other apps that are squished down 1 line?
I know this can be done as I have other GPS based background apps that don't display this flashing banner.
EDIT - So we found the answer quickly but the solution evades me:
If I stop OpenEars pocketsphinxController from listening with a button that calls this method while the program is active, the banner disappears when the app loses focus:
-(void) mystopListening{
NSLog(#"Tried to stop listening");
[pocketsphinxController stopListening];
}
BUT if I call the same method from my app delegate with (I had to import my view controller.h file in my app delegate.h and add -(void) nystopListening; in my view controller.h to make the below execute properly):
- (void)applicationWillResignActive:(UIApplication *)application{
myViewController * vc = [[myViewController alloc]init];
[vc mystopListening];
}
The banner persists! It is a little like ios7 has decided I am a recording culprit before I even have a chance to turn it off. OR, am I even turning it off?
How do I do this effectively and in what event?
EDIT - So it turns out I am not really turning pocketsphinxController off when 'mystopListening' is called from the app delegate. I know this because it DOES log the 'Tried to stop listening' when called from app delegate but the pocketsphinxController does not respond with its 'pocketsphinxDidStopListening' method. PocketsphinxController does call its 'pocketsphinxDidStopListening' method when I call 'mystopListening' from a button while the app is active.
Why won't the pocketsphinxController respond when called from from the app delegate, I must be doing it wrong?
Thanks,Carmen
Turns out I was not really calling the original pockectsphinxcontroller instance from my app delegate.
As a workaround to the problem I did this:
My app always has a timer running, so in my app delegate where I get notice of when app goes to inactive and comes back active, I just set global flags so my timer can know app active status. Then my timer just uses pockecsphinxcontroller methods to stop and start listening and voila, the banner is no more while app not active.

iOS state restoration logs warning instead of running in simulator

I have some odd behaviour in the iOS Simulator with state restoration. I've only recently realized it is only happening in the emulator. I'm wondering if there is something I am doing wrong. But I would also like to share my experience.
I created a single screen project in Xcode 5.0.2. In my application delegate I have only added two methods:
- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder
{
NSLog(#"I am restore.");
return YES;
} // */
- (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder
{
NSLog(#"I am save.");
return YES;
} // */
There are no other changes.
When debugging on an actual iPhone, I get both the log messages; "I am restore" on start up, and "I am save" when I press the home button to stop the app. If I comment out either one or both, I do not get any log messages. It seems that you need both methods for either to work. They don't even get called without the presence of the other.
When debugging in the iOS Simulator, (I don't know how to tell what version of the OS I'm using in the Simulator) I never get either of the log messages. If both methods are present, and only if both are present, I get "Warning: Unable to create restoration in progress marker file" showing up in my log, but I still don't get the log messages I made. So, the mere presence of both will cause a warning, but no force on Earth will allow them to be called. In the simulator. I tried adding a restoration id in the storyboard, but it didn't change anything.
I realize that Apple recommends running on an actual device and they don't guarantee similar behaviour on the simulator. But is there some setting I need to put somewhere to get state restoration working in the simulator? At one point I had it working, and I assumed that my storyboard changes had disrupted it. But with such a minimal app, I'm wondering if there is something more fundamental.
This is not a bug. These methods are called in preparation of state serialization for your app. State serialization never happens in the simulator because the app will not be terminated.
Ultimately, this is one of many differences between the simulator and actual devices. Always test on a device to ensure actual functionality.
Edit: State serialization can happen in the simulator by press the simulated 'home' key. ⌘⇧H
Often, the simulator start acting funny and the solution to most problem there is just to reset it.
In the simulator, click on the 'iOS Simulator menu' > 'Rest Content And Settings...'
I do this I think at least once a day, when the keyboard just stops responding or I get funny messages out of the blue.

GameCenter authentication in landscape-only app throws UIApplicationInvalidInterfaceOrientation

Problem:
If user is not logged into GameCenter account - GameCenter authentication view is launched in portrait mode (in ios 5 there were a modal dialog) asking to log in. But if I disable Portrait mode in xcode (Project Summary) or in supportedInterfaceOrientationsForWindow: (as my app supposed to run in landscape mode ONLY) I get:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
If I enable Portrait for ipad/iphone (and/or comment out supportedInterfaceOrientationsForWindow:) it works without crash, but I don't want portrait mode to be enabled.
While writing this question and experimenting with code, it seems that I've found a solution:
enable all orientations in project summary and remove application:supportedInterfaceOrientationsForWindow.
Add this code to ViewController:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
Now it works seamlessly.
Add to app delegate:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {
return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);
}
I have found that the problem is coming from the Game Center in my case. When in the simulator I do not have the Game Center initialized yet, it would like to pop up the login view, but in portrait mode. Once it is reaching this point it crashes if I disallowed portrait orientation. Strange bug in the OS as Game Center should take the allowed orientations only to be inline with our intention of landscape user interface.
I do not have the solution yet, but I will post if I find it.
I had the same issue as you and I fixed it with a kinda, ugly work around, basically I have a global variable in my app that I use to choose what the valid interface orientations are. In the
- (NSInteger)application : (UIApplication *)supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if(orientationIndicator == 1){
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else if(orientationIndicator == 2){
return UIInterfaceOrientationMaskLandscape;
}
}
To declare the global variable put this in your appDelegate.m file :
int orientationIndicator = 1;
To import the global variable use :
extern int orientationIndicator;
Then you can change the value of orientation indicator and it will allow you to run in different interface types. So what I did was I start by making the orientationIndicator = 1. When you authenticate a player and initiate the login view controller set the orientation indicator to 2. When you dismiss the view (authenticate the player) then you can change it back to 1.
This is a slimy work around but it has worked for me.
Hope this helps!
Catching the exception appears to work just fine for me:
#try {
[rootNavigationController pushViewController:viewController animated:YES];
}
#catch (NSException *exception) {
//somehow, catching this exception just allows the view controller to be shown?
}
In iOS 6.0, the exception is thrown, but if you catch it then the viewController will still be shown and GameCenter will behave as expected in landscape orientation.
An alternate solution is just to target iOS 6.1 and above, as Apple fixed the bug by that release.

iPad UISplitviewControllers with Storyboards ands Cocos2d multiple scene error

I have a UISplitviewController app that's structured like the picture in this question:
UISplitViewController on iPad with Storyboards?
When I click on either Game #1 or Game #2, their respective game run.
However, if I click on the second game (either #1 or #2), I get this
error:
Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'You can't run an scene
if another Scene is running. Use replaceScene or pushScene instead'
How can I check to see if there's already an existing Cocos2d scene
and replace it when the second game is clicked? Ideally, I think I should keep both games running so
the user can click back to the other game. Is
this possible?
I tried to simply replace this line: [director runWithScene:scene];
with this line: [director replaceScene:scene];
Unfortunately, I get an error CCTextureAtlas.m, in method:
-(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start {...}
[Update]
I think I might need to stop the scene so everything is cleaned up properly. When I click on my Help screen, for example, my controller's viewWillDisappear gets called. This does not happen when switching between Cocos2d view controllers.
After following these instructions, and only creating the EAGLView once, I almost have it working, but I get a black screen for the second scene. Note that I do briefly see the new scene.
How can I check to see if there's already an existing Cocos2d scene
and replace it when the second game is clicked?
if ([[CCDirector sharedDirector] runningScene] == nil) {
[[CCDirector sharedDirector] runWithScene:sceneToRun];
} else {
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}

Resources