Game Development Community

BUG report. "sgx error: background gpu access not permitted" [SOLVED]

by Pedro Vicente · in iTorque 2D · 07/04/2011 (3:55 am) · 2 replies

Build: 1.4.1

Platform: only iDevice (iPad)

Issues: Switching between iTorque2D application and another iPad app causes application to crash with the message in the XCode debug console.

Quote:
sgx error: background gpu access not permitted

I know this report does not offer many details but does anyone ever get this error?

#1
07/12/2011 (8:33 am)
This is easy to reproduce and there is a solution available.
To reproduce, just create an empty project and add sound to it.

The error is triggered by this call in iPhoneOGLVideo.mm

-(void)swapBuffers {
	if( isLayedOut == true ) { 
		
		[context presentRenderbuffer:GL_RENDERBUFFER_OES];
		
	}
}



In my code I have a global flag that enables/disables sound like this

if( $Game::UsesAudio )
   initializeOpenAL();

If I disable sound, the error does *not* happen.

But I think the root cause of the problem is that, according to Apple's guidelines, an Open GL app must stop sending commands to the graphics pipeline while in the background.

Implementing a Multitasking-aware OpenGL ES Application


developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_Pro...

Quote:An OpenGL ES application is terminated if it attempts to execute OpenGL ES commands on the graphics hardware. This not only refers to calls made to OpenGL ES while your application is in the background, but also refers to previously submitted commands that have not yet completed.

Fix


As posted here

www.garagegames.com/community/forums/viewthread/118571

an easy fix is to add a boolean flag to stop the game loop while in the background.

I added this code to iPhoneMain.mm

bool bDoNotRun = false;
S32 gLastStart = 0;
void _iPhoneGameInnerLoop()
{
    if(bDoNotRun)
	{
		return;
	}

and then in these 2 functions

void _iPhoneGameResignActive()
{
	Con::executef( 1, "oniPhoneResignActive" );
    bDoNotRun = true;
}

void _iPhoneGameBecomeActive()
{
	Con::executef( 1, "oniPhoneBecomeActive" );
    bDoNotRun = false;
}

Like this my app only does not crash but also it resumes game play if put on foreground (without the change and no sound the app did not crash but terminated execution)


#2
08/01/2011 (12:36 am)
Looks like a good thing to add to the 1.5 release. Thanks Pedro.