My program switches between two Activities
that each inflate a derived GLSurfaceView
that uses VBOs.
After switching back and forth between the two Activities a few times, the program crashes and throws the following exception:
Java.lang.RuntimeException: createContext failed: EGL_BAD_ALLOC
at android.opengl.GLSurfaceView$EglHelper
.throwEglException(GLSurfaceView.java:1079)
at android.opengl.GLSurfaceView$EglHelper
.throwEglException(GLSurfaceView.java:1071)
at android.opengl.GLSurfaceView$EglHelper
.start(GLSurfaceView.java:927)
at android.opengl.GLSurfaceView$GLThread
.guardedRun(GLSurfaceView.java:1248)
at android.opengl.GLSurfaceView$GLThread
.run(GLSurfaceView.java:1118)
Each time there is a context switch the VBO buffers are deleted, onStop() is called, and a new instance of the next Activity's GLSurfaceView
is inflated.
I refactored the program to run on only one GLSurfaceView
and Activity
, and the program seems to run without incident.
Only polygons and colors are used, no textures.
From doing some internet research, this is a recognized bug. So how do I do damage control?
EDIT: I SOLVED THE PROBLEM (I FORGOT TO CALL ONPAUSE() / ONRESTART() ON THE VIEWS).