Skip to content

feat(deck.gl-geotiff): open MosaicLayer's sources again when updateTriggers.getSource changes - #848

Merged
kylebarron merged 5 commits into
mainfrom
kyle/mosaic-reopen-sources
Nov 5, 2026
Merged

kylebarron merged 5 commits into
mainfrom
kyle/mosaic-reopen-sources

Conversation

@kylebarron

@kylebarron kylebarron commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

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:

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 }),
});

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: feat(deck.gl-geotiff): give renderSource the props MosaicLayer passes to sublayers #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

kylebarron and others added 2 commits November 5, 2026 13:00
…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]>
@github-actions github-actions Bot added the feat label Nov 5, 2026
// 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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤷‍♂️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: getSource as its getTileData trigger, plus all.
  • deck.gl then calls the tileset's reloadAll. Override that in MosaicTileset2D so 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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

kylebarron and others added 2 commits November 5, 2026 13:20
…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]>

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅

@kylebarron
kylebarron merged commit f7c20aa into main Nov 5, 2026
4 checks passed
@kylebarron
kylebarron deleted the kyle/mosaic-reopen-sources branch November 5, 2026 18:38
kylebarron added a commit that referenced this pull request Nov 5, 2026
> [!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]>
kylebarron added a commit that referenced this pull request Nov 6, 2026
> [!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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MosaicLayer can't open its sources again through updateTriggers

1 participant