{
  "id": "unity/rendering-command-buffer-overflow",
  "signature": "ArgumentException: Command buffer overflow. Cannot push more commands. The maximum capacity is 2048.",
  "signature_zh": "参数异常：命令缓冲区溢出。无法推送更多命令。最大容量为2048。",
  "regex": "Command buffer overflow\\. Cannot push more commands\\. The maximum capacity is \\d+",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A script or shader pushes too many commands into a CommandBuffer, exceeding the default capacity of 2048 commands.",
  "root_cause_type": "generic",
  "root_cause_zh": "脚本或着色器向命令缓冲区推送了过多命令，超出默认容量2048。",
  "versions": [
    {
      "version": "2021.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2022.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2023.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "CommandBuffer capacity is hardcoded internally; no public API exists to change it. Attempting to do so causes compilation errors.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Removing CommandBuffers may break custom rendering effects like outlines or post-processing.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing pipeline requires rewriting shaders and materials, which is a large refactor and may not resolve buffer overflow.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Batch commands using CommandBuffer.Clear before pushing new ones. For example, in an Update loop, call cmdBuffer.Clear() at the start of each frame and rebuild only necessary commands.",
      "success_rate": 0.9,
      "how": "Batch commands using CommandBuffer.Clear before pushing new ones. For example, in an Update loop, call cmdBuffer.Clear() at the start of each frame and rebuild only necessary commands.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce command count by merging draw calls with MaterialPropertyBlock or using GPU instancing. Replace per-object draw calls with a single DrawMeshInstanced.",
      "success_rate": 0.85,
      "how": "Reduce command count by merging draw calls with MaterialPropertyBlock or using GPU instancing. Replace per-object draw calls with a single DrawMeshInstanced.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set CommandBuffer's maximum capacity via reflection (not recommended for production) or offload some commands to a compute shader.",
      "success_rate": 0.6,
      "how": "Set CommandBuffer's maximum capacity via reflection (not recommended for production) or offload some commands to a compute shader.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Batch commands using CommandBuffer.Clear before pushing new ones. For example, in an Update loop, call cmdBuffer.Clear() at the start of each frame and rebuild only necessary commands.",
    "Reduce command count by merging draw calls with MaterialPropertyBlock or using GPU instancing. Replace per-object draw calls with a single DrawMeshInstanced.",
    "Set CommandBuffer's maximum capacity via reflection (not recommended for production) or offload some commands to a compute shader."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-09-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}