Ogre Android - Crash on Home Button

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Ogre Android - Crash on Home Button

Post by BigDave2001 »

Hi,

I'm getting *occasional* crashes in Ogre when pressing the home button on Android.

Code: Select all

OpenGL ES2 error 0x0506  in virtual void Ogre::GLES2RenderSystem::clearFrameBuffer(unsigned int, const Ogre::ColourValue&, Ogre::Real, short unsigned int) at line 1834
... and this one, which is much more common:

Code: Select all

OGRE EXCEPTION(3:RenderingAPIException): Fail to SwapBuffers in swapBuffers
I would expect that this is to do with OpenGL trying to render when losing focus (and context) - and I have a check when the window loses focus (APP_CMD_LOST_FOCUS) that stops the rendering update. However, with a bit of logging I can see the error is occurring before I receive any key or window messages (I actually don't appear to receive a key message for the home button).

It is a Nexus 7 - code is based on the last 1.9 (which had the comment - merging 1.8-1.9)

Any ideas? Are there any earlier methods of checking when the home button has been pressed?

Thanks
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: Ogre Android - Crash on Home Button

Post by Wolfmanfx »

Hi,

The problem could be the ndk - you get the messages with a bit of lag on the c++ side.
So it could be that the context is already invalid before the message arrives - i assume the crash happens when you go to the home screen or does it happen when you reopen it?
BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Re: Ogre Android - Crash on Home Button

Post by BigDave2001 »

Thanks for the reply.

Yes, it crashes when I close it. Don't think I've ever had it crash when I've re-opened it (and it has closed safely).
EDIT - when I say close, I mean, go to the home page.

If it is the NDK - is there a way round the problem?

Thanks
BigDave2001
Kobold
Posts: 37
Joined: Tue Feb 21, 2012 3:57 pm

Re: Ogre Android - Crash on Home Button

Post by BigDave2001 »

Think I've solved the problem:

APP_CMD_PAUSE

This is the first event (and one I wasn't checking) which occurs when the home button is pressed. Stopping rendering at this point appears to have solved it.
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: Ogre Android - Crash on Home Button

Post by Wolfmanfx »

Thats great i will incorporate into the sample browser.