0x3009 android runtime_error ai_generated partial

E/EGL_emulation: tid XXXX: eglSurfaceAttrib(1234): error 0x3009 (EGL_BAD_MATCH)

ID: android/surfaceview-out-of-order-egl

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
1Evidence
2023-05-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Android 10 (API 29) active
Android 11 (API 30) active
Android 12 (API 31) active
Android Emulator 31.0.0 active

Root Cause

An EGL surface operation (like eglSurfaceAttrib) is called on a surface that is not properly initialized or has been destroyed, often due to threading issues in SurfaceView or TextureView rendering.

generic

中文

在未正确初始化或已销毁的表面上调用 EGL 表面操作(如 eglSurfaceAttrib),通常是由于 SurfaceView 或 TextureView 渲染中的线程问题。

Official Documentation

https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglSurfaceAttrib.xhtml

Workarounds

  1. 85% success Ensure that all EGL operations are performed on the same thread that created the EGL surface, typically the rendering thread. Use a Handler or GLSurfaceView.Renderer to synchronize.
    Ensure that all EGL operations are performed on the same thread that created the EGL surface, typically the rendering thread. Use a Handler or GLSurfaceView.Renderer to synchronize.
  2. 80% success Check that the surface has been created before calling eglSurfaceAttrib. In SurfaceView, override surfaceCreated() and set a flag; only call EGL operations after the flag is set.
    Check that the surface has been created before calling eglSurfaceAttrib. In SurfaceView, override surfaceCreated() and set a flag; only call EGL operations after the flag is set.
  3. 70% success If using the Android Emulator, try updating the emulator to the latest version or switch to a different graphics backend (e.g., SwiftShader instead of ANGLE).
    If using the Android Emulator, try updating the emulator to the latest version or switch to a different graphics backend (e.g., SwiftShader instead of ANGLE).

中文步骤

  1. 确保所有 EGL 操作在与创建 EGL 表面的同一线程上执行,通常是渲染线程。使用 Handler 或 GLSurfaceView.Renderer 进行同步。
  2. 在调用 eglSurfaceAttrib 之前检查表面是否已创建。在 SurfaceView 中,重写 surfaceCreated() 并设置标志;仅在标志设置后才调用 EGL 操作。
  3. 如果使用 Android 模拟器,尝试更新模拟器到最新版本,或切换到不同的图形后端(例如使用 SwiftShader 代替 ANGLE)。

Dead Ends

Common approaches that don't work:

  1. 70% fail

    The error can cause rendering artifacts or crashes on other devices or under specific conditions, and it may indicate a latent bug.

  2. 95% fail

    This does not address the underlying surface state mismatch and may cause undefined behavior.