{
  "id": "android/surfaceview-out-of-order-egl",
  "signature": "E/EGL_emulation: tid XXXX: eglSurfaceAttrib(1234): error 0x3009 (EGL_BAD_MATCH)",
  "signature_zh": "E/EGL_emulation: tid XXXX: eglSurfaceAttrib(1234): 错误 0x3009 (EGL_BAD_MATCH)",
  "regex": "E/EGL_emulation: tid \\d+: eglSurfaceAttrib\\(\\d+\\): error 0x3009 \\(EGL_BAD_MATCH\\)",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "在未正确初始化或已销毁的表面上调用 EGL 表面操作（如 eglSurfaceAttrib），通常是由于 SurfaceView 或 TextureView 渲染中的线程问题。",
  "versions": [
    {
      "version": "Android 10 (API 29)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 11 (API 30)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 12 (API 31)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android Emulator 31.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error can cause rendering artifacts or crashes on other devices or under specific conditions, and it may indicate a latent bug.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This does not address the underlying surface state mismatch and may cause undefined behavior.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.85,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.8,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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).",
      "success_rate": 0.7,
      "how": "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).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保所有 EGL 操作在与创建 EGL 表面的同一线程上执行，通常是渲染线程。使用 Handler 或 GLSurfaceView.Renderer 进行同步。",
    "在调用 eglSurfaceAttrib 之前检查表面是否已创建。在 SurfaceView 中，重写 surfaceCreated() 并设置标志；仅在标志设置后才调用 EGL 操作。",
    "如果使用 Android 模拟器，尝试更新模拟器到最新版本，或切换到不同的图形后端（例如使用 SwiftShader 代替 ANGLE）。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglSurfaceAttrib.xhtml",
  "official_doc_section": null,
  "error_code": "0x3009",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2023-05-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}