eglSwapBuffers failed: EGL_BAD_ALLOC AndEngine Android

Jawad Amjad picture Jawad Amjad · Feb 15, 2012 · Viewed 7.6k times · Source

I m developing a game in And engine which throws the exception. Actually I don't know the point where exceptions occurs. It is reported in market many many time.

    java.lang.RuntimeException: eglSwapBuffers failed: EGL_BAD_ALLOC
at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1080)
at android.opengl.GLSurfaceView$EglHelper.swap(GLSurfaceView.java:1038)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1364)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

is there any solution for this one??

Answer

haffax picture haffax · Feb 15, 2012

This error can occur when you don't notify the GLSurfaceView about state transistions of your Activity. See the following paragraph from here: http://developer.android.com/reference/android/opengl/GLSurfaceView.html

Activity Life-cycle

A GLSurfaceView must be notified when the activity is paused and resumed. GLSurfaceView clients are required to call onPause() when the activity pauses and onResume() when the activity resumes. These calls allow GLSurfaceView to pause and resume the rendering thread, and also allow GLSurfaceView to release and recreate the OpenGL display.

I don't know how andengine handles this though.