{"record":{"id":"c8407486f0af6690","repo":"wasabeef/android-gpuimage","slug":"eglchooseconfig-failed","errorCode":null,"errorMessage":"eglChooseConfig failed","messagePattern":"eglChooseConfig failed","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java","lineNumber":777,"sourceCode":"         * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the\n         * EGL specification available from The Khronos Group to learn how to call eglChooseConfig.\n         *\n         * @param egl     the EGL10 for the current display.\n         * @param display the current display.\n         * @return the chosen configuration.\n         */\n        EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);\n    }\n\n    private abstract class BaseConfigChooser implements EGLConfigChooser {\n        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        }","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/wasabeef/android-gpuimage/blob/ceea576ec931c2968431ad46f1fb2e6d68a542e2/library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java#L759-L795","documentation":"eglChooseConfig(EGLDisplay, null, 0, num_config) returned EGL_FALSE, meaning the EGL call itself failed (bad display, uninitialized EGL, or invalid attrib list). GLTextureView's EglHelper throws IllegalArgumentException from its internal ConfigChooser before any configs can be counted. It signals an EGL-level failure, not merely an empty result set.","triggerScenarios":"EglHelper.start() -> chooseConfig() when eglChooseConfig returns EGL_FALSE, typically due to an invalid or unsupported mConfigSpec attribute list (e.g. EGL_STENCIL_SIZE or unusual bits) or EGL not properly initialized on the display.","commonSituations":"Devices/emulators with limited EGL implementations, vendor drivers rejecting the hard-coded RGBA8888 config spec, running on an emulator without GPU acceleration (host GPU off), or mis-specified filterConfigSpec overrides.","solutions":["Enable GPU acceleration on the emulator (Graphics: Hardware) or test on a physical device","Simplify/relax the config spec produced by filterConfigSpec (drop optional attribs like stencil size)","Log egl.eglGetError() after failure to identify the EGL error code","Update device graphics drivers / target a newer GPUImage version"],"exampleFix":"// before\nfilterConfigSpec(spec) keeps EGL_STENCIL_SIZE 8 on devices without stencil support\n// after\nprivate int[] filterConfigSpec(int[] spec) {\n    if (mEGLContextClientVersion != 2) return spec;\n    return removeStencilAttrib(spec); // drop unsupported attribs on constrained devices\n}","handlingStrategy":"validation","validationCode":"// Before relying on the default spec, confirm at least one config matches\nint[] spec = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_NONE };\nint[] num = new int[1];\nboolean ok = egl.eglChooseConfig(egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY), spec, null, 0, num);\nif (!ok || num[0] <= 0) { /* relax spec / fallback renderer */ }","typeGuard":null,"tryCatchPattern":"// try { gpuImage = new GPUImage(context); } catch (IllegalArgumentException e) { fallback to GLSurfaceView-based renderer or relaxed config }","preventionTips":["Test on the lowest-end device and on software-rendered emulators","Keep the EGL config spec minimal; drop stencil unless required","Log eglGetError() at every EGL step"],"tags":["egl","android","opengl","gpuimage","config-selection"],"backgroundTag":"invalid-config-value","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"}