wasabeef/android-gpuimage · critical · IllegalArgumentException

eglChooseConfig failed

Error message

eglChooseConfig failed

What it means

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.

Solutions

  1. Enable GPU acceleration on the emulator (Graphics: Hardware) or test on a physical device
  2. Simplify/relax the config spec produced by filterConfigSpec (drop optional attribs like stencil size)
  3. Log egl.eglGetError() after failure to identify the EGL error code
  4. Update device graphics drivers / target a newer GPUImage version

Example fix

// before
filterConfigSpec(spec) keeps EGL_STENCIL_SIZE 8 on devices without stencil support
// after
private int[] filterConfigSpec(int[] spec) {
    if (mEGLContextClientVersion != 2) return spec;
    return removeStencilAttrib(spec); // drop unsupported attribs on constrained devices
}
Defensive patterns

Strategy: validation

Validate before calling

// Before relying on the default spec, confirm at least one config matches
int[] spec = { EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_NONE };
int[] num = new int[1];
boolean ok = egl.eglChooseConfig(egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY), spec, null, 0, num);
if (!ok || num[0] <= 0) { /* relax spec / fallback renderer */ }

Try / catch

// try { gpuImage = new GPUImage(context); } catch (IllegalArgumentException e) { fallback to GLSurfaceView-based renderer or relaxed config }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of wasabeef/android-gpuimage@ceea576ec9 (2026-09-11). Data as JSON: /api/errors/c8407486f0af6690. Report an issue: GitHub.

Appendix: source

Thrown at library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java:777

         * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
         * EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
         *
         * @param egl     the EGL10 for the current display.
         * @param display the current display.
         * @return the chosen configuration.
         */
        EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
    }

    private abstract class BaseConfigChooser implements EGLConfigChooser {
        public BaseConfigChooser(int[] configSpec) {
            mConfigSpec = filterConfigSpec(configSpec);
        }

        public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
            int[] num_config = new int[1];
            if (!egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config)) {
                throw new IllegalArgumentException("eglChooseConfig failed");
            }

            int numConfigs = num_config[0];

            if (numConfigs <= 0) {
                throw new IllegalArgumentException("No configs match configSpec");
            }

            EGLConfig[] configs = new EGLConfig[numConfigs];
            if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) {
                throw new IllegalArgumentException("eglChooseConfig#2 failed");
            }
            EGLConfig config = chooseConfig(egl, display, configs);
            if (config == null) {
                throw new IllegalArgumentException("No config chosen");
            }
            return config;
        }

View on GitHub (pinned to ceea576ec9)