Repository navigation
fix(deck.gl-raster): stop leaking a WebGL vertex array per tile - #786
Merged
Merged
Conversation
luma.gl's `Model.destroy()` (as of `@luma.gl/engine` 9.4.2) releases a model's pipeline, shaders, uniform store and geometry, but never destroys its vertex array. `SimpleMeshLayer` destroys its model when the layer is finalized and when it rebuilds the model (on a new mesh, or on a render pipeline change, which `MeshTextureLayer` signals as `extensionsChanged`), so every tile ever drawn leaked one WebGL vertex array object for the life of the context. `MeshTextureLayer` now destroys the vertex array of each model it releases: in `finalizeState`, and in `updateState` when `SimpleMeshLayer` replaced the model. It skips a vertex array that is already destroyed, so it stays correct once luma.gl destroys it itself and the workaround can be removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
@luma.gl/engine9.4.2'sModel.destroy()releases a model's pipeline, shaders, uniform store and geometry, but never destroys its vertex array.SimpleMeshLayerdestroys its model when the layer is finalized and when it rebuilds the model, so every tile'sMeshTextureLayerleaked one WebGL vertex array object for the life of the context.MeshTextureLayernow destroys the vertex array of each model it releases, until luma.gl does it itself.Changes
MeshTextureLayer.finalizeStatedestroys the vertex arrays of the layer's models afterSimpleMeshLayerdestroys the models.MeshTextureLayer.updateStatedestroys the old model's vertex array whenSimpleMeshLayerreplaces the model (on a newmesh, or on a render pipeline change, which the layer signals asextensionsChanged).Model.destroy()destroys it, and can then be removed.Tests
tests/mesh-layer/mesh-layer.test.tsrenders the layer through deck.gl'sLayerManager, with stand-in models and device since tests have no GPU.Model.destroy()already destroyed isn't destroyed again.main. The fourth (no double destroy) passes there by design and fails if the guard is removed.Notes
Model.setBufferLayout()also replacesvertexArraywithout destroying the old one. deck.gl calls it only when an attribute's layout changes, so it should be rare here, and the layer can't reach that old vertex array.Closes #765
🤖 Written by Claude Code