{
  "id": "android/compose-recomposition-infinite-loop",
  "signature": "java.lang.StackOverflowError: stack size 8MB at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd",
  "signature_zh": "java.lang.StackOverflowError: 栈大小8MB在androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd",
  "regex": "java\\.lang\\.StackOverflowError: stack size \\d+MB at androidx\\.compose\\.runtime\\.ComposerImpl\\.recomposeToGroupEnd",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Infinite recomposition loop in Jetpack Compose due to a state variable being updated during composition (e.g., calling setState inside a LaunchedEffect without proper key or in a composable lambda that triggers re-render).",
  "root_cause_type": "generic",
  "root_cause_zh": "Jetpack Compose中无限重组循环，由于状态变量在组合期间被更新（例如，在没有正确键的LaunchedEffect中调用setState，或触发重新渲染的可组合lambda中）。",
  "versions": [
    {
      "version": "Compose BOM 2024.01.00",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Compose Compiler 1.5.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Kotlin 1.9.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Android 14 (API 34)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase stack size via AndroidManifest android:largeHeap=\"true\"",
      "why_fails": "largeHeap increases heap memory, not stack size. Stack size is fixed per thread in Android (8MB default). This does not fix the infinite loop.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrap the state update in withFrameMillis or withFrameNanos",
      "why_fails": "These APIs schedule work on the next frame but do not prevent the recomposition loop if the state is still updated during composition.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Move the state update outside of composition by using LaunchedEffect with a stable key. Example: LaunchedEffect(Unit) { delay(100); myState.value = newValue } instead of LaunchedEffect(myState.value) { ... }",
      "success_rate": 0.9,
      "how": "Move the state update outside of composition by using LaunchedEffect with a stable key. Example: LaunchedEffect(Unit) { delay(100); myState.value = newValue } instead of LaunchedEffect(myState.value) { ... }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use remember with a derivedStateOf to compute values without triggering recomposition. Example: val derivedValue by remember { derivedStateOf { computeExpensive(myState.value) } }",
      "success_rate": 0.85,
      "how": "Use remember with a derivedStateOf to compute values without triggering recomposition. Example: val derivedValue by remember { derivedStateOf { computeExpensive(myState.value) } }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a snapshotFlow block to observe state changes outside composition. Example: LaunchedEffect(Unit) { snapshotFlow { myState.value }.collect { /* update other state */ } }",
      "success_rate": 0.88,
      "how": "Add a snapshotFlow block to observe state changes outside composition. Example: LaunchedEffect(Unit) { snapshotFlow { myState.value }.collect { /* update other state */ } }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Move the state update outside of composition by using LaunchedEffect with a stable key. Example: LaunchedEffect(Unit) { delay(100); myState.value = newValue } instead of LaunchedEffect(myState.value) { ... }",
    "Use remember with a derivedStateOf to compute values without triggering recomposition. Example: val derivedValue by remember { derivedStateOf { computeExpensive(myState.value) } }",
    "Add a snapshotFlow block to observe state changes outside composition. Example: LaunchedEffect(Unit) { snapshotFlow { myState.value }.collect { /* update other state */ } }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/jetpack/compose/state#side-effects-in-compose",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.86,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}