见标题

解决方案 »

  1.   

    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){}就可以了。
      

  2.   

    EGL接口介绍(转) 
    http://www.cnblogs.com/wanqieddy/archive/2011/11/24.html
      

  3.   

    http://topic.csdn.net/u/20101112/15/85fe152f-21d7-4bce-9783-e0cb422b4ee1.html?seed=1433775139&r=76965225#r_76965225error/surface invalid token(identity=438)又出了新的错误!怀疑是不是OPENGL的对象不够什么的。
      

  4.   

    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.
      

  5.   

    GLSurfaceView NullPointerException randomly when game starts
    http://www.andengine.org/forums/development/glsurfaceview-nullpointerexception-randomly-when-game-starts-t2945.html
      

  6.   

    Issue 16124:  GLSurfaceView in Android 2.3.x consistently produces EGL_BAD_ALLOC  
    http://code.google.com/p/android/issues/detail?id=16124Reported by [email protected], 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/.EglBadAllocFURTHER 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 [email protected], Apr 13, 2011 
    (No comment was entered for this change.)
    Owner: [email protected]
    Cc: [email protected]
    Labels: Component-GfxMediaComment 2 by [email protected], 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 [email protected], 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 [email protected], Sep 26, 2011 
    As the kernel.org is down now, can you share the diff patch?
      

  7.   

    Issue 214:  EGL_BAD_ALLOC on Android 2.3.x  
    http://code.google.com/p/libgdx/issues/detail?id=214