EGL2.0 context sharing between 2 GLSurfaceViews triggered EGL_BAD_ACCESS on Android tablets

I am trying to use the EGL context of bwteen 2 GLSurfaceViews with the 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 Android phones (OS> = 2.2), but failed on all 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 LOCAL_LDLIBS: = -lGLESv2, EGL is a 2.0 context.

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

Any understanding is understood.

+4
source share
2 answers

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

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

It may also be that the graphics processor that you use on tablets does not support the general context.

+1
source

Most likely, the following lines are the cause of the error in GLSurfaceView.

 public GL createSurface(SurfaceHolder holder) { .... /* * Before we can issue GL commands, we need to make sure * the context is current and bound to a surface. */ if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) { throwEglException("eglMakeCurrent"); } } 
0
source

Source: https://habr.com/ru/post/1390764/


All Articles