Android EGL_BAD_ALLOC 的问题,有没有遇到并很好的解决了?

Yao-Wang 2011-05-18 07:40:12
见标题
...全文
8295 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xqhrs232 2011-12-16
  • 打赏
  • 举报
回复
xqhrs232 2011-12-16
  • 打赏
  • 举报
回复
Opengl es抛出的异常EGL_BAD_ALLOC
http://www.eoeandroid.com/thread-41982-1-1.html


我也遇到这个问题,根据3楼的提示,解决方法如下:
EglHelper.swap是在GLSurfaceView.java文件里的GLThread.guardedRun()调用的,而swap()所在的try没有catch,在try{}和finally{}之间加上catch (RuntimeException e){}就可以了。

xqhrs232 2011-12-16
  • 打赏
  • 举报
回复
也遇到这样的问题,在找解决的办法。
qthsrs232 2011-12-16
  • 打赏
  • 举报
回复
Issue 214: EGL_BAD_ALLOC on Android 2.3.x
http://code.google.com/p/libgdx/issues/detail?id=214
xqhrs232 2011-12-16
  • 打赏
  • 举报
回复
Issue 16124: GLSurfaceView in Android 2.3.x consistently produces EGL_BAD_ALLOC
http://code.google.com/p/android/issues/detail?id=16124



Reported by badlogic...@gmail.com, Apr 13, 2011
OVERVIEW
Opening and closing a simple GLSurfaceView based app multiple times on Android 2.3.x results in an EGL_BAD_ALLOC error during context creation.

STEPS TO REPRODUCE THE PROBLEM
1) Create a simple Android project, using the following Activity code:

public class EglBadAlloc extends Activity {
GLSurfaceView view;

@Override public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
view = new GLSurfaceView(this);
view.setRenderer(new Renderer() {
@Override public void onDrawFrame (GL10 gl) {
gl.glClearColor(1, 0, 0, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}

@Override public void onSurfaceChanged (GL10 gl, int width, int height) {
}

@Override public void onSurfaceCreated (GL10 gl, EGLConfig config) {
}
});

setContentView(view);
}

@Override public void onPause () {
super.onPause();
view.onPause();
}

@Override public void onResume() {
super.onResume();
view.onResume();
}
}

2) Install the app on a 2.3.x device and open/close it multiple times.
3) After reopening the app around the 20th time it will be force closed with the following stack trace, indicating an error while creating the EGL context:

04-13 13:33:24.400: VERBOSE/RenderScript_jni(191): surfaceDestroyed
04-13 13:33:24.460: ERROR/Surface(867): invalid token (identity=335)
04-13 13:33:24.470: ERROR/Surface(867): invalid token (identity=335)
04-13 13:33:24.470: ERROR/Surface(867): invalid token (identity=335)
04-13 13:33:24.470: ERROR/Adreno200-EGL(867): egliGetNativeWindowSize: unable to dequeue native buffer
04-13 13:33:24.470: ERROR/Surface(867): invalid token (identity=335)
04-13 13:33:24.470: ERROR/Surface(867): invalid token (identity=335)
04-13 13:33:24.470: ERROR/Adreno200-EGL(867): egliGetNativeWindowSize: unable to dequeue native buffer
04-13 13:33:24.470: ERROR/Surface(867): invalid token (identity=335)
04-13 13:33:24.480: WARN/dalvikvm(867): threadid=9: thread exiting with uncaught exception (group=0x40015560)
04-13 13:33:24.490: ERROR/AndroidRuntime(867): FATAL EXCEPTION: GLThread 41
04-13 13:33:24.490: ERROR/AndroidRuntime(867): java.lang.RuntimeException: eglMakeCurrent failed: EGL_BAD_ALLOC
04-13 13:33:24.490: ERROR/AndroidRuntime(867): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1080)
04-13 13:33:24.490: ERROR/AndroidRuntime(867): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1072)
04-13 13:33:24.490: ERROR/AndroidRuntime(867): at android.opengl.GLSurfaceView$EglHelper.createSurface(GLSurfaceView.java:992)
04-13 13:33:24.490: ERROR/AndroidRuntime(867): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1335)
04-13 13:33:24.490: ERROR/AndroidRuntime(867): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
04-13 13:33:24.490: WARN/ActivityManager(103): Force finishing activity com.badlogic.egl/.EglBadAlloc

FURTHER INFO
I tested this on an HTC Hero (1.5), Droid (2.1.1), HTC Desire HD (2.2) and Nexus One (2.3.3, GRI40). The application does not crash on devices with Android < 2.3.

I did a diff on the GLSurfaceView sources of Android 2.2 and saw that there is a new way to destroy the EGL context. I didn't put to much brain power into it, as i suspected that maybe EGL might be the problem, and not the GLSurfaceView. I therefore fetched the GLSurfaceView sources from the 2.2.1_r1 release (http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=opengl/java/android/opengl/GLSurfaceView.java;h=f904cdf6babbb0b65da366ceb0f30bf1a600d6c8;hb=ec721fd1db4d895b342cfb83c651e0b78afac4dd) and included it in my project along with the Activity code above (after some slight modifications). The problem did not disappear which leads me to the conclusion that either SurfaceView or the EGL implementation itself has a problem.

My Jedi powers are to weak to dig through Android's EGL implementation though, so i leave this to whoever picks up this bug (if ever).
Comment 1 by project member e...@google.com, Apr 13, 2011
(No comment was entered for this change.)
Owner: pixelfli...@gmail.com
Cc: e...@google.com
Labels: Component-GfxMedia

Comment 2 by skan0...@gmail.com, Apr 26, 2011
This EGL exception is reproduced in Android Froyo version either.
Especially, when changing orientation mode during accessing GL app like Gallery3D.
Comment 3 by shasha...@gmail.com, Aug 11, 2011
This is a bug in the C++ code due to a refcounting error in 2.3.3 only. The fix is in, but there is unfortunately no workaround: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=commitdiff;h=c3fba3be74669d59141a25b36e3a07a8e2605144
Comment 4 by rarin...@gmail.com, Sep 26, 2011
As the kernel.org is down now, can you share the diff patch?


xqhrs232 2011-12-16
  • 打赏
  • 举报
回复
xqhrs232 2011-12-16
  • 打赏
  • 举报
回复
eglCreateWindowSurface always return EGL_NO_SURFACE
http://groups.google.com/group/android-developers/msg/cb04923d7c931de8?dmode=source


> However, I always got a result EGL_NO_SURFACE, and a error log like
> this:
> E/Surface ( 1393): invalid token (identity=3D0)
> I guess it is because the video surface passed from UI is not proper
> to setup EGL environment. So my question is:
> What kind of window does eglCreateWindowSurface expect? Should it be
> the same with the movie view set from UI, or should I create a new
> surface?
>
> Thank you for your reply.


qthsrs232 2011-12-16
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20101112/15/85fe152f-21d7-4bce-9783-e0cb422b4ee1.html?seed=1433775139&r=76965225#r_76965225

error/surface invalid token(identity=438)

又出了新的错误!怀疑是不是OPENGL的对象不够什么的。
Jamse19860909 2011-05-20
  • 打赏
  • 举报
回复
同求解决办法

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧