wasabeef/android-gpuimage · critical · RuntimeException

eglInitialize failed

Error message

eglInitialize failed

What it means

eglInitialize(eglDisplay, version) returned EGL_FALSE, meaning the display handle exists but EGL could not be initialized for it. EglHelper throws RuntimeException since no context/surface creation can follow.

Solutions

  1. Check egl.eglGetError() (e.g. EGL_BAD_DISPLAY, EGL_NOT_INITIALIZED) for the root cause
  2. Retry after full EGL teardown (eglTerminate in a fresh process restart)
  3. Update GPUImage / switch rendering to GLSurfaceView which handles EGL differently
  4. Test on a physical device or a properly GPU-accelerated emulator
Defensive patterns

Strategy: try-catch

Try / catch

// catch (RuntimeException e) { read eglGetError(); restart render thread; degrade to non-GL rendering }

Prevention

When it happens

Trigger: eglInitialize fails with the default display handle — usually an uninitialized/invalid driver, incompatible EGL version, or display state corrupted after earlier failures in the same process.

Common situations: Broken graphics drivers on some Android devices, emulators with mismatched host-GPU drivers, calling start() on a thread after the process EGL state was torn down.

Related errors


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

Appendix: source

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

             * Get an EGL instance
             */
            egl = (EGL10) EGLContext.getEGL();

            /*
             * Get to the default display.
             */
            eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

            if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
                throw new RuntimeException("eglGetDisplay failed");
            }

            /*
             * We can now initialize EGL for that display
             */
            int[] version = new int[2];
            if (!egl.eglInitialize(eglDisplay, version)) {
                throw new RuntimeException("eglInitialize failed");
            }
            GLTextureView view = glTextureViewWeakRef.get();
            if (view == null) {
                eglConfig = null;
                eglContext = null;
            } else {
                eglConfig = view.eglConfigChooser.chooseConfig(egl, eglDisplay);

                /*
                 * Create an EGL context. We want to do this as rarely as we can, because an
                 * EGL context is a somewhat heavy object.
                 */
                eglContext = view.eglContextFactory.createContext(egl, eglDisplay, eglConfig);
            }
            if (eglContext == null || eglContext == EGL10.EGL_NO_CONTEXT) {
                eglContext = null;
                throwEglException("createContext");
            }

View on GitHub (pinned to ceea576ec9)