Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing the EGL2.0 context between 2 GLSurfaceViews caused EGL_BAD_ACCESS on Android tablets

I try to share EGL context bwteen 2 GLSurfaceViews by following code:

createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
    EGLContext shared = ...; // a cached egl context
    int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
    EGLContext context = egl.eglCreateContext(display, eglConfig, shared == null ? EGL10.EGL_NO_CONTEXT : shared,
        attrib_list);
    return context;
  }
}

The code works on most of the android phones (OS>=2.2) but failed on all the tested tablets.

01-12 18:33:35.381: E/AndroidRuntime(12171): FATAL EXCEPTION: GLThread 11

01-12 18:33:35.381: E/AndroidRuntime(12171): java.lang.RuntimeException: eglMakeCurrent failed: EGL_BAD_ACCESS

01-12 18:33:35.381: E/AndroidRuntime(12171): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1146)

Since I declared the LOCAL_LDLIBS: = -lGLESv2, the EGL is a 2.0 context.

Why it failed on tablets(xoom, galaxy, lg, sony, etc)

Any insight is appreciated.

like image 658
Shu Sang Avatar asked Nov 05 '22 07:11

Shu Sang


1 Answers

Two possible reasons for this failure (from the EGL spec):

  • If ctx is current to some other thread, or if either draw or read are bound to contexts in another thread, an EGL_BAD_ACCESS error is generated.
  • If binding ctx would exceed the number of current contexts of that client API type supported by the implementation, an EGL_BAD_ACCESS error is generated.

It could also be that the GPU you are using on tablets does not support shared context.

like image 54
Romain Guy Avatar answered Nov 12 '22 17:11

Romain Guy