Skip to content

docs(deck.gl-raster): explain why TilesetFactory is a new class every render - #734

Merged
kylebarron merged 2 commits into
mainfrom
kyle/tileset-factory-comment
Oct 21, 2026
Merged

kylebarron merged 2 commits into
mainfrom
kyle/tileset-factory-comment

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

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

RasterTileLayer declares TilesetFactory inside _renderTileLayer, so the inner TileLayer gets a new TilesetClass on every render. deck.gl compares that prop by identity, so each render rebuilds the sublayers of every cached tile. That rebuild is what carries prop changes into tiles that are already loaded: maxError, debug and debugOpacity; the props that getSubLayerProps copies into each tile's RasterLayer, such as opacity and extensions; and subclass props read while rendering tiles, such as MultiCOGLayer's composite.

This adds a comment at the class saying so, so it isn't moved out of _renderTileLayer without declaring those dependencies. There are no code changes.

Ref #710

🤖 Written by Claude Code

… render

RasterTileLayer declares TilesetFactory inside `_renderTileLayer`, so the
inner TileLayer gets a new `TilesetClass` on every render. deck.gl
compares that prop by identity, so each render rebuilds every cached
tile's sublayers, and that is what carries prop changes into tiles that
are already loaded. Say so at the class, so it isn't hoisted out without
declaring those dependencies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment on lines +349 to +359
// `TilesetFactory` is a new class on every call, and that is load-bearing.
// deck.gl compares `TilesetClass` by identity, so on every render the inner
// `TileLayer` sees a changed prop and rebuilds each cached tile's sublayers
// (it builds the tileset itself once, from the first class). That rebuild
// carries prop changes into tiles that are already loaded: `maxError`,
// `debug` and `debugOpacity`; the props that `getSubLayerProps` copies into
// each tile's `RasterLayer`, such as `opacity` and `extensions`; and
// subclass props read while rendering tiles, such as MultiCOGLayer's
// `composite`. Creating the class once would leave loaded tiles stale
// unless all of those were declared in `updateTriggers.renderSubLayers`.
// See #710.

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.

Ok this is way too verbose. How about just

It's important for TilesetFactory to be a new class on every call because deck.gl compares TilesetClass by identity

@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.

lgtm

@kylebarron
kylebarron enabled auto-merge (squash) October 21, 2026 01:32
@kylebarron
kylebarron disabled auto-merge October 21, 2026 01:33
@kylebarron
kylebarron merged commit 3915e42 into main Oct 21, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/tileset-factory-comment branch October 21, 2026 01:33
kylebarron added a commit that referenced this pull request Nov 5, 2026
…osaicLayer items (#844)

> [!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](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