Skip to content

fix: Keep raster tiles loaded when the map re-renders - #1356

Merged
kylebarron merged 2 commits into
mainfrom
kyle/stable-tileset-descriptor
Nov 13, 2026
Merged

kylebarron merged 2 commits into
mainfrom
kyle/stable-tileset-descriptor

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

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

Fixes a regression from #1355. A RasterLayer with a tile matrix set (RasterLayer.from_geotiff, or the generic constructor) asked Python for every visible tile again whenever the map re-rendered. That includes changing any layer property, panning, and several times during the initial load.

deck.gl-raster 0.10 names its inner TileLayer after the tilesetDescriptor object (developmentseed/deck.gl-raster#799), so a new descriptor makes a new TileLayer with an empty cache. RasterModel.render() built a new TileMatrixSetAdaptor every time. Now it's memoized on the tile matrix set and the CRS converters, which only change when Python sets _tile_matrix_set or _crs.

The PMTiles path uses deck.gl's own TileLayer and wasn't affected.

Testing

Tile fetches counted from Python, with a UTM (EPSG:32618) COG loaded through from_geotiff:

Initial load After setting opacity After a 15 px pan
deck.gl-raster 0.8.1 (before #1355) 16 +0 +0
deck.gl-raster 0.10.0 (main) 22 +16 +32

With this PR, using a global WebMercatorQuad grid, the initial load has no duplicate requests, and a small pan only requests the row of tiles that comes into view (6 new, 0 repeats).

  • New UI test test_tile_matrix_set_tiles_not_refetched_on_rerender fails on main (36 requests instead of 24) and passes here.
  • uv run pytest: 368 passed, 1 skipped.
  • pnpm build, pnpm check and pnpm test pass. tsc --noEmit reports the same 9 errors as main.

🤖 Written by Claude Code

deck.gl-raster 0.10 names its inner TileLayer after the tileset
descriptor object, so the new TileMatrixSetAdaptor built on every
render made it drop its tiles and request them all from Python again.
Memoize the adaptor on the tile matrix set and CRS converters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the fix label Nov 13, 2026
The new raster UI test builds a TileMatrixSet with morecantile, which
was only in the geotiff extra that CI doesn't install.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/model/layer/raster.ts
} from "@developmentseed/deck.gl-raster";
import type { TileMatrixSet } from "@developmentseed/morecantile";
import type { WidgetModel } from "@jupyter-widgets/base";
import memoizeOne from "memoize-one";

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.

is this already a dependency? I don't know that we explicitly depend on it?

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.

Yes. package.json lists "memoize-one": "^6.0.0" under dependencies, and pnpm-lock.yaml already has it, so this PR doesn't change either file. It was added in #417, but as far as I can tell from the git history nothing ever imported it, so this is its first use.

If you'd rather not depend on it, a hand-written cache of the last (tileMatrixSet, converters) pair would take about 8 lines, and we could drop the dependency. I'd keep memoize-one, since it's small and says what it does.

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

oh weird, ok we can keep it

@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 d496a8d into main Nov 13, 2026
7 checks passed
@kylebarron
kylebarron deleted the kyle/stable-tileset-descriptor branch November 13, 2026 17:38
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