80,353
社区成员
发帖
与我相关
我的任务
分享
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 0
I installed msttcore fonts into /usr/share/fonts/truetype/msttcorefonts
run skhello again and I now get:
SkFontHost::GetFileName unimplemented
I have successfully installed SKIA on MacOSX (unix) with no problems.
purging 191k from font cache [26 entries]
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
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.
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.
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 :)
//==============================
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.
Comment 9 by sla.shal...@gmail.com, 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.html
GlSurfaceView must be notified of Activity lifecycle, I did it and the problem is solved.
Hope this helps.
Comment 10 by olli.ala...@gmail.com, 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.