I use OGRE 1.9RC1 in my game on Android. The game starts first is OK, but when I push the home button and return to the game, the game crash.
OGRE throw the exception swapbuffers failed, and the egl error is egl_bad_surface. I do not know why. The surface is valid.
btw: I use the JNI, not the native activity.
heres the error log.
11-14 15:34:10.420: I/OGRE(9703): EGL error 0x300D in virtual void Ogre::EGLWindow::swapBuffers(bool) at line 320 in ..\..\..\RenderSystems\GLES\src\EGL\OgreEGLWindow.cpp
11-14 15:34:10.420: E/OGRE(9703): OGRE EXCEPTION(3:RenderingAPIException): Fail to SwapBuffers in swapBuffers at ..\..\..\RenderSystems\GLES\src\EGL\OgreEGLWindow.cpp (line 323)
11-14 15:34:10.420: A/libc(9703): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 9703 (.geeeu.cloudapp)
I had this issue at one point around when v1-9-0RC1 got tagged, but I can't reproduce it now. My current environment is v1-9 tip, building with ndk-r8c toolchain, targetting platform android-10 armeabiv7.
Make sure the OgreJNI sample project exhibits the same behaviour.
c6burns wrote:I had this issue at one point around when v1-9-0RC1 got tagged, but I can't reproduce it now. My current environment is v1-9 tip, building with ndk-r8c toolchain, targetting platform android-10 armeabiv7.
Make sure the OgreJNI sample project exhibits the same behaviour.
Thanks c6burns.
I used the OGRE1-9-0RC1 SDK, theres is not OGREjni sample but the native activity. And the native activity sample is OK.
I used the Android JNI, so I am not sure there are bugs in the OGRE1-9-0RC1 SDK or in my game.
Do you have any suggestions? Thanks.
There's a JNI example if you build Ogre from source. What happens is when the app loses focus it calls _destroyInternalResources on the renderwindow, and when it gains focus it calls _createInternalResources again. This has to be done if you are using a SurfaceView since you are managing the EGL window. With a GLSurfaceView you manage EGL from the java side, so things would be different. Below is an excerpt from the OgreJNI sample ... initWindow is called on resume while termWindow is called on pause:
c6burns , I have done like the OgreJNI sample. I used the SurfaceView, initWindow is called on surfaceCreated, termWindow is called on surfaceDestroy, but it doesn't work.
Heres the code.
Well like I mentioned, I didn't resolve this through skill or awesome troubleshooting. I resolved my issue by updating ogre, changing ndk platform target, and using updated android dependencies (thanks Wolfman!). v1-9-0RC1 was tagged around 6 months ago now, I think. I can no longer reproduce the swap buffer issue in my environment. Long story short ... update some stuff and maybe it'll go away
I am using Ogre 1.9 Stable release with OgreJNI and facing the same issue. I am calling _destroyInternalResources() in onPause and _createInternalResources() in onSurfaceCreated. After resuming the app i got this log
OGRE EXCEPTION(3:RenderingAPIException): Fail to SwapBuffers in swapBuffers at /Users/svanga/Projects/android-working/sinbad-ogre-dd30349ea667/RenderSystems/GLES2/src/EGL/OgreEGLWindow.cpp (line 161)
I am stuck on this as i cant create an android application with out handling these window/lifecycle events sucessfully. Any updates on this issue?
@c6burns,
I have download the latest 1.9 branch code. I am still facing the same issue in OgreJNI sample provided.
The environment i used is
NDK : r8d
NDK API Level : 9
OS : Mac OS X
used cmake to build Ogre 1.9
I got rid of this issue by simply changing the android platform target to 10. Previously i was using android-14 as target. This is the only change i did.
Is there any dependency on android-10 or am i missing something? Strange fix though...
No after android-10 the UI use the GPU to render and thats cause some problems. I am not sure how to fix it the problem is that the shaders and everything is regenerated but the driver do not give me any log output anymore.