{
  "id": "android/renderscript-rs-invalid-element",
  "signature": "FATAL EXCEPTION: RSMessageThread. Error: rsInvalidElement: invalid element at libs/renderscript/rsCpuCore.c:1234",
  "signature_zh": "致命异常：RSMessageThread。错误：rsInvalidElement：libs/renderscript/rsCpuCore.c：1234 处的元素无效",
  "regex": "rsInvalidElement.*rsCpuCore\\.c:\\d+",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "RenderScript allocation or kernel operation uses an incorrectly defined or mismatched Element type, often due to mixing float and int types in script or passing wrong allocation to forEach.",
  "root_cause_type": "generic",
  "root_cause_zh": "RenderScript 分配或内核操作使用了错误定义或不匹配的 Element 类型，通常是由于在脚本中混合使用浮点型和整型，或将错误的分配传递给 forEach。",
  "versions": [
    {
      "version": "Android 8.0 (API 26)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 10 (API 29)",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is not a runtime state issue but a script or allocation definition bug; clearing cache does not fix incorrect Element types.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error occurs regardless of SDK version if the Element definition in the script is invalid; changing minSdkVersion does not correct the script logic.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "In your .rs script, ensure all allocations use matching Element types. For example, if passing a float allocation, define the kernel with `__attribute__((kernel)) void root(const float *v_in, float *v_out)` and create the allocation with `Element.F32(rs)`. Do not mix int and float.",
      "success_rate": 0.85,
      "how": "In your .rs script, ensure all allocations use matching Element types. For example, if passing a float allocation, define the kernel with `__attribute__((kernel)) void root(const float *v_in, float *v_out)` and create the allocation with `Element.F32(rs)`. Do not mix int and float.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Replace RenderScript with Android's NDK or custom C++ code using `android::renderscript::RS` API, and validate Element creation with `rsCreateElement()` using correct data type enum (e.g., `RS_TYPE_FLOAT_32`).",
      "success_rate": 0.8,
      "how": "Replace RenderScript with Android's NDK or custom C++ code using `android::renderscript::RS` API, and validate Element creation with `rsCreateElement()` using correct data type enum (e.g., `RS_TYPE_FLOAT_32`).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "In your .rs script, ensure all allocations use matching Element types. For example, if passing a float allocation, define the kernel with `__attribute__((kernel)) void root(const float *v_in, float *v_out)` and create the allocation with `Element.F32(rs)`. Do not mix int and float.",
    "Replace RenderScript with Android's NDK or custom C++ code using `android::renderscript::RS` API, and validate Element creation with `rsCreateElement()` using correct data type enum (e.g., `RS_TYPE_FLOAT_32`)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/guide/topics/renderscript",
  "official_doc_section": null,
  "error_code": "rsInvalidElement",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}