Android 2.3.x下,基于OpenGL的程序多次切来切去报EGL_BAD_ALLOC错误
解决方案 »
- sdcard无法读写文件
- Cannot play video: VideoView(278): Error: 1,-2147483648
- 大侠们请进,关于ListView中RadioButton单选问题。
- android如何进行实时播放
- 布局的问题
- 类似UCWEB中登陆界面时进度条是如何实现的?
- Android 应用 怎么读取自身apk文件 (data/app目录下的)
- No compatible target were found. Do you wish to add a new Android Virtual Device
- Android 获取系统所占存储空间大小(不是内存)
- 新手小白,有没有大师帮忙我
- adb logcat 过滤打印信息
- 如何读2.4Ghz 键盘的码值?
http://topic.csdn.net/u/20110518/07/0af5e87f-87da-4bf5-874a-abe1fed1b4d7.html[Android] OpenGL eglSwapBuffers failed: EGL_BAD_ALLOC?
http://topic.csdn.net/u/20101112/15/85fe152f-21d7-4bce-9783-e0cb422b4ee1.html
http://code.google.com/p/android/issues/detail?id=16124Issue 214: EGL_BAD_ALLOC on Android 2.3.x
http://code.google.com/p/libgdx/issues/detail?id=214
http://code.google.com/p/android/issues/detail?id=12378
Comment 9 by [email protected], Jun 23, 2011
Oh well, it turns out it is our fault as developers: s stated here: http://developer.android.com/reference/android/opengl/GLSurfaceView.htmlGlSurfaceView must be notified of Activity lifecycle, I did it and the problem is solved.Hope this helps.Comment 10 by [email protected], Jun 23, 2011
Tested my app with Nexus S and ZTE Blade (CM7), and only ZTE Blade would give me this error occasionally when going to/returning from background.After fixing some other problems I got this one solved out too.
I added several lines of code to prevent GLThread from being executed at ill times (mostly when textures or the context wasn't ready). I also added appropriate onResume and onPause calls. So it is very likely that this is the solution and that some devices just suppress these kind of errors.
http://stackoverflow.com/questions/4768439/android-drawing-text-with-opengl-es-crashes-after-a-few-minutesThe trouble is that I was generating textures repeatedly without ever deleting them. Simply adding one line before generation is enough to prevent a memory leak (it seems there is no need to check that a texture has already been generated): gl.glDeleteTextures(1, texturesFPS, 1); gl.glGenTextures(1, texturesFPS, 1); Simple as that :)
//==============================
Looks like you're creating a new texture each time you call loadFPSTexture(), and never release it. After some time this will cause you to run out of memory, which could explain the EGL_BAD_ALLOC in your logs.It would be better to create your bitmap, canvas and texturesFPS variables just once, and reuse them in the loadFPSTexture() function. In that case, you should probably use GLUtils.texSubImage2D() instead of GLUtils.texImage2D(), to upload new bitmap data to the existing texture.
难道还是因为纹理没释放把内存占用完了,所以报EGL_BAD_ALLOC错误?!
在产生纹理的前面加删除纹理的程序,就可以解决这个问题?不需要去判断纹理是不是已经被创建从而可以去删除它.The trouble is that I was generating textures repeatedly without ever deleting them. Simply adding one line before generation is enough to prevent a memory leak (it seems there is no need to check that a texture has already been generated):gl.glDeleteTextures(1, texturesFPS, 1); //在创建之前先删除,可以不管是否已经被创建
gl.glGenTextures(1, texturesFPS, 1);
Simple as that :)
http://stackoverflow.com/questions/6039107/android-glsurfaceview-egl-bad-allocMy 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.
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. Here's the damage: 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) From doing some internet research, this is a recognized bug. So how do I do damage control? +200 for a nudge in the right direction.EDIT: I SOLVED THE PROBLEM (I FORGOT TO CALL ONPAUSE() / ONRESTART() ON THE VIEWS).
FIRST PERSON TO PUT AN ANSWER ABOUT ANYTHING WHATSOEVER GETS +200.
1>
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).
2>
In short, remember to pass onPause and onResume to both your super and to the GLSurfaceView.From http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html:看来的记得在恰当的地方恰当的时间正确调用继承自GLSurfaceView类的成员函数----onPause( )+onResume( ).
EglHelper.swap是在GLSurfaceView.java文件里的GLThread.guardedRun()调用的,而swap()所在的try没有catch,在try{}和finally{}之间加上catch (RuntimeException e){}就可以了。
erroe/surface invalid token(identity=438)又出了新的错误!怀疑是不是OPENGL的对象不够什么的。
purging 191k from font cache [26 entries]
purging 191k from font cache [26 entries]
process com.android.deskclock(pid 1046) has died.
---no context for glyph 0
http://code.google.com/p/skia/issues/detail?id=97
Compiled (after a quick fix due to pnt_set_gray_1_2_4_to_8 no longer part of libpng) libskia.a, then compiled skhello (with SKIA_DEBUG=true).skhello compiles ok, but when run from the command line I get:
--- no context for glyph 0
--- no context for glyph 0I installed msttcore fonts into /usr/share/fonts/truetype/msttcorefontsrun skhello again and I now get:
SkFontHost::GetFileName unimplementedI have successfully installed SKIA on MacOSX (unix) with no problems.
http://developer.android.com/search.html#q=EGL_BAD_ALLOC&t=0
http://source.android.com/index.html
http://source.android.com/index.html