EGL_BAD_CONFIG on few devices

Hi guys! I’ve got this problem - I’ve written very simple game and it works all good on iOS, but when I compiled it for android it does not launch on simulator and for example physical device Huawei P7 Lite with Android 5. When I tried to launch it on Samsung Grand Prime, S5, few LGs, S7 and Huawei P9 it works all good, but in simulator and few devices it does not.

Compiled for SDK 16 with NDK 14 armeabi-v7a. Cocos2dx straight from github.

This error comes up:
    03-29 22:48:55.389 2542-2619/com.skyhorn.simplegame I/OpenGLRenderer: Initialized EGL, version 1.4
03-29 22:48:55.389 2542-2619/com.skyhorn.simplegame D/OpenGLRenderer: Swap behavior 1
03-29 22:48:55.382 2542-2542/com.skyhorn.simplegame W/RenderThread: type=1400 audit(0.0:17): avc: denied { search } for name="graphics" dev="tmpfs" ino=4281 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:graphics_device:s0 tclass=dir permissive=0
                                                                        
                                                                        --------- beginning of crash
03-29 22:48:55.850 2542-2618/com.skyhorn.simplegame E/AndroidRuntime: FATAL EXCEPTION: GLThread 94
                                                                          Process: com.skyhorn.simplegame, PID: 2542
                                                                          java.lang.RuntimeException: createContext failed: EGL_BAD_CONFIG
                                                                              at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1211)
                                                                              at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1202)
                                                                              at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1052)
                                                                              at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1412)
                                                                              at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)

hi @th7nder
i have the same issue after pulling last commits from github v3 branch , did you manage to resolve this issue?

@slackmoehrle can you please look at this?

Thanks.

Guys :slight_smile: Could you please use official stable releases? :slight_smile:

@michio

if we want to get this work on v3.15 the editing needs to be done in the Cocos2dx activity class, when I replaced its contents with version from 3.14.1 it worked, but then the problems with shaders occured so I think it won’t be so easy.

in Cocos2dxActivity.java replace this function

public EGLContext createContext(
EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {

        // create GL ES 3 context first,
        // if failed, then try to create GL ES 2 context

        /*
        int[] attributes = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };
        // attempt to create a OpenGL ES 3.0 context
        EGLContext context = egl.eglCreateContext(
            display, eglConfig, EGL10.EGL_NO_CONTEXT, attributes);

        if (context == null) {
        */
            int[] attributes = new int[] {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
            EGLContext context = egl.eglCreateContext(
                display, eglConfig, EGL10.EGL_NO_CONTEXT, attributes);
        //}

        return context;
    }

It will work now but the eagl3.0 will be desabled. For me i needed a quick fix to send a build to the graphic artis. I’ll come back and investigate this problem.
For a start, the createContext returns a valid pointer for EAGL 3.0 but will crash later. The function is not marked to throw an exception, this could be a fix.

I created a new thread for this issue.