fix: resolve WebGPU setIndexBuffer crash during gameplay#1063
Merged
Conversation
Multiple issues were causing the Three.js render to go dark after ~7 minutes of gameplay due to WebGPU failing to set index buffers. Issue 1: Wrong disposal order (EnvironmentManager, WaterMesh) - Geometry was being disposed BEFORE meshes were removed from scene - WebGPU would try to render meshes with disposed geometry buffers - Fixed by removing from scene FIRST, then disposing resources Issue 2: Projectile trail index buffers using plain arrays - BattleEffectsRenderer used plain number[] arrays for trail indices - WebGPU requires properly typed index buffers (Uint16Array) - Over time (7+ minutes of continuous projectiles), buffer lifecycle issues accumulated causing setIndexBuffer to receive invalid buffers - Fixed by using Uint16Array with THREE.BufferAttribute for indices Files changed: - EnvironmentManager.ts: Reorder dispose() to remove from scene first - WaterMesh.ts: Reorder clear() to remove meshes before disposing - BattleEffectsRenderer.ts: Use Uint16Array for trail index buffers https://claude.ai/code/session_01E36JDY27fQMf5EzB3KMZD4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multiple issues were causing the Three.js render to go dark after ~7 minutes of gameplay due to WebGPU failing to set index buffers.
Issue 1: Wrong disposal order (EnvironmentManager, WaterMesh)
Issue 2: Projectile trail index buffers using plain arrays
Files changed:
https://claude.ai/code/session_01E36JDY27fQMf5EzB3KMZD4