Repository navigation
feat(deck.gl-geotiff): coalesce COG tile reads by default - #809
Conversation
54436b8 to
6a8af6e
Compare
55a3ac3 to
9cc8cf1
Compare
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Adds `@developmentseed/range-reader`, a new workspace package that turns the byte-range reads a client issues in one task into few streamed HTTP range requests, resolves each read the moment its bytes arrive, cancels a request as soon as no read wants what is left of it, and keeps every received span in a byte cache. It is stage 1 of three: nothing reads through it yet. Stage 2 (next PR in this stack) puts `GeoTIFF.fromUrl` on it; stage 3 makes the deck.gl COG layers share one reader by default. Design: `dev-docs/specs/2026-10-26-range-reader-design.md` (committed here). Background: #273, #747, #762, #690, #524; the usgs-topo prototype (kylebarron/usgs-topo#23) that measured 226 requests / 4.19 s down to 30 / 0.79 s for a zoom-12 view of 128 px tiles, which this package generalises and improves on by streaming. ## What is in the package - `RangeReader.read(file, range, { purpose, signal, limiter, getPriority })`: queues absolute reads until the end of the task, groups them by file identity (URL plus a canonical request-init signature, so different credentials never share bytes) and purpose (`metadata` or `data`; `data` when omitted), widens small metadata reads to aligned 64 KiB blocks that are read to their end, merges them with the usgs-topo rule plus two caps (`maxOverfetchBytes`, 1 MiB; `maxRequestBytes`, 16 MiB; `maxGap: "median"`), and runs one `RangeStream` per merged range. Before queueing, a read is served from the cache, or attached to a request already in flight, of either purpose, or resolved empty past a known object size. Suffix and whole-object reads go out at once, unmerged. `reader.stats` counts requests, bytes, over-fetch, cache hits, attaches and validator changes for the measurement gate. - `RangeStream`: one range request, body read as a stream into a preallocated buffer; each member read resolves with a view the moment its last byte lands; a member whose signal aborts rejects at once and the stream runs on for the others, and is cancelled, keeping what arrived, when the last live member leaves (by abort, or by a resolve once others have left). Handles 206, 200 to a ranged request (consumed as the whole object when its `Content-Length` is small enough, else rejected), 404 (a typed not-found outcome, since a missing Zarr chunk is data), other statuses, a body that ends before the range (end of object, told apart from a truncated transfer by `Content-Length`), a body that runs past the range, and body errors from a real `fetch` on abort or a dropped connection. One limiter slot per request, with the best priority among live members. - `MemoryByteCache` (the default `ByteCache`): contiguous spans per file, served by containment as views, one LRU budget per purpose (32 MiB metadata, 64 MiB data) so tile churn never evicts the offset tables every later read depends on; a read of either purpose is served from any span that contains it. `ByteCache` is an interface (`get`, `put`, optional `byteSize` and `delete`) so a disk-backed cache (OPFS) can be supplied later. - The per-origin limiter (`Semaphore`, `PerOriginSemaphore`, `ConcurrencyLimiter`, `Priority`) moves here from `@developmentseed/geotiff`, which re-exports the same names and keeps its chunkd `LimiterMiddleware`. No other change to geotiff's API. 88 tests drive fake responses chunk by chunk (the fake errors the body on abort, like a real `fetch`). A fresh whole-branch review found two confirmed bugs (body errors rejected `run()` and hung reads; cancelled prefixes pinned their whole preallocated buffer) and two rule gaps, all fixed with tests in `a28d18d1`. Registered on the docs site (`range-reader`); the API pages are generated at build time like every other package's. ## After Kyle's review (2026-10-27) - Two bugs found while checking the review, both only visible with a body that arrives in more than one chunk: a widened metadata block was cancelled right after its small read resolved, so only the first chunk was cached and the block was requested again (live during the #809 measurements); and a data read inside a metadata block still streaming went out as its own request instead of attaching. Fixed in 79eebe2 with two-chunk tests; a keep member that offers no priority no longer sets the request's (5fc6c7b). - The structural purpose is `metadata`, not `header`: the same class of bytes is a sharded Zarr shard's index and a PMTiles directory. Options follow (`minMetadataReadBytes`, `cache.metadataBytes`); `purpose` is optional and defaults to `data` (355b531). - `ReadRange` no longer includes `undefined`; `FileIdentity.key` is a branded `FileKey` only `fileIdentity()` makes; the key's parts are separated by a space, which a serialized URL never contains; the `fileIdentity` docstring says why the identity exists: one merged request carries one set of headers (d48caa6). - Validators: chunkd's `SourceHttp` failed reads whose ETag changed and the stack had dropped that guard. The reader keeps each file's `ETag` (or `Last-Modified`) from its latest response, purges the file's cached spans and forgets its size when it changes, and reports the validator on every result, cache hits included; `ByteCache.delete` is the purge hook. The reader never sends `If-Match` (CORS preflight); icechunk's own `If-Match` passes through the init (5691502). The geotiff adapter in #807 does the per-instance check. - README: why merging pays (six HTTP/1.1 connections per host, per-request latency and billing, interleaving over HTTP/2), sharded Zarr as a client, the metadata definition (67aa356). 🤖 Written by [Claude Code](https://claude.com/claude-code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
af2f612 to
e6fffbe
Compare
e6fffbe to
c953f24
Compare
…es, 1 MiB default (#815) > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Three changes from the timing benchmark of the stack (#807, #809), each measured; the before-and-after tables are in #809's description. - **Adjacent reads respect the request cap.** `mergeReads` treated a read that starts exactly where the current range ends like an overlapping one and joined it unconditionally. The tiles of a COG row are contiguous, so they merged without any bound and `maxRequestBytes` never applied: in `cog-basic`, ten 2.4 MB tiles became one 24 MB request and a viewport of big tiles ran on two or three streams, which cannot fill a fast link that ten parallel requests fill (0.6x of unmerged on an emulated 200 Mbit/s, 80 ms link). Only a read that starts before the range's end, a true overlap, joins past the cap now. - **Merged ranges launch round-robin across files.** A limiter serves streams in launch order and COG tile reads carry no priority, so launching every range of one file before the next file's meant a MultiCOG tile, which needs one range of each band file, could not complete until the last file's streams started: sentinel-2's first tile arrived 2.5 s after a jump at every cap, against 0.5 s unmerged; it is 0.85 s with this change, and the view completes 1.2x to 1.4x faster than unmerged. - **Default `maxRequestBytes` is 1 MiB** (the third commit set 4 MiB; the fourth corrects it after the final pass), from a sweep of 1 to 16 MiB under three link conditions: merging pays when tiles are small against the link's latency, and about 1 MiB is where it stops paying. A 128 px topo sheet's 99 reads still merge to 9 requests and load 2x to 4x faster; 460 KB NAIP tiles merge in pairs at parity or better, where 2 to 4 MiB cost 20% to 30% on a home link; 2.4 MB tiles go alone, at parity. A larger cap buys up to 20% on a high-latency link for mid-size tiles at the cost of the first tile; an adaptive cap derived from the selection's size, so a view always yields enough streams to fill the link, is the follow-up. Independent of #807 and #809 textually; merging it first and rebasing the stack is the simplest order. 🤖 Written by [Claude Code](https://claude.com/claude-code) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
c320d66 to
806274c
Compare
806274c to
cb94fe9
Compare
…layers `DEFAULT_RANGE_READER`, a module-level `RangeReader` next to the default limiter, so every COG layer on a page shares one byte cache and one batching window. `COGSource.open`, `MultiCOGSource.open` and `MosaicLayer` take `reader` and `requestInit` (headers, credentials, mode for data behind authentication) and forward them to `GeoTIFF.fromUrl`; the mosaic passes them to `getSource` like the limiter. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…e task `COGLayer` and `MultiCOGLayer` default to `maxRequests: 256` and `debounceTime: 50`: deck.gl's six-at-a-time throttle would starve the range reader, which merges a selection's reads into few streamed requests and is capped by the per-origin limiter instead; the debounce lets a pan settle before anything is requested. `RasterTileLayer` and `MosaicLayer` keep deck.gl's defaults (#562). Co-Authored-By: Claude Fable 5.1 <[email protected]>
`RasterTileset2D` gains `abortUnwantedLoads`: after every update, a loading tile that is neither selected nor visible is aborted. deck.gl does that only while more than `maxRequests` loads are in flight, which the COG layers' high `maxRequests` disables; without it a merged, streamed request would run on for tiles that left the view. `RasterTileLayer` exposes it as a protected hook, off by default; `COGLayer` and `MultiCOGLayer` turn it on. `ZarrLayer` keeps deck.gl's behaviour until its own reader adapter lands: zarrita's coalescer fails every read of a merged request when one aborts. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Requests, caching and authentication for the COG layers: the shared reader, tuning it or isolating a layer, `requestInit` for data behind authentication, and the new throttling defaults. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…x docs Findings of the whole-branch review: - deck.gl evicts unselected loading tiles inside `update` (its cache resize) before the tileset's own abort pass can see them, so a tile that left the view and fell out of the cache in one update kept its stream alive and later made a texture nobody would free. `RasterTileset2D` now wraps `onTileUnload` in `setOptions` (which `TileLayer` calls on every props change) to abort a loading tile first. Test added for both the option on and off. - The deck.gl-geotiff README showed `reader` and `requestInit` as `COGLayer` props, which do not exist: a TypeScript user got a compile error and a JavaScript user's auth header was silently dropped. The examples now open the source with `COGSource.open` and pass it to the layer; `MosaicLayer` takes both as props. - `finalize`'s docstring had been displaced above `update`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Docstrings state what each option or hook is and the rule a caller needs; the reasoning behind the defaults and the abort rule is in the PR. Co-Authored-By: Claude Fable 5.1 <[email protected]>
cb94fe9 to
98bf4eb
Compare
| // reads; the per-origin limiter caps requests. Cast as in MultiCOGLayer. | ||
| static override defaultProps = { | ||
| ...RasterTileLayer.defaultProps, | ||
| maxRequests: 256, |
There was a problem hiding this comment.
Why do we put maxRequests so high again? Because we're coalescing instead of using deck.gl's request limiter?
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Yes. deck.gl's scheduler issues at most maxRequests getTileData calls at a time, six by default, so the reader would only ever see six reads per task and could merge only within those. With 256, a whole viewport's reads reach the reader in one task and merge across the selection; actual HTTP concurrency is capped by the per-origin limiter, six per origin, at the merged-request level, which is where the browser's own limit applies anyway. 256 rather than unbounded because deck.gl still uses the number: _pruneRequests aborts unselected loading tiles only while more than maxRequests are in flight, and a cap bounds what a pathological selection can queue. A viewport is rarely more than a hundred tiles, so 256 leaves room for two zoom levels in flight.
🤖 Written by Claude Code
| static override defaultProps = { | ||
| ...RasterTileLayer.defaultProps, | ||
| maxRequests: 256, | ||
| debounceTime: 50, |
There was a problem hiding this comment.
This is the debounce time for how to coalesce tiles? Should it be smaller than 50ms?
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
No, the coalescing window is the reader's own and is one task (setTimeout 0), independent of this. debounceTime is deck.gl's request scheduler: after a tile is scheduled it waits this long before issuing the batch, so during a continuous pan or zoom the tiles that are only briefly in view are never requested, and the ones that are go out together in priority order. 50 ms came from the usgs-topo prototype and was never swept; it is the measured 50 to 80 ms the first tile lost in every small-tile row of the benchmark. It could well be smaller: with abortUnwantedLoads catching tiles that leave the view, the debounce mostly saves the round trip of streams that would be cancelled anyway. I'd sweep 0, 20 and 50 on the harness before changing it, a few minutes per value; my expectation is that 20 shaves about 30 ms off the first tile and costs a few requests on fast pans.
🤖 Written by Claude Code
| * The {@link RangeReader} every COG source and layer on the page reads | ||
| * through when given none: one byte cache and one batching window for all. | ||
| */ | ||
| export const DEFAULT_RANGE_READER = new RangeReader(); |
There was a problem hiding this comment.
Hmm, will this move outside of the geotiff package in the future? We'll want a single reader to manage COG, Zarr, etc, right?
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Yes, it should move: every adapter should default to the same reader so COG and Zarr chunks share one cache and one batching window. The two candidates are deck.gl-raster, the base package both layer packages import, or range-reader itself as a lazily created defaultRangeReader. I'd put it in deck.gl-raster next to the limiter default when the Zarr adapter lands, since the shared reader is a page-level concern and that keeps range-reader free of module state, and re-export it from deck.gl-geotiff so nothing breaks. GeoTIFF.fromUrl's private fallback reader stays as decided, for callers outside deck.gl. It is left here in this PR only because deck.gl-raster has no consumer for it yet.
🤖 Written by Claude Code
| /** | ||
| * Abort a tile's load as soon as the tile is neither selected nor visible, | ||
| * not only while more than `maxRequests` loads are in flight as deck.gl | ||
| * does. Needed by layers that hand a whole selection to a range reader at | ||
| * once; deck.gl requests an aborted tile again when it is selected again. |
There was a problem hiding this comment.
can you explain this a little more in detail?
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
deck.gl's Tileset2D._pruneRequests aborts a loading tile that is no longer selected or visible only while more than maxRequests loads are in flight: it exists to free slots, not to stop waste. At six it triggers on every pan; at 256 it never does. So without this option a stream for a tile that left the view would run to its end, and with merged requests it would keep a whole merged run alive for tiles nobody wants.
abortUnwantedLoads makes RasterTileset2D abort every such tile unconditionally: once after each update, and, for the tiles deck.gl evicts inside its own update before our pass runs, through the onTileUnload wrap in setOptions. The abort reaches the reader as the read's signal; the reader rejects that read and cancels the stream the moment no live read wants what is left, keeping what arrived in the cache. deck.gl resets an aborted tile to unloaded and requests it again when it is selected again, by then usually a cache hit.
Off by default; the two COG layers turn it on. ZarrLayer keeps deck.gl's behaviour until its adapter lands, because zarrita's own coalescer fails every read of a merged request when one of them aborts (#690).
🤖 Written by Claude Code
|
lgtm ✅ |
#809 squash-merged as ed7a7f1, with the same tree as its head 98bf4eb, which this branch was built on. Merging main lets the PR's diff show only the example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Adds `examples/experimental/pmtiles-terrain`. It computes relief shading on the GPU from [Mapterhorn](https://mapterhorn.com/)'s global terrain, read straight from one PMTiles archive by `RasterTileLayer`. The archive is `planet.pmtiles`: 356 GB covering zooms 0-12, as Terrarium-encoded 512 px lossless WebP. It shows three things: 1. **deck.gl-raster reads PMTiles too.** Any tiled source works, not only COG and Zarr. 2. **Hillshade is computed live on the GPU.** The sun is a slider, and moving it fetches nothing. 3. **Reads are merged.** A clustered PMTiles archive keeps a view's tiles together in the file, so the range reader merges them into a few streamed requests. A "Merge requests" switch compares that with one request per tile. This becomes the hillshade example. It ports and reviews #647's Horn kernel, halo and modes; #647 stays parked. Ref #647. The design is in [`dev-docs/specs/2026-10-27-pmtiles-terrain-design.md`](https://github.com/developmentseed/deck.gl-raster/blob/64702126264eec1cf1ff30a4ec182f2f02436531/dev-docs/specs/2026-10-27-pmtiles-terrain-design.md) and the [example's README](https://github.com/developmentseed/deck.gl-raster/blob/64702126264eec1cf1ff30a4ec182f2f02436531/examples/experimental/pmtiles-terrain/README.md). ## Built on the range reader It reads PMTiles through `@developmentseed/range-reader` (#806) and uses #809's protected `_abortUnwantedLoads` hook, both on main. Outside the example, the PR changes only the spec, one docs entry, the card image and lockfile additions. ## How it works - **No loaders.gl.** The example uses the `pmtiles` library directly. `@loaders.gl/pmtiles` takes only a URL or a `Blob`, so its reads can't merge; it calls `getZxy` without a signal; and it pins `pmtiles` 3.x. - **`RangeReaderSource`** implements `pmtiles`' `Source` on the range reader. - Tile-data reads use the `data` purpose; the header and directories use `metadata`. - Bytes are copied out, because the reader's are views into shared buffers. - A replaced archive is caught with `pmtiles`' own `etag` check. - **`PMTilesSource extends RasterSource`** describes a 512 px WebMercatorQuad grid bounded to the archive. - The layer takes its `tilesetDescriptor`; question 10 of the Sources spec stays as it is. - If `RasterTileLayer` learns to take a `source`, this plugs in there. - **Halo.** Each tile is a 514 x 514 `r32float` texture whose outer ring comes from its eight neighbors. - Nothing is fetched for a halo. A tile loads only itself and draws at once, its ring filled from the neighbors that have loaded. - A side whose neighbor hasn't loaded repeats the tile's own edge. That neighbor isn't in view, so neither is the side. - When a neighbor loads later, the tile rewrites only its ring, four strips one texel wide. - `TileBorders` keeps each loaded tile's border (8 KiB, not 1 MiB), so a tile still finds a neighbor's border after deck.gl has unloaded the neighbor. - **Ground cell size is computed per fragment** from Mercator latitude. One value per tile would make the shading jump 7% between z6 tile rows near 46°N. - **Exact decoding.** There's no premultiplied alpha or color conversion. Pixels are read back the way MapLibre reads DEM tiles: through a canvas, or through `VideoFrame` when canvas reads are altered. Where neither gives exact bytes, tiles fail with a message in the panel instead of drawing wrong elevations. - **`PMTilesTerrainLayer`** exists only to turn on #809's protected `_abortUnwantedLoads` hook, because the example raises `maxRequests`. It can go once a public prop exists. ## Measured The opening view at the Matterhorn: 12 tiles. - Each mode was measured cold, two or three times, from a toggle of the switch after the basemap had loaded, in headed Chrome 156. - Times come from polling the readout, so they're +/- 0.25 s. | Connection | Mode | HTTP requests | Data | All tiles drawn | | --- | --- | --- | --- | --- | | fast | per tile | 14 | 1.9 MB | 1.9 s | | fast | merged | **7** | 2.0 MB | 1.2-1.9 s | | 150 ms round trips, 20 Mbit/s | per tile | 14 | 1.9 MB | 2.1-2.3 s | | 150 ms round trips, 20 Mbit/s | merged | **7** | 2.0 MB | **1.8-1.9 s** | The merged opening view is seven requests: - one 64 KiB header block; - one 64 KiB block holding the leaf directory; - five tile-data requests: 951 KB and 303 KB (one run of eight adjacent tiles, split by the reader's 1 MiB request cap), 305 KB (two tiles), 166 KB and 160 KB. Mapterhorn serves over HTTP/2, so merging saves more requests than time. Decoding takes about 1.25 ms per tile on the main thread. **Halos without fetches.** At first, each tile also fetched its eight neighbors for its halo. Kyle found the example slow, and filling halos only from neighbors that load anyway made it faster: | Measured | Fetching neighbors | Loaded neighbors only | | --- | --- | --- | | Opening view, merged | 4.8 MB | **2.0 MB** | | Opening view, merged, 150 ms round trips | all drawn at 2.9 s | **all drawn at 1.8-1.9 s** | | One-screen pan, fast | 13 tiles fetched for 6 shown, 1.57 MB | **6 tiles, 0.91 MB**, all drawn at 0.6 s | | One-screen pan, 150 ms round trips | last tile at 1.27 s | **last tile at 0.93 s** | ## Verified - **Tests:** the example's 82 tests, typecheck, Biome and `vite build`. Before the halo change, `deck.gl-raster` (251) and `range-reader` (99) also passed on #809's head. - **Headed Chrome:** - All four modes render. - Moving the sun or changing the mode fetches nothing. - There are no seams at tile edges or between tile rows at z5 (the Himalaya). - After the halo change, full-resolution crops across tile edges and a corner show no seams. Every opening view rewrote 29 rings: one per pair of adjacent tiles, counting diagonals, among its 4 x 3 tiles. - Tilted to 60° at z12.5 and 65° at z9.6, no seams were visible. - Across the antimeridian (Taveuni, Fiji, at z12), the rings read back from the GPU equal the neighbors' edge columns exactly. Hillshade still shows a faint line at 180°, and it comes from the data: there, the step between Mapterhorn's two edge columns is 20-60% of the steps beside it, while at other tile edges it matches them. - With canvas noise simulated, decoding switches to the `VideoFrame` path. - **Headed Firefox 155 with `privacy.resistFingerprinting`:** canvas reads come back random and `VideoFrame` is undefined. Tiles fail with the panel message; before the fix they drew random stripes. ## Review A fresh reviewer found four Important issues, and I raised two minors to Important. All are fixed, each verified by a failing test or browser check first. - **A drawn tile's halo reads were never cancelled.** Fixed then with a signal per halo, released when the tile unloaded. The halo change has since removed those reads. - **A replaced archive could leave `pmtiles` unable to read it** until reload. Fixed by using `pmtiles`' own `etag` check. - **Each cached tile kept its 1 MiB halo array alive.** luma.gl keeps `createTexture`'s `data` prop, so the array is now uploaded with `writeData`. The COG layers do the same: [`render-pipeline.ts`](https://github.com/developmentseed/deck.gl-raster/blob/98bf4ebad9988b6ddd001e32517517afefd09afd/packages/deck.gl-geotiff/src/geotiff/render-pipeline.ts#L207-L208) and [`multi-cog-layer.ts`](https://github.com/developmentseed/deck.gl-raster/blob/98bf4ebad9988b6ddd001e32517517afefd09afd/packages/deck.gl-geotiff/src/multi-cog-layer.ts#L908-L909). - **The stats poll rebuilt every tile's sublayers about four times a second** while tiles loaded. The readout now polls on its own; tileset `setOptions` calls during a pan load went from 4 to 0. - **Firefox with fingerprinting resistance drew random stripes as terrain.** Tiles now fail, and the panel says why. Also found in the browser: #647's shader takes `atan(0, 0)` on flat ground, and the resulting NaN drew lakes black. It's fixed here, but #647 still has it. ## Open questions - Should there be a WebAssembly WebP decoder as a fallback, so Firefox with fingerprinting resistance (and probably Safari private browsing) can draw tiles? It would be a new dependency. - Should there be an issue for the COG layers keeping `createTexture`'s `data`? - `pmtiles` caches failed directory fetches, so a network blip blanks a region until reload. That's upstream behavior and isn't filed. <details> <summary>Calls made without asking</summary> - Built on #809's newest head rather than the head named in the plan. Cost if wrong: one `rebase --onto`. - Tests use hand-derived literal values. - Borders are kept after their tiles unload, up to 2048 (16 MiB). Cost if wrong: memory, or seams where a forgotten neighbor's border is missing. - Added tests beyond the plan: the counting `FetchSource`, `getUniforms` (proven by a mutation), a released tile's refine, and `getZxy` returning nothing. - Two comment fixes in #647's small modules: ASCII, and Terrarium units. - Gave `TerrainDerivative` explicit uniform and binding types. - `loadTerrariumElevation` lives in `get-tile-data.ts`. - The experimental badge sits inline in the panel title, because `ControlPanel` has no `experimental` prop on this base. - A refined halo repaints through `map.triggerRepaint`. Cost if wrong: a refined ring could show a frame late. - Retuned the colormap ranges so valleys don't look like water: [500, 4500], [2000, 8850], [0, 2800] and [400, 3000]. - The layer allows `null` tiles, and `renderTile` draws nothing for them. - Fixed `atan(0, 0)` on flat ground. - Verified in my own headed Chrome over CDP, because the chrome-devtools profile was busy. - Each opened archive gets its own range reader, so both sides of the switch start cold. - Timed every pass from a toggle after the basemap loaded. An earlier run timed from page load was confounded by the basemap still loading, so it's excluded. - Captured a fresh 1800 x 1013 docs card. - Raised the stats-poll and canvas-fallback minors to Important. - **Superseded by review fixes:** - warning once and falling back to a distorted canvas; - adopting a new validator after one mismatch; - simulating the Firefox check in Chrome. - **Left as is:** - deck.gl's default tile cache size. Cost: hundreds of MiB of GPU memory on large high-DPR screens. - Blockiness past z12 wasn't checked. Cost: possibly blocky shading at zooms 13-14. - The colormap range follows the chosen place, not the current view. Cost: a poor range after panning far. - Borders can survive an archive swap. Cost: a stray seam right after a swap. - Safari is untested. Its private browsing would now get the error message. - StrictMode opens the archive twice in development. - A few unused deck.gl dependencies, copied from titiler-cog. - A ring is rewritten once per neighbor that loads after its tile, up to eight times. Cost: four small `writeData` calls each. - Where tiles of two zoom levels meet, the finer tile's neighbor at its own zoom may never load, so that side keeps a repeated edge. The tilted views above stayed at one tile zoom, so I didn't see it happen. - Decoding stays on the main thread. Cost: about 15 ms for the 12-tile opening view. </details> <details> <summary>Deferred minors</summary> - The center texel isn't clamped at the tile edge, which could draw a speck there. None was seen. - `performance.measure` entries pile up over a session. </details> 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
#809 gave COGLayer a 50 ms request debounce by default, so the test's loads hadn't started when it checked them, after merging main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. `MosaicLayer` passed `renderSource` the signal of the item's open. Both its docs example and the naip-mosaic example passed it on to each COGLayer's `signal`. That signal can't do what passing it suggests, and it can leave an item blank: - **It can't stop a layer's tile loads.** deck.gl doesn't abort a tile once it has loaded, and `renderSource` only draws items whose open has finished. - **It can arrive already aborted.** Say an item's open is aborted while more than `maxRequests` opens are in flight, and its `getSource` finishes anyway. Then deck.gl keeps the source, together with the aborted signal. - naip-mosaic's shared per-URL cache allows that: a later load's abort doesn't reject the promise that an earlier load started. - When the item is drawn again, its COGLayer gets the aborted signal, and every tile load aborts at once. The item stays blank for as long as its mosaic tile stays cached. `renderSource` now gets only `{ source }`. A COGLayer already aborts its loads that leave the view (#809). It aborts the rest when MosaicLayer evicts its item and the layer is finalized (#728). ## Migration Drop `signal` from `renderSource`'s options. 0.10 already changes them from `{ data }` to `{ source }`. ```ts // Before renderSource: (item, { source, signal }) => new COGLayer({ id: item.url, source, signal }), // After renderSource: (item, { source }) => new COGLayer({ id: item.url, source }), ``` ## Tests - **The bug, in deck.gl's `LayerManager`.** The test reproduces it step by step: 1. With `maxRequests: 1`, item A's open is aborted when A leaves the view while F's starts. 2. A's `getSource` finishes anyway. 3. A comes back into view. Before the fix, `renderSource` got an aborted signal. Now it gets `{ source }`. - **A type test:** `renderSource`'s options are exactly `{ source?: SourceT }`. It fails if `signal` is added back. - **The workspace typecheck** passes, naip-mosaic included. - **In Chrome:** naip-mosaic draws as before (924 NAIP items over Denver), with no new console messages. 🤖 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.1` in the root `package.json` and in every `packages/*/package.json`, ready for the first 0.10 beta. The publish workflow sees `beta` in the version and publishes to npm under the `beta` dist-tag, so `latest` stays on 0.9.0. `CHANGELOG.md` gets a `v0.10.0-beta.1` section listing the 19 PRs merged since v0.9.0. ## Publish `@developmentseed/range-reader` by hand before tagging `@developmentseed/range-reader` (#806) isn't on npm yet, and `@developmentseed/geotiff` and `@developmentseed/deck.gl-geotiff` depend on it. The publish workflow can't create it: it publishes only through trusted publishing (OIDC), and npm can add a trusted publisher only to a package that [already exists](https://docs.npmjs.com/cli/v11/commands/npm-trust). Pushing the tag first would fail at `range-reader`. `pnpm publish --recursive` stops at the first failure, so packages published before it in the run would be out, and the rest, including `geotiff` and `deck.gl-geotiff`, would not. Once this is merged, from an up-to-date `main`: 1. Publish it once, as a public package under the `beta` tag. Its `prepublishOnly` script builds it first. ```sh cd packages/range-reader pnpm publish --tag beta --access public --no-git-checks ``` 2. Give it the same trusted publisher as the other packages (workflow `release.yml`, environment `release`), in its settings on npmjs.com or with: ```sh npm trust github @developmentseed/range-reader --file release.yml --repo developmentseed/deck.gl-raster --env release --allow-publish ``` 3. Tag the merge commit `v0.10.0-beta.1` and push the tag. The workflow skips `range-reader`, since that version is already on npm, and publishes the other ten packages. ## Breaking changes - #799: `COGLayer` takes a single `source`: an opened `COGSource`, or any input of `COGSource.open`. `geotiff` becomes `source`, `onGeoTIFFLoad` becomes `onSourceLoad`, and `epsgResolver` and `concurrencyLimiter` move to `COGSource.open`. - #801: `MultiCOGLayer` does the same with `MultiCOGSource`. `sources: { red: { url } }` becomes `source: { red: url }`, `MultiCOGSourceConfig` is removed, and files that don't share a CRS and an extent are rejected. - #804: `MosaicLayer`'s `sources` becomes deck.gl's `data`, and `MosaicSource` becomes `MosaicItem`. The callbacks get the item's opened source as `source`, and `onViewportLoad`'s entries are `{ item, source }`. - #821: `renderSource` gets only `{ source }`, without `signal`. - #812: `ZarrLayer` takes a `ZarrSource`, or a zarrita group or array, as `source`. `node`, `variable`, `metadata` and `epsgResolver` are removed (`metadata` becomes `ZarrSource.open`'s `geoZarrMetadata`), and the type parameters are now `ZarrLayer<DataT, Dtype, Store>`. - #807: `GeoTIFF.fromUrl` no longer takes `chunkSize` or `cacheSize`. They're `RangeReader` options now (`minMetadataReadBytes`, `cache.metadataBytes`). Two behavior changes aren't marked breaking: - #809: COG tile reads are coalesced by default, and `COGLayer` and `MultiCOGLayer` default to `maxRequests: 256` and `debounceTime: 50`. - #818: changing `updateTriggers.getTileData`, or ZarrLayer's `selection`, fetches tiles again, and the old tiles are removed at once. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
…er (#837) > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Moves `DEFAULT_RANGE_READER`, the shared `RangeReader` that COG sources and layers read through by default (#809), from `@developmentseed/deck.gl-geotiff` to `@developmentseed/deck.gl-raster`. A Zarr range-reader adapter in deck.gl-zarr can then share the same reader, with its byte cache and batching window, without depending on deck.gl-geotiff. deck.gl-raster now depends on `@developmentseed/range-reader`. deck.gl-geotiff no longer exports it and keeps no re-export, so the symbol has one home. Behavior is unchanged: `COGSource.open`, `MultiCOGSource.open` and `MosaicLayer` default to the same single instance, now imported from deck.gl-raster. `DEFAULT_CONCURRENCY_LIMITER` stays in deck.gl-geotiff. The module is marked side-effect free, so an app that doesn't use the reader doesn't bundle it: the zarr-sentinel2-tci example build contains no range-reader code. ## Migration ```ts // Before import { DEFAULT_RANGE_READER } from "@developmentseed/deck.gl-geotiff"; // After import { DEFAULT_RANGE_READER } from "@developmentseed/deck.gl-raster"; ``` ## Tests - The existing `COGSource.open` and `MultiCOGSource.open` tests import `DEFAULT_RANGE_READER` from deck.gl-raster, including "defaults to the shared reader", which checks that a bare `COGSource.open` reads through deck.gl-raster's instance. - `pnpm -r --filter='!docs' typecheck` and `pnpm -r test` pass. The cog-basic, vermont-cog-comparison, naip-mosaic and zarr-sentinel2-tci examples build. 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
https://github.com/user-attachments/assets/9947d32c-e2d6-4946-93d6-29e5a761bbfb > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. The usgs-topo example now jumps to the topo map you pick, instead of flying there over one second. You see its tiles load at once, rather than after the camera stops. While the camera flies, the tiles in view change every frame, so `COGLayer`'s 50 ms `debounceTime` (#809) holds back tile requests until the animation ends. After picking another map, the fly-to sent the tile request 1.01 s after the pick. The jump sends it at 0.20 s. ## Changes - `fitBounds` in `onSourceLoad` passes `animate: false` instead of `duration: 1000`. It still fits the map with 40 px padding. ## Checked - The example typechecks and builds, and Biome is clean. - In Chrome, I loaded the page cold, then picked "Mount St Helens" after 5 s, with production builds of `main` and of this branch. One run each, times from the pick: | | `main` (flies) | This PR (jumps) | |---|---|---| | Tile request sent | **1.01 s** | **0.20 s** | | All tiles loaded | **1.33 s** | **0.51 s** | | GeoTIFF requests | 2 | 2 | 🤖 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.
Stage 3 of the range reader (stacked on #807): the deck.gl COG layers share one
RangeReaderby default, hand a whole selection to it in one task, and abort a tile's load the moment the tile leaves the view, so coalesced, streamed, cached range requests are the default path for every COG layer, with no change to deck.gl.Design:
dev-docs/specs/2026-10-26-range-reader-design.md, section "deck.gl-geotiff and deck.gl-raster". Closes #273 (nogetMultiTilesneeded: the batching happens belowgetTileData), closes #747 (the gap rule and caps are reader options; defaults below), closes #762 (received bytes are cached, a pan back refetches nothing).Changes
DEFAULT_RANGE_READERin deck.gl-geotiff, next toDEFAULT_CONCURRENCY_LIMITER: everyCOGLayer,MultiCOGLayerandMosaicLayeron a page shares one byte cache and one batching window.COGSource.open,MultiCOGSource.openandMosaicLayertakereaderandrequestInit(headers, credentials, mode for data behind authentication) and forward them toGeoTIFF.fromUrl; the mosaic passes them togetSourcelike the limiter.COGLayerandMultiCOGLayerdefault tomaxRequests: 256anddebounceTime: 50: deck.gl's six-at-a-time throttle would starve the reader, which merges a selection's reads and is capped by the per-origin limiter instead; the debounce lets a pan settle before anything is requested.RasterTileLayerandMosaicLayerkeep deck.gl's defaults (Support debounceTime in MosaicLayer (flat tile model breaks deck.gl's debounced scheduler) #562).RasterTileset2Dgains an internalabortUnwantedLoadsoption: after every update, a loading tile that is neither selected nor visible is aborted. deck.gl does that only while more thanmaxRequestsloads are in flight; without the rule a streamed request would run on for tiles that left the view.RasterTileLayerexposes it as a protected hook, off by default; the two COG layers turn it on.ZarrLayeris untouched until its own reader adapter lands, because zarrita's coalescer fails every read of a merged request when one of them aborts.Measurements
Same machine, same hour, headed Chrome 156 through the CDP harness in
dev-docs/perf-harness, two repeats, counting only the S3 host. Before is the stage 1 tip (behaviour identical tomain), after is this branch. Settled screenshots are pixel-identical (ImageMagickcompare -metric AE= 0) for every scenario. The review of this PR found two things fixed in87b49a85: a loading tile that deck.gl evicted inside its own update kept its stream alive (now aborted through the tileset'sonTileUnload), and the README showedreader/requestInitasCOGLayerprops, which do not exist (open the source yourself;MosaicLayerhas the props).The single pan on cog-basic brings in one column of new tiles, which are not adjacent in file order, so nothing merges there and nothing is worse; the ten fast pans fetch the same bytes with fewer requests, and the pan-away-and-back is the #762 case: before, the way back refetched five tiles that had been evicted; after, every request started mid-pan was cancelled before a byte arrived and the view on return was served from cache. Settle times were too noisy on this connection to read (the 2 MB tiles are bandwidth-bound; cold zoom 2.8 / 3.2 s before against 2.7 / 5.2 s after, and the reverse spread on the warm run; sentinel-2 zoom 6.3 / 6.6 s before, 6.0 / 8.6 s after).
Not run, left for the review:
naip-mosaic,vermont-cog-comparison, the usgs-topo mosaic app linked against this build, the centre-tile timing, and the knob sweeps (maxGap,maxOverfetchBytes,debounceTime,cacheMode). The defaults are the spec's first-implementation values:maxGap: "median",maxOverfetchBytes1 MiB,maxRequestBytes16 MiB,minMetadataReadBytes64 KiB, cache 32 MiB metadata + 64 MiB data shared page-wide. To rerun:dev-docs/perf-research-2026-10.md, "How to re-run" (the harness needs thewindow.__overlayhook from its instrumentation patch applied toexamples/_shared).After Kyle's review of #806 (2026-10-27)
The numbers above were measured before the widened-block fix in #806 (a metadata block was cancelled after its first chunk and requested again), so the metadata-side request counts, the usgs-topo sheet load in particular, should be lower now; the gate still needs the rerun listed above. The README follows the
metadatabudget name.Timing (2026-10-28, with #815)
Does it make things faster, and how much? Measured on the same machine with the CDP harness, cold cache, headed Chrome 156, as instant camera jumps so the numbers are request timing rather than animation: first tile is the time from the jump until the first newly selected tile is loaded, all loaded until every root layer reports loaded, both sampled per animation frame from deck's tile state, no idle floor. Before is
mainafter #806 (chunkd path, deck.gl's six at a time), five repeats; after is this stack plus #815 with its 1 MiB default, three repeats. Page load is from navigation to all tiles loaded and includes the app's own bootstrap; it varies several-fold run to run in both builds (sentinel-2's ranges 1 to 9 s), so read the jump rows, not the page-load rows. Medians.native (home link, ~45 Mbit/s, low RTT)
emulated 200 Mbit/s, 80 ms RTT
emulated 10 Mbit/s, 150 ms RTT
Reading it:
experiment/range-reader-launch-order. The remaining fix is an adaptive cap derived from the selection's size, so a small selection such as a pan yields enough units to keep six streams busy; that is the follow-up.Not measured: your usgs-topo mosaic app against this build, and HTTP/2 hosts (all four examples read from S3 or Azure Blob, which are HTTP/1.1).
🤖 Written by Claude Code
🤖 Generated with Claude Code