Repository navigation
fix(deck.gl-geotiff): call onSourceUnload for MosaicLayer's cached sources when it's removed - #823
Merged
Merged
Conversation
…urces when it's removed deck.gl's `Tileset2D.finalize` clears its cache without `onTileUnload`, so removing a MosaicLayer never called `onSourceUnload` for the sources it still held. MosaicTileset2D now unloads every cached item on finalize, as RasterTileset2D does (#728). An item still opening is unloaded once its open finishes, since deck.gl keeps what an aborted open returns anyway. Part of #816. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
commented
Oct 30, 2026
Comment on lines
+88
to
+89
| * Unloads every cached item, which deck.gl's `finalize` skips (see #728). An | ||
| * item still opening is unloaded once its open finishes. |
Member
Author
There was a problem hiding this comment.
We should point to visgl/deck.gl#10883 upstream
Member
Author
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Done in 53581a1. This docstring now points to visgl/deck.gl#10883. I added the same pointer to RasterTileset2D.finalize, which works around the same deck.gl gap, so both overrides say they can go once #10883 lands.
🤖 Written by Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Oct 30, 2026
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Bumps `version` to `0.10.0-beta.2` in the root `package.json` and in every `packages/*/package.json`. The publish workflow publishes it under the `beta` dist-tag, so `latest` stays on 0.9.0. `CHANGELOG.md` gets a `v0.10.0-beta.2` section with the one PR merged since v0.10.0-beta.1, #823. ## Before pushing the tag `@developmentseed/range-reader` needs a trusted publisher on npm, with the same settings as the other packages: workflow `release.yml`, environment `release`. The v0.10.0-beta.1 publish run failed at `range-reader` without one, after it had published `affine`, `epsg` and `proj`. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Nov 5, 2026
…iggers.getSource changes (#848) > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. `MosaicLayer` caches the source that `getSource` opens for each item. Until now, nothing opened those sources again. When something `getSource` reads changed, loaded items kept their old sources and only items loaded afterward used the new ones, so the mosaic could show a mix of both. Now a change to `updateTriggers.getSource` or `updateTriggers.all` opens every source again: ```ts new MosaicLayer({ data: items, getSource: (item, options) => COGSource.open(item.assets[band].href, options), updateTriggers: { getSource: band }, renderSource: (item, { source, subLayerProps }) => new COGLayer({ ...subLayerProps, source }), }); ``` - **How it works:** - MosaicLayer hands `updateTriggers.getSource` to its inner `TileLayer` as `updateTriggers.getTileData`, and `all` as `all`. When either changes, deck.gl's `TileLayer` calls the tileset's `reloadAll`, as it does upstream. - `MosaicTileset2D` overrides `reloadAll`. It unloads every source through `finalize` (#823), which also aborts the opens in flight. Then it makes the next update select the items in view again, and they open with the current `getSource`. Items out of view are opened when they come back. - **The old items stop drawing at once,** as #818's tiles do. - **A new `getSource` function alone opens nothing again,** as with deck.gl's accessors. - **deck.gl's own `reloadAll` is replaced** (#816): - It drops items out of view without unloading them, and keeps them in `tileset.tiles`. - It keeps drawing the items in view with their old sources until the new ones open, and never unloads the old ones. - The override stays until we adopt deck.gl v10's shared `Tileset2D` (#846). Its `reloadAll` unloads the tiles it drops, but still not the data a reload replaces. `renderSource` gets no trigger. Every render of MosaicLayer already draws the loaded items again with the current `renderSource`, and #844 tests that. RasterTileLayer still refetches through a count in its inner `TileLayer`'s id (#818). A follow-up moves it to the same override. ## Changes - **`MosaicLayer`** passes the two triggers to its inner `TileLayer`, and stores nothing. - **`MosaicTileset2D`** overrides `reloadAll`. - **Docs:** `getSource`'s docs say when and how to open the sources again. - **Spec:** decision 26 records this and the `renderSource` decision. The 4c entry points to it. ## Tests - **Runtime**, through deck.gl's `LayerManager`: - A change to `updateTriggers.getSource`, and to `updateTriggers.all`, opens every source again with the new `getSource`, and passes the old sources to `onSourceUnload`. - An unchanged trigger opens nothing again, even with a new `getSource` function. - The old items stop drawing at once, before the new sources open. - **`MosaicTileset2D`:** `reloadAll` unloads every item, and the next update selects the items in view again, even though the viewport hasn't changed. - **Replaced test:** #789 had a test that `all` doesn't open the sources again. `all` now opens them again, through the override instead of deck.gl's `reloadAll`. - **Mutation checks:** - Without the `setOptions` call in the override, 1 test fails. - Without the `getTileData` trigger, 2 tests fail. - Without the `all` trigger, 1 test fails. - Without the override, 4 tests fail. - **Everything else:** all 222 `deck.gl-geotiff` tests pass, as do the workspace typecheck and Biome. In Chrome, naip-mosaic still loads and pans with no errors. Closes #816 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- 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), not by @kylebarron.
When a MosaicLayer is removed,
onSourceUnloadnow fires for every source the layer still holds.deck.gl's
Tileset2D.finalizeclears its cache without callingonTileUnload, so MosaicLayer never reported those sources.MosaicTileset2Dnow unloads every cached item on finalize, asRasterTileset2Ddoes for tiles (#728). An item still opening is unloaded once its open finishes, since deck.gl keeps what an aborted open returns anyway.This is the first step toward #816. Re-opening sources through
updateTriggerswill replace MosaicLayer's inner TileLayer, which drops its cache the same way.The override repeats
RasterTileset2D.finalize. visgl/deck.gl#10883 would make deck.gl do this itself, and then both could go.Ref #816
Tests
These run in deck.gl's
LayerManager, and both failed before the fix:onSourceUnload;🤖 Written by Claude Code