{"record":{"id":"0189bfe1f296e8cc","repo":"wasabeef/android-gpuimage","slug":"egl-not-initialized","errorCode":null,"errorMessage":"egl not initialized","messagePattern":"egl not initialized","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java","lineNumber":962,"sourceCode":"\n            eglSurface = null;\n        }\n\n        /**\n         * Create an egl surface for the current SurfaceHolder surface. If a surface\n         * already exists, destroy it before creating the new surface.\n         *\n         * @return true if the surface was created successfully.\n         */\n        public boolean createSurface() {\n            if (LOG_EGL) {\n                Log.w(\"EglHelper\", \"createSurface()  tid=\" + Thread.currentThread().getId());\n            }\n            /*\n             * Check preconditions.\n             */\n            if (egl == null) {\n                throw new RuntimeException(\"egl not initialized\");\n            }\n            if (eglDisplay == null) {\n                throw new RuntimeException(\"eglDisplay not initialized\");\n            }\n            if (eglConfig == null) {\n                throw new RuntimeException(\"eglConfig not initialized\");\n            }\n\n            /*\n             *  The window size has changed, so we need to create a new\n             *  surface.\n             */\n            destroySurfaceImp();\n\n            /*\n             * Create an EGL surface we can render into.\n             */\n            GLTextureView view = glTextureViewWeakRef.get();","sourceCodeStart":944,"sourceCodeEnd":980,"githubUrl":"https://github.com/wasabeef/android-gpuimage/blob/ceea576ec931c2968431ad46f1fb2e6d68a542e2/library/src/main/java/jp/co/cyberagent/android/gpuimage/GLTextureView.java#L944-L980","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nif (egl == null) throw new RuntimeException(\"egl not initialized\");\n// after\nif (egl == null) {\n    Log.e(TAG, \"createSurface called before start(); restarting EglHelper\");\n    start();\n    if (egl == null) throw new RuntimeException(\"egl not initialized\");\n}","handlingStrategy":"validation","validationCode":"// Before creating a surface on the GL thread\nif (eglHelper == null || !eglHelper.isStarted()) { eglHelper.start(); }","typeGuard":null,"tryCatchPattern":"// catch (RuntimeException e) { restart the GL thread / EglHelper rather than crashing }","preventionTips":["Enforce strict lifecycle order start -> createSurface on one thread","Never swallow exceptions from start()","Cancel pending surface work once stop() is invoked"],"tags":["egl","android","opengl","lifecycle","null-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"ceea576ec931c2968431ad46f1fb2e6d68a542e2","analyzedAt":"2026-09-11T16:56:13.742Z","contentChangedAt":"2026-09-11T16:56:13.742Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}