Repository navigation
fix(deck.gl-raster): unload a tile whose load finishes after it was unloaded - #878
Merged
Merged
Conversation
…nloaded deck.gl 9.4.1 evicts tiles that are still loading and calls onTileUnload before they have content. When such a load still returns data, deck.gl keeps it as the tile's content, but the tile has left the cache, so nothing unloads it and its textures leak. RasterTileset2D now remembers the tiles it has unloaded. When one of them finishes loading, it is unloaded again, now with its content, instead of being reported loaded. visgl/deck.gl#10883 does the same in deck.gl 9.4.2, where this guard is never reached. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 10, 2026
kylebarron
added a commit
that referenced
this pull request
Nov 16, 2026
Resolves the conflict in RasterTileset2D.setOptions with #878 by keeping both changes: the onTileLoad wrapper and the best-available replacement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 4 tasks
kylebarron
added a commit
that referenced
this pull request
Nov 24, 2026
…s redundant (#886) > [!NOTE] > This PR was written by Claude (Claude Code) on behalf of @kylebarron, not by @kylebarron. Closes #863 ### Problem deck.gl [9.4.2](https://github.com/visgl/deck.gl/releases/tag/v9.4.2) includes visgl/deck.gl#10883: - `Tileset2D.finalize` calls `onTileUnload` for every cached tile. - A tile whose load finishes after it left the cache is unloaded instead of reported loaded. Our workarounds for 9.4.1 do the same thing. On 9.4.2, they unloaded every tile twice. That destroyed default-pipeline textures twice and ran user `onTileUnload` / `onSourceUnload` callbacks twice (#863). With the lockfile moved to 9.4.2, five tests failed this way before this change. ### Change This is option 2 from #863: - Every `@deck.gl/*` spec, including peer deps, pnpm overrides and examples, now requires `^9.4.2`. The lockfile moves only deck.gl. - `RasterTileset2D`: removes the `finalize` override and the late-load guard from #878. The `abortUnwantedLoads` wrapper of `onTileUnload` stays. - `MosaicTileset2D`: removes the `finalize` override. `reloadAll` stays, because deck.gl's `reloadAll` still drops items without unloading them. It now calls deck.gl's `finalize`. - `custom-projection` example: removes its `finalize` override. - `MosaicLayer.onSourceUnload` docs: an item that is still opening is unloaded with no source, then again with its source once the open finishes. - `onnx-embeddings/NOTES.md`: no longer says the mid-load eviction leak applies. ### Test plan - [x] `deck.gl-raster` (263), `deck.gl-geotiff` (224) and `deck.gl-zarr` (81) tests pass on 9.4.2. - [x] One test encoded 9.4.1 behavior, with no unload at `finalize` for a loading tile. It now expects an unload right away with no content, then another once the data arrives. - [x] `biome ci` passes. - [ ] Not checked in a browser. Follow-up: switch the examples to `@deck.gl/maplibre` (#661), which visgl/deck.gl#10734 in 9.4.2 unblocks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011cLtCQHxJfGKqmXPYrjSPA Co-authored-by: Claude Opus 5.5 <[email protected]>
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) on behalf of @kylebarron, not by @kylebarron.
Closes #876
Problem
A tile that is unloaded while it is still loading can leak its textures:
onTileUnloadwhile theircontentis stillnull.RasterTileset2D's own wrapper does the same when it aborts an unwanted load.getTileDatadoesn't stop at the abort or was never aborted, deck.gl keeps the result as the tile's content.onTileUnloadnever runs for it again, and whatevergetTileDatacreated is never freed.#876 describes this for a
COGLayertile aborted mid-decode. It also happens with no abort at all:ZarrLayerdoesn't abort unwanted loads, andaef-mosaicsetsmaxCacheSize: 10with about 15 tiles in view, so short pans evict tiles mid-load.Fix
RasterTileset2Dremembers the tiles it has passed toonTileUnload, in aWeakSet. When one of them finishes loading, it callsonTileUnloadagain, now with content, instead ofonTileLoad. This is the "unload late results centrally" option from #876, so customgetTileDatapipelines are covered too.#728 knowingly left this case to the upstream fix. This brings a guard back for the interval before that fix is published. visgl/deck.gl#10883 makes the same change in deck.gl's own load handler, due in 9.4.2. There, deck.gl unloads the late tile and returns before it calls
onTileLoad, so this guard is never reached and nothing is unloaded twice. The guard can go when the overrides in #863 go.Measured
aef-mosaiconmainwith deck.gl 9.4.1, headless Chromium at 1280 x 800: 16 round trips of a 300 px pan, then a wait until no loads were left. An orphaned texture is a tile texture that no live tile holds and that was never destroyed.Texture MemoryTextures Activemain, run 1main, run 2With this PR, 15 tiles finished loading after they had been unloaded empty, and all 15 were freed.
Not covered
signalbeforedevice.createTexturein the defaultgetTileData, and passingsignalintopool.decode. They are not in this PR; Skip the decode and the texture upload for a tile that was aborted #879 tracks them.MosaicTileset2Dextends deck.gl'sTileset2Ddirectly, so it doesn't get this guard. I didn't check whether a mosaic item evicted mid-load leaks its source.Test plan
main, where the tiles are never unloaded, and passes here. It runs withabortUnwantedLoadsboth off and on.typecheckandbiome cipass.COGLayermid-decode case from A tile aborted while it decodes still gets a texture, which is never freed #876. The unit test withabortUnwantedLoadson follows the same path.🤖 Written by Claude Code