Repository navigation
feat(deck.gl-geotiff): open MosaicLayer's sources again when updateTriggers.getSource changes - #848
Conversation
…iggers.getSource changes A change to updateTriggers.getSource or updateTriggers.all now opens every source again, through a new inner TileLayer id, as RasterTileLayer refetches its tiles (#818). deck.gl removes the old TileLayer at once, and its tileset passes every source to onSourceUnload. Before, loaded items kept their old sources, so a mosaic could show a mix of both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| // The items the index was built from | ||
| items: ItemT[]; | ||
| // How many times the sources were opened again, in the inner TileLayer's id | ||
| refetchCount?: number; |
There was a problem hiding this comment.
Hmm, I don't love storing refetchCount; it feels hacky. But perhaps it's the best solution to seeing that updateTriggers has been triggered and we need to refetch sources 🤷♂️
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
It's a generation number for the inner TileLayer's id. deck.gl matches layers by id from one render to the next, so a new id is how it starts a layer from scratch. The old inner TileLayer is finalized, which unloads every source, and the new one gets a fresh tileset. The count has to live in state, because each render creates a new MosaicLayer instance and only state carries over. RasterTileLayer does the same for refetches (#818). deck.gl's own TileLayer also built a new tileset for each reload, until visgl/deck.gl#6194.
There is an alternative that stores nothing:
- Pass the triggers to the inner TileLayer as deck.gl does upstream:
getSourceas itsgetTileDatatrigger, plusall. - deck.gl then calls the tileset's
reloadAll. Override that inMosaicTileset2Dso it unloads and clears every item (this.finalize()) and re-selects the items in view (this.setOptions({})).
That's about five lines and no counter. But it reuses a tileset after finalize, which works in deck.gl 9.4 but isn't something deck.gl promises. It would also differ from RasterTileLayer, unless we switch that too.
I'd keep the count: it uses deck.gl's normal layer lifecycle, and it matches RasterTileLayer. If you prefer the reloadAll override, I'm happy to switch both layers to it.
🤖 Written by Claude Code
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Switched to the reloadAll override in 0ab8914, and refetchCount is gone. MosaicLayer hands getSource and all to its inner TileLayer as its getTileData and all triggers. MosaicTileset2D.reloadAll unloads every source and selects the items in view again.
A new tileset test pins the override: after reloadAll, an update with the same viewport selects the items again. The four trigger tests pass unchanged. dd4d8d1 updates the spec, and the PR description now describes the override.
RasterTileLayer moves to the same override in a follow-up PR, and the upstream fix for reloadAll is next.
🤖 Written by Claude Code
…eloadAll MosaicLayer no longer stores a count for the inner TileLayer's id. It hands updateTriggers.getSource to the inner TileLayer as its getTileData trigger, and all as all, so deck.gl's TileLayer calls the tileset's reloadAll as it does upstream. MosaicTileset2D overrides reloadAll to unload every source and select the items in view again, where deck.gl's drops items without unloading them and keeps drawing the old ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dAll Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed Tileset2D Co-Authored-By: Claude Opus 5.5 <[email protected]>
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. This updates the Sources design spec. Decision 26 said RasterTileLayer would move to the same `reloadAll` override that MosaicLayer uses since #848. It now says why RasterTileLayer keeps decision 24's refetch count instead: - **The id changes anyway.** RasterTileLayer's inner TileLayer id already changes with the tile grid, because deck.gl's TileLayer builds its grid only once. - **ZarrLayer starts its own refetches.** It refetches when `selection` changes by value, and there's no app trigger to hand to deck.gl's TileLayer. An override would still need a stored value that changes. - **There's nothing to fix.** Its inner TileLayer never calls deck.gl's leaky `reloadAll`. The PR changes only the spec. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Bumps `version` to `0.10.0-beta.4` in the root `package.json` and in every `packages/*/package.json`. The publish workflow publishes it under the `beta` dist-tag, so `latest` doesn't change. `CHANGELOG.md` gets a `v0.10.0-beta.4` section with GitHub's generated notes for the 6 PRs merged since v0.10.0-beta.3. ## Breaking changes - #837: `DEFAULT_RANGE_READER` moves from `@developmentseed/deck.gl-geotiff` to `@developmentseed/deck.gl-raster`. - #838: `ZarrSource.open` takes the store and a `path` option, instead of a group you opened and `variable`. ZarrLayer's `source` takes a store too. - `open` returns a general `ZarrSource`. Narrow its data type with `source.is("float32")`. - `source.arrays` is renamed to `source.levels`. - `ZarrSource`, `ZarrLayer` and `ZarrLayerProps` lose their `Store` type argument. ## Behavior changes - #838: an array passed in inherits its parent group's `proj:` and `spatial:` attributes, unless you pass `geoZarrMetadata`. - #851: `parseGeoZarrMetadata` orders a multiscales group's levels finest first by pixel size, whatever order its `layout` lists them in. - #848: a change to `MosaicLayer`'s `updateTriggers.getSource` (or `all`) unloads every item's source and opens the sources in view again. The old items stop drawing at once. ## New APIs - #792: `read({ window, pool, signal })` on `GeoTIFF` and `Overview`, with the `Window` type and the `WindowError` class. - #838: `ZarrSource.is(dtype)` and `source.node`. ## Not included The fix for #826 (the range reader sends a read again when it arrives as the stream holding its bytes finishes) isn't written yet. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
MosaicLayercaches the source thatgetSourceopens for each item. Until now, nothing opened those sources again. When somethinggetSourcereads 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.getSourceorupdateTriggers.allopens every source again:updateTriggers.getSourceto its innerTileLayerasupdateTriggers.getTileData, andallasall. When either changes, deck.gl'sTileLayercalls the tileset'sreloadAll, as it does upstream.MosaicTileset2DoverridesreloadAll. It unloads every source throughfinalize(fix(deck.gl-geotiff): call onSourceUnload for MosaicLayer's cached sources when it's removed #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 currentgetSource. Items out of view are opened when they come back.getSourcefunction alone opens nothing again, as with deck.gl's accessors.reloadAllis replaced (MosaicLayer can't open its sources again through updateTriggers #816):tileset.tiles.Tileset2D(Adapt to deck.gl v10's sharedTileset2D(visgl/deck.gl#10367) #846). ItsreloadAllunloads the tiles it drops, but still not the data a reload replaces.renderSourcegets no trigger. Every render of MosaicLayer already draws the loaded items again with the currentrenderSource, 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
MosaicLayerpasses the two triggers to its innerTileLayer, and stores nothing.MosaicTileset2DoverridesreloadAll.getSource's docs say when and how to open the sources again.renderSourcedecision. The 4c entry points to it.Tests
LayerManager:updateTriggers.getSource, and toupdateTriggers.all, opens every source again with the newgetSource, and passes the old sources toonSourceUnload.getSourcefunction.MosaicTileset2D:reloadAllunloads every item, and the next update selects the items in view again, even though the viewport hasn't changed.alldoesn't open the sources again.allnow opens them again, through the override instead of deck.gl'sreloadAll.setOptionscall in the override, 1 test fails.getTileDatatrigger, 2 tests fail.alltrigger, 1 test fails.deck.gl-geotifftests 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