wasabeef/android-gpuimage · critical · IllegalArgumentException
eglChooseConfig#2 failed
Error message
eglChooseConfig#2 failed
What it means
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.
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
Example fix
// before
if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) { throw ... }
// after
if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config)) {
Log.e(TAG, "eglChooseConfig#2 eglError=" + egl.eglGetError());
throw new IllegalArgumentException("eglChooseConfig#2 failed");
} Defensive patterns
Strategy: retry
Try / catch
// catch (IllegalArgumentException e) { logEglErrorAsWarning; restart EglHelper once; then surface a user-facing error } Prevention
- Keep all EGL work on one dedicated GL thread
- Avoid concurrent start/stop lifecycle calls
- Log eglGetError() for diagnosis
When it happens
Trigger: 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.
Common situations: Flaky vendor EGL drivers on specific devices, activity/thread teardown racing the EglHelper startup, GL context created on a display that became invalid.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- eglChooseConfig failed
- No config chosen
- eglConfig not initialized
- No configs match configSpec
- eglGetDisplay failed
AI-assisted analysis of wasabeef/android-gpuimage@ceea576ec9 (2026-09-11).
Data as JSON: /api/errors/9c6bc61f736da09c.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java:788
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;
}
abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs);
protected int[] mConfigSpec;
private int[] filterConfigSpec(int[] configSpec) {
if (eglContextClientVersion != 2) {
return configSpec;
}
/* We know none of the subclasses define EGL_RENDERABLE_TYPE.
* And we know the configSpec is well formed.View on GitHub (pinned to ceea576ec9)