Skip to content

feat(deck.gl-geotiff): coalesce COG tile reads by default - #809

Merged
kylebarron merged 7 commits into
mainfrom
kyle/range-reader-layers
Oct 28, 2026
Merged

kylebarron merged 7 commits into
mainfrom
kyle/range-reader-layers

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

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 RangeReader by 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 (no getMultiTiles needed: the batching happens below getTileData), 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_READER in deck.gl-geotiff, next to DEFAULT_CONCURRENCY_LIMITER: every COGLayer, MultiCOGLayer and MosaicLayer 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.
  • COGLayer and MultiCOGLayer default to maxRequests: 256 and debounceTime: 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. RasterTileLayer and MosaicLayer keep deck.gl's defaults (Support debounceTime in MosaicLayer (flat tile model breaks deck.gl's debounced scheduler) #562).
  • RasterTileset2D gains an internal abortUnwantedLoads option: 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; without the rule a streamed request would run on for tiles that left the view. RasterTileLayer exposes it as a protected hook, off by default; the two COG layers turn it on. ZarrLayer is untouched until its own reader adapter lands, because zarrita's coalescer fails every read of a merged request when one of them aborts.
  • Docs: a "Requests, caching and authentication" section in the deck.gl-geotiff README.

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 to main), after is this branch. Settled screenshots are pixel-identical (ImageMagick compare -metric AE = 0) for every scenario. The review of this PR found two things fixed in 87b49a85: a loading tile that deck.gl evicted inside its own update kept its stream alive (now aborted through the tileset's onTileUnload), and the README showed reader/requestInit as COGLayer props, which do not exist (open the source yourself; MosaicLayer has the props).

Example Scenario Before (requests / MB) After (requests / MB)
cog-basic (Sentinel-2 TCI, 1024 px tiles of ~2.4 MB) load 14 / 4.4 3 / 4.3
cog-basic zoom +3, cold cache 28 / 22.8, 18 cancelled 9-10 / 22.8, 6-7 cancelled
cog-basic zoom +3, warm 28-29 / 22.8-23.5 10 / 22.8
cog-basic pan 1 viewport 8 / 19.0 8 / 19.0
cog-basic ten fast pans (1 viewport each, 20 frames) after the zoom 8 / 19.0, 0 cancelled 5 / 19.0, 0 cancelled
cog-basic pan 3 viewports away, then back away: 11 / 4.8 (5 cancelled); back: 5 / 4.6-9.6 away: 11 started, all cancelled before a byte, 0 MB; back: same, 0 MB
sentinel-2 (MultiCOGLayer, one scene's band files) load 36-42 / 8.5-10.5 9 / 10.3
sentinel-2 zoom +2 114-117 / 36.3-37.4, 12 cancelled 23 / 35.2, 8 cancelled
usgs-topo (one HTMC sheet, 128 px tiles) load 151-154 3-5
usgs-topo pan 0.5 viewport 0 0

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", maxOverfetchBytes 1 MiB, maxRequestBytes 16 MiB, minMetadataReadBytes 64 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 the window.__overlay hook from its instrumentation patch applied to examples/_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 metadata budget 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 main after #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)

Example Step First tile before -> after (ms) All loaded before -> after (ms) Speedup Requests before -> after MB
usgs-topo page load 510 -> 752 1988 -> 1749 1.14x 89 -> 35 0.3
usgs-topo zoom +2 (jump) 136 -> 197 1943 -> 579 3.36x 99 -> 9 0.6
usgs-topo pan 1 viewport (jump) 132 -> 186 721 -> 299 2.41x 32 -> 8 0.1
naip-mosaic page load 146 -> 573 8484 -> 9112 0.93x 257 -> 257 47.3
naip-mosaic zoom +2 (jump) 185 -> 624 2993 -> 3508 0.85x 50 -> 33 22.0
naip-mosaic pan 1 viewport (jump) 19 -> 17 2376 -> 2737 0.87x 30 -> 20 10.8
sentinel-2 page load 691 -> 1022 1487 -> 3408 0.44x 75 -> 51 11.2
sentinel-2 zoom +2 (jump) 489 -> 532 5738 -> 5025 1.14x 99 -> 50 36.9
cog-basic page load - -> - 618 -> 660 0.94x 47 -> 36 4.7
cog-basic zoom +3 (jump) 747 -> 1015 4088 -> 4162 0.98x 10 -> 10 23.9
cog-basic pan 1 viewport (jump) 1154 -> 920 3318 -> 3521 0.94x 8 -> 8 20.0

emulated 200 Mbit/s, 80 ms RTT

Example Step First tile before -> after (ms) All loaded before -> after (ms) Speedup Requests before -> after MB
usgs-topo page load 621 -> 825 2434 -> 1840 1.32x 92 -> 35 0.4
usgs-topo zoom +2 (jump) 146 -> 181 2164 -> 559 3.87x 99 -> 9 0.6
usgs-topo pan 1 viewport (jump) 142 -> 224 741 -> 340 2.18x 32 -> 8 0.1
naip-mosaic page load 232 -> 309 9163 -> 9258 0.99x 257 -> 257 47.3
naip-mosaic zoom +2 (jump) 188 -> 551 3165 -> 2985 1.06x 50 -> 33 22.0
naip-mosaic pan 1 viewport (jump) 16 -> 19 1965 -> 2403 0.82x 30 -> 20 10.8
sentinel-2 page load 768 -> 969 1712 -> 1663 1.03x 75 -> 51 11.2
sentinel-2 zoom +2 (jump) 521 -> 635 5498 -> 4446 1.24x 99 -> 50 36.9
cog-basic page load - -> - 798 -> 829 0.96x 47 -> 36 4.7
cog-basic zoom +3 (jump) 1076 -> 1278 3258 -> 3094 1.05x 10 -> 10 23.9
cog-basic pan 1 viewport (jump) 1031 -> 1224 2905 -> 2948 0.99x 8 -> 8 20.0

emulated 10 Mbit/s, 150 ms RTT

Example Step First tile before -> after (ms) All loaded before -> after (ms) Speedup Requests before -> after MB
usgs-topo page load 837 -> 1089 3973 -> 3410 1.17x 82 -> 35 0.3
usgs-topo zoom +2 (jump) 234 -> 248 3067 -> 928 3.30x 99 -> 9 0.6
usgs-topo pan 1 viewport (jump) 199 -> 278 1088 -> 526 2.07x 32 -> 8 0.1
naip-mosaic page load 751 -> 470 40406 -> 40332 1.00x 257 -> 257 47.3
naip-mosaic zoom +2 (jump) 729 -> 4275 16904 -> 17449 0.97x 50 -> 33 22.0
naip-mosaic pan 1 viewport (jump) 17 -> 16 8918 -> 9107 0.98x 30 -> 20 10.8
sentinel-2 page load 3791 -> 3311 10604 -> 10351 1.02x 71 -> 51 9.3
sentinel-2 zoom +2 (jump) 1849 -> 2192 29885 -> 29831 1.00x 99 -> 50 36.9
cog-basic page load - -> - 2049 -> 2037 1.01x 47 -> 36 3.9
cog-basic zoom +3 (jump) 11133 -> 11147 19367 -> 19480 0.99x 10 -> 10 23.9
cog-basic pan 1 viewport (jump) 11497 -> 11188 16274 -> 16320 1.00x 8 -> 8 20.0

Reading it:

  • Small tiles win, everywhere. usgs-topo's 128 px tiles: a zoom completes 3.4x to 3.9x faster and a pan 2.1x to 2.4x faster in every link condition; page load 1.1x to 1.3x. The first tile is 50 to 80 ms later, which is the new 50 ms debounce.
  • Multi-file tiles win on fast links. sentinel-2 (MultiCOGLayer, ten scenes): 1.14x native, 1.24x on the fast link, equal on the slow link where bytes are all that matters; the first tile is back at the unmerged 0.5 s after fix(range-reader): request cap for adjacent reads, round-robin launches, 1 MiB default #815's round-robin launch, where the unbounded merge had it at 2.5 s.
  • Big single tiles are at parity. cog-basic's 2.4 MB tiles do not merge at a 1 MiB cap; the view is the same requests as before and loads in the same time (0.94x to 1.05x). What this stack adds there is the cache and the cancellation, not speed: the pan-away-and-back case fetches nothing on the way back.
  • A mosaic of mid-size tiles is the one mixed case. naip-mosaic's 460 KB tiles merge in pairs (50 to 33 requests); a zoom on the home link is 0.85x and a pan 0.83x, the fast link 1.13x and 0.92x, five interleaved repeats each. The request timelines say why: no metadata requests during the zoom (offsets are cached at load), five of six streams busy on average in both builds, the same 9 Mbit/s per stream in both, so this link only reaches its 45 to 50 Mbit/s with all six streams running, and this bucket is in Azure EU West at 120 ms to first byte. Merged units of about 780 KB against 460 KB single tiles leave a longer tail where fewer than six streams are busy; the latency saved by 17 fewer requests is real but smaller than that tail on this link, and the arithmetic flips on the fast link. Two launch orders were tried against it: largest-first brings the zoom to parity (1.00x home, 1.21x fast) but delays sentinel-2's first tile from 0.53 s to 1.27 s, and a first-run-then-largest hybrid keeps the first tile but loses the naip win; neither is in fix(range-reader): request cap for adjacent reads, round-robin launches, 1 MiB default #815, both are on 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.
  • Two bugs the benchmark found are in fix(range-reader): request cap for adjacent reads, round-robin launches, 1 MiB default #815, which this stack should land after: contiguous tiles merged without any bound because an adjacent read counted as overlapping, which is why the first pass of this benchmark showed big tiles at 0.6x on the fast link; and merged ranges launched file by file, which held every MultiCOG tile until the last band file's streams started.

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

@kylebarron
kylebarron added this pull request to stack #808 October 27, 2026 16:31
@kylebarron kylebarron changed the title kyle/range reader layers feat(deck.gl-geotiff): coalesce COG tile reads by default Oct 27, 2026
@github-actions github-actions Bot added the feat label Oct 27, 2026
@kylebarron
kylebarron force-pushed the kyle/range-reader-layers branch 2 times, most recently from 54436b8 to 6a8af6e Compare October 27, 2026 21:49
@kylebarron
kylebarron force-pushed the kyle/range-reader-layers branch 2 times, most recently from 55a3ac3 to 9cc8cf1 Compare October 28, 2026 00:32
kylebarron added a commit that referenced this pull request Oct 28, 2026
> [!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]>
@kylebarron
kylebarron force-pushed the kyle/range-reader-layers branch 2 times, most recently from af2f612 to e6fffbe Compare October 28, 2026 00:38
@kylebarron
kylebarron force-pushed the kyle/range-reader-layers branch from e6fffbe to c953f24 Compare October 28, 2026 03:50
kylebarron added a commit that referenced this pull request Oct 28, 2026
…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]>
@kylebarron
kylebarron force-pushed the kyle/range-reader-layers branch 2 times, most recently from c320d66 to 806274c Compare October 28, 2026 18:32
Base automatically changed from kyle/range-reader-geotiff to main October 28, 2026 18:38
@kylebarron
kylebarron force-pushed the kyle/range-reader-layers branch from 806274c to cb94fe9 Compare October 28, 2026 18:38
kylebarron and others added 7 commits October 28, 2026 14:39
…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]>
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]>
// reads; the per-origin limiter caps requests. Cast as in MultiCOGLayer.
static override defaultProps = {
...RasterTileLayer.defaultProps,
maxRequests: 256,

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.

Why do we put maxRequests so high again? Because we're coalescing instead of using deck.gl's request limiter?

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

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.

This is the debounce time for how to coalesce tiles? Should it be smaller than 50ms?

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.

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();

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, will this move outside of the geotiff package in the future? We'll want a single reader to manage COG, Zarr, etc, right?

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, 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

Comment on lines +144 to +148
/**
* 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.

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.

can you explain this a little more in detail?

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.

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

@kylebarron

Copy link
Copy Markdown
Member Author

lgtm ✅

@kylebarron
kylebarron merged commit ed7a7f1 into main Oct 28, 2026
5 checks passed
@kylebarron
kylebarron deleted the kyle/range-reader-layers branch October 28, 2026 19:09
kylebarron added a commit that referenced this pull request Oct 28, 2026
#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]>
kylebarron added a commit that referenced this pull request Oct 28, 2026
> [!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]>
kylebarron added a commit that referenced this pull request Oct 29, 2026
#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]>
kylebarron added a commit that referenced this pull request Oct 30, 2026
> [!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]>
kylebarron added a commit that referenced this pull request Oct 30, 2026
> [!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]>
kylebarron added a commit that referenced this pull request Nov 5, 2026
…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]>
kylebarron added a commit that referenced this pull request Nov 9, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant