{"record":{"id":"9c6bc61f736da09c","repo":"wasabeef/android-gpuimage","slug":"eglchooseconfig-2-failed","errorCode":null,"errorMessage":"eglChooseConfig#2 failed","messagePattern":"eglChooseConfig#2 failed","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java","lineNumber":788,"sourceCode":"        public BaseConfigChooser(int[] configSpec) {\n            mConfigSpec = filterConfigSpec(configSpec);\n        }\n\n        public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {\n            int[] num_config = new int[1];\n            if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) {\n                throw new IllegalArgumentException(\"eglChooseConfig failed\");\n            }\n\n            int numConfigs = num_config[0];\n\n            if (numConfigs <= 0) {\n                throw new IllegalArgumentException(\"No configs match configSpec\");\n            }\n\n            EGLConfig[] configs = new EGLConfig[numConfigs];\n            if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) {\n                throw new IllegalArgumentException(\"eglChooseConfig#2 failed\");\n            }\n            EGLConfig config = chooseConfig(egl, display, configs);\n            if (config == null) {\n                throw new IllegalArgumentException(\"No config chosen\");\n            }\n            return config;\n        }\n\n        abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs);\n\n        protected int[] mConfigSpec;\n\n        private int[] filterConfigSpec(int[] configSpec) {\n            if (eglContextClientVersion != 2) {\n                return configSpec;\n            }\n            /* We know none of the subclasses define EGL_RENDERABLE_TYPE.\n             * And we know the configSpec is well formed.","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/wasabeef/android-gpuimage/blob/ceea576ec931c2968431ad46f1fb2e6d68a542e2/library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java#L770-L806","documentation":"The second eglChooseConfig call — which fills the pre-allocated EGLConfig[] after the first call reported numConfigs matches — returned EGL_FALSE. This is an EGL runtime failure during retrieval of the matched config list, and should be rare since the same spec just succeeded.","triggerScenarios":"eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config) fails on the filled-array pass, usually due to driver bugs, display/context state changing between calls, or a corrupted/terminated display.","commonSituations":"Flaky vendor EGL drivers on specific devices, activity/thread teardown racing the EglHelper startup, GL context created on a display that became invalid.","solutions":["Retry EglHelper.start() once before giving up","Log egl.eglGetError() to capture the EGL error code","Guard against concurrent start/stop calls (run EglHelper strictly on one GL thread)","Update GPUImage or swap GLSurfaceView-style EGL setup if the device is known-buggy"],"exampleFix":"// before\nif (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw ... }\n// after\nif (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) {\n    Log.e(TAG, \"eglChooseConfig#2 eglError=\" + egl.eglGetError());\n    throw new IllegalArgumentException(\"eglChooseConfig#2 failed\");\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// catch (IllegalArgumentException e) { logEglErrorAsWarning; restart EglHelper once; then surface a user-facing error }","preventionTips":["Keep all EGL work on one dedicated GL thread","Avoid concurrent start/stop lifecycle calls","Log eglGetError() for diagnosis"],"tags":["egl","android","opengl","driver-bug","config-selection"],"backgroundTag":"http-request-failed","analyzedSha":"ceea576ec931c2968431ad46f1fb2e6d68a542e2","analyzedAt":"2026-09-11T16:56:13.742Z","contentChangedAt":"2026-09-11T16:56:13.742Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}