eglSwapBuffers failed: EGL_BAD_ALLOC AndEngine Android

与世无争的帅哥 提交于 2019-12-21 02:26:25

问题


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??


回答1:


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.




回答2:


In my experience (which is specific to my Samsung Note, and no other Android device I've tested so far), is that EGL_BAD_ALLOC will be incorrectly produced by eglSwapBuffers() instead of EGL_BAD_CURRENT_SURFACE. If your code handles re-creating the surface, it should be trivial to handle this obscure case as well.



来源:https://stackoverflow.com/questions/9293241/eglswapbuffers-failed-egl-bad-alloc-andengine-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!