Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES crash on move background, iOS 5.1

I have a little issue about my application iOS. When i'm using the iOS simulator 5.1 ipad/iphone the application is working, but when i use a real iOS device (iPad and iPhone 5.1 too)

the application crashes when moving on background after clicking on home button... with this error:

libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
0x33240094:  trap   
0x33240096:  nop 

I found out that it's was OpenGL ES that was still calculating and making the application crash and found this function: glFinish();

But that still not working here a sample of my code:

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[CCDirector sharedDirector] resume];
}

- (void)applicationWillResignActive:(UIApplication *)application {
    glFinish();
    [[CCDirector sharedDirector] pause];
}

I think the problem is just here Is there someone who have an idea of my problem ? Thanks

EDIT:

Problem solved with that:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] stopAnimation];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[CCDirector sharedDirector] startAnimation];
}

maybe that can help someone x)

like image 654
John Smith Avatar asked May 16 '12 14:05

John Smith


2 Answers

In iOS 5.1 it is enforced that you cannot make a call to OpenGL after you have been requested to resign active.

- (void)applicationWillResignActive:(UIApplication *)application

Is the place to stop everything, whether it be a CADisplayLink or a [[CCDirector sharedDirector] stopAnimation]

like image 96
mmopy Avatar answered Oct 21 '22 00:10

mmopy


Technically, the last method you can make OpenGL calls from is this one:

- (void)applicationDidEnterBackground:(UIApplication *)application

Although it is often a good idea to suspend drawing after applicationWillResignActive, this is just a recommendation and some apps have requirements beyond this. What is actually enforced is that you cannot make any OpenGL calls once your app moves to the background.

From the docs:

Once your application exits its applicationDidEnterBackground: method, it must not make any new OpenGL ES calls. If your application makes an OpenGL ES call, it is terminated by iOS.

Also, remember to include glFinish() as your final GL call.

like image 36
sup Avatar answered Oct 21 '22 01:10

sup