wasabeef/android-gpuimage · error · RuntimeException

eglDisplay not initialized

Error message

eglDisplay not initialized

What it means

This RuntimeException is a precondition guard inside EglHelper.createSurface(): it fires when createSurface() is called before start() has successfully initialized the EGL objects, leaving eglDisplay null. It is a generic sentinel check — the input at fault is the helper's uninitialized state, typically caused by calling createSurface() out of order (e.g., before start()) or after a failed/aborted start() that never reached eglDisplay = egl.eglGetDisplay(). Callers must ensure start() succeeds before requesting surface creation.

Solutions

  1. Verify start() succeeded (check logs for 'eglGetDisplay/Initialize failed') before creating surfaces
  2. Synchronize EglHelper lifecycle; cancel pending createSurface when stop() runs
  3. Re-run start() if display is null and the view is still attached
  4. Don't reuse EglHelper after stop(); create a fresh instance per render thread
Defensive patterns

Strategy: validation

Validate before calling

if (eglDisplay == null) { /* re-run start() or abort createSurface */ }

Try / catch

// catch (RuntimeException e) { reinitialize EglHelper if view still attached; else exit GL thread quietly }

Prevention

When it happens

Trigger: createSurface() runs while eglDisplay == null: start() aborted at eglGetDisplay/eglInitialize, or stop() nulls state while a createSurface request was already queued on the GL thread.

Common situations: Activity paused/destroyed racing GLThread startup, EglHelper.start() exception being caught and ignored, calling surface-creation paths after stop().

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


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

Appendix: source

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

        /**
         * 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();
            if (view != null) {
                eglSurface = view.eglWindowSurfaceFactory.createWindowSurface(egl, eglDisplay, eglConfig,
                        view.getSurfaceTexture());

View on GitHub (pinned to ceea576ec9)