Ji-Seong
Ji-Seong

Reputation: 25

can't release thread in opengles on android

I have some problem..

When call the function, eglReleaseThread(), immediately application is closed without any return value on specific device which is 'Galaxy S4'. other devices (galaxy note2,3 galaxy S7) don't make the error. I use JNI for openGLES 2.0 and the specific device has 4.3 version (API 18)

This is release Part source code.

if (mEGLDisplay != EGL_NO_DISPLAY) {
    CppLog("env - release - exist display");
    if(!eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)){
        CppError("ImageProcGLES - eglMakeCurrent");
        return -1;
    }
    else{
        CppLog("env - release - eglMakeCurrent");
    }

    if(!eglDestroySurface(mEGLDisplay, mEGLSurface)){
        CppError("ImageProcGLES - eglDestroySurface Error.");
        return -1;
    }
    else{
        CppLog("env - release - eglDestroySurface");
    }

    if(!eglDestroyContext(mEGLDisplay, mEGLContext)){
        CppError("ImageProcGLES - eglDestroyContext.");
        return -1;
    }else{
        CppLog("env - release - eglDestroyContext");
    }

    if(!eglReleaseThread()){
        CppError("ImageProcGLES - eglReleaseThread.");
        return -1;
    }else{
        CppLog("env - release - eglReleaseThread");
    }

    if(!eglTerminate(mEGLDisplay)){
        CppError("ImageProcGLES - eglTerminate.");
        return -1;
    }else{
        CppLog("env - release - eglTerminate");
    }
}
else{
    CppError("env - release - No Display");
}

and this is return log.

    buffer - release
    env - release - start
    env - release - exist display
    env - release - eglMakeCurrent
    env - release - eglDestroySurface
    env - release - eglDestroyContext

If you have some idea... please help me :(

Upvotes: 2

Views: 745

Answers (1)

alexandr.opara
alexandr.opara

Reputation: 454

It is a bug in EGL driver. I used to have the same issue, to work around it create egl surface from Surface and not SurfaceTexture. When you create surface:

mSurface = new Surface(mSurfaceTexture);
             mEglSurface = EGL14.eglCreateWindowSurface(mEglDisplay, 
mEglConfig, mSurface, surfaceAttribs, 0);

Key moment here is to create Surface from SurfaceTexture:

Surface surface = new Surface(mSurfaceTexture);

Upvotes: 1

Related Questions