Skip to content

test(deck.gl-geotiff): check that a new renderSource reaches loaded MosaicLayer items - #844

Merged
kylebarron merged 1 commit into
mainfrom
kyle/mosaic-render-source-test
Nov 5, 2026
Merged

kylebarron merged 1 commit into
mainfrom
kyle/mosaic-render-source-test

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

This PR adds a test: when MosaicLayer gets a new renderSource, an item that has already loaded is drawn again with it, and its source isn't opened again.

That works because MosaicLayer builds a new tileset class on every render. The inner TileLayer compares TilesetClass by identity, so it redraws every loaded item, and each one calls the current renderSource. Nothing tested this, so moving the class out of renderTileLayer would have stopped it without any test failing (#816).

deck.gl's own TileLayer handles this case with updateTriggers.renderSubLayers instead. This PR keeps MosaicLayer's current behavior, as #734 did for RasterTileLayer.

Mutation check: reusing the first render's tileset class fails 13 tests, including this one. The other 12 fail because the new class is also how the inner TileLayer notices new items, and those tests all change data. This test keeps data the same, so it's the only one that checks renderSource on its own.

Ref #816

🤖 Written by Claude Code

@github-actions github-actions Bot added the test label Nov 5, 2026

@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 4025167 into main Nov 5, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/mosaic-render-source-test branch November 5, 2026 15:54
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]>
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.

1 participant