Skip to content

fix: Prevent WebGPU setIndexBuffer crash via geometry disposal quaran…#1120

Merged
braedonsaunders merged 1 commit into
mainfrom
claude/fix-gpu-buffer-error-CTkjb
Jan 30, 2026
Merged

fix: Prevent WebGPU setIndexBuffer crash via geometry disposal quaran…#1120
braedonsaunders merged 1 commit into
mainfrom
claude/fix-gpu-buffer-error-CTkjb

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

…tine

The "setIndexBuffer" error occurred because geometries were disposed synchronously while WebGPU still had pending draw commands using those GPU buffers. WebGPU typically has 2-3 frames in flight.

Added geometry disposal quarantine system that delays geometry and material disposal for 4 frames, ensuring the GPU has finished all pending draw commands before buffers are freed.

Changes:

  • Add geometryQuarantine array and GEOMETRY_QUARANTINE_FRAMES constant
  • Add queueGeometryForDisposal() to queue resources for delayed cleanup
  • Add processGeometryQuarantine() called at start of each frame
  • Update inactive mesh cleanup to use quarantine instead of immediate disposal
  • Update refreshAllMeshes() to use quarantine
  • Update dispose() to flush quarantine during full teardown
  • Apply same pattern to GPUIndirectRenderer

https://claude.ai/code/session_01LA6RwJfSB6nsab6v8oAGf9

…tine

The "setIndexBuffer" error occurred because geometries were disposed
synchronously while WebGPU still had pending draw commands using those
GPU buffers. WebGPU typically has 2-3 frames in flight.

Added geometry disposal quarantine system that delays geometry and
material disposal for 4 frames, ensuring the GPU has finished all
pending draw commands before buffers are freed.

Changes:
- Add geometryQuarantine array and GEOMETRY_QUARANTINE_FRAMES constant
- Add queueGeometryForDisposal() to queue resources for delayed cleanup
- Add processGeometryQuarantine() called at start of each frame
- Update inactive mesh cleanup to use quarantine instead of immediate disposal
- Update refreshAllMeshes() to use quarantine
- Update dispose() to flush quarantine during full teardown
- Apply same pattern to GPUIndirectRenderer

https://claude.ai/code/session_01LA6RwJfSB6nsab6v8oAGf9
@braedonsaunders braedonsaunders merged commit 1d29341 into main Jan 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants