wasabeef/android-gpuimage · error · RuntimeException
egl not initialized
Error message
egl not initialized
What it means
createSurface() was called before EglHelper.start() had run (or after it failed), leaving the internal egl handle null. The preconditions check throws RuntimeException because surface creation is impossible without an initialized EGL instance.
Solutions
- Ensure start() completes successfully before createSurface(); check for swallowed earlier exceptions
- Keep the EglHelper lifecycle on a single GL thread with proper ordering (start -> createSurface -> ... )
- Log the earlier EglHelper.start() failure that left egl null
- Restart the render thread cleanly on failure instead of continuing
Example fix
// before
if (egl == null) throw new RuntimeException("egl not initialized");
// after
if (egl == null) {
Log.e(TAG, "createSurface called before start(); restarting EglHelper");
start();
if (egl == null) throw new RuntimeException("egl not initialized");
} Defensive patterns
Strategy: validation
Validate before calling
// Before creating a surface on the GL thread
if (eglHelper == null || !eglHelper.isStarted()) { eglHelper.start(); } Try / catch
// catch (RuntimeException e) { restart the GL thread / EglHelper rather than crashing } Prevention
- Enforce strict lifecycle order start -> createSurface on one thread
- Never swallow exceptions from start()
- Cancel pending surface work once stop() is invoked
When it happens
Trigger: GLThread invokes createSurface() while egl == null — start() never completed, failed earlier (e.g. errors 4/5), or stop() was called before createSurface on the GL thread.
Common situations: Race between setting the GLThread's paused/size and the EglHelper lifecycle, calling requestRender/createSurface paths before the thread finished starting, swallowing earlier EGL init exceptions.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- eglDisplay not initialized
- eglConfig not initialized
- eglChooseConfig failed
- No configs match configSpec
- eglChooseConfig#2 failed
AI-assisted analysis of wasabeef/android-gpuimage@ceea576ec9 (2026-09-11).
Data as JSON: /api/errors/0189bfe1f296e8cc.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java:962
eglSurface = null;
}
/**
* Create an egl surface for the current SurfaceHolder surface. If a surface
* already exists, destroy it before creating the new surface.
*
* @return true if the surface was created successfully.
*/
public boolean createSurface() {
if (LOG_EGL) {
Log.w("EglHelper", "createSurface() tid=" + Thread.currentThread().getId());
}
/*
* Check preconditions.
*/
if (egl == null) {
throw new RuntimeException("egl not initialized");
}
if (eglDisplay == null) {
throw new RuntimeException("eglDisplay not initialized");
}
if (eglConfig == null) {
throw new RuntimeException("eglConfig not initialized");
}
/*
* The window size has changed, so we need to create a new
* surface.
*/
destroySurfaceImp();
/*
* Create an EGL surface we can render into.
*/
GLTextureView view = glTextureViewWeakRef.get();View on GitHub (pinned to ceea576ec9)