Skip to content

feat(proposals): Shared Tile2dLayer and MVT2DLayer - #10367

Merged
ibgreen merged 9 commits into
masterfrom
ib/shared-tile-layer
Nov 5, 2026
Merged

ibgreen merged 9 commits into
masterfrom
ib/shared-tile-layer

Conversation

@ibgreen-openai

@ibgreen-openai ibgreen-openai commented Jun 11, 2026 •

Copy link
Copy Markdown
Collaborator

Add Tile2DLayer and MVT2DLayer to @deck.gl/proposals/layers. Multiple layers and views can reuse loaded tile data through one Tileset2D while keeping selection, rendering, and picking independent. Existing TileLayer and MVTLayer consumers retain the compatibility path.

Move the shared tile demo and the existing proposals examples to examples/proposals. Group the shared tile API reference, Arrow and GPU layer guides, and effects guide in the Proposals documentation section. Update the website, build scripts, and tests to use the new locations.

Validation: lint, 86 Node tests, the moved example’s Chromium test and standalone build, and yarn test-website passed. The website build reported a broken anchor in /docs/TEST-STATUS.


Note

Medium Risk
Refactors core Tileset2D caching and traversal logic used by existing TileLayer and MVTLayer, though backwards compatibility paths and legacy behaviors are preserved.

Overview
Introduces experimental Tile2DLayer and MVT2DLayer to @deck.gl/proposals/layers, enabling multiple layers and viewports to share a single tile cache (Tileset2D) while retaining independent traversal, rendering, picking, and refinement.

Updates Tileset2D in @deck.gl/geo-layers to support multi-consumer registration, viewport-independent adapters, LRU cache eviction, stats, and event subscriptions, while promoting it to a public export alongside Tile2DHeader. Also adds LayerManager.getViewports() to retrieve active viewports across filters.

Relocates experimental examples from examples/v10-experimental to examples/proposals, adds a new shared-tile-2d-layer demo, and reorganizes proposal documentation under a dedicated Proposals category.

Reviewed by Cursor Bugbot for commit c382d4d. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls

coveralls commented Jun 12, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.475% (-0.2%) from 83.703% — ib/shared-tile-layer into master

Comment thread docs/table-of-contents.json Resolved
Comment thread modules/geo-layers/src/index.ts Resolved
Comment thread test/modules/geo-layers/index.ts Resolved

@athomct athomct left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compared this branch (e60e350a6) with the copies of the same layers on deck.gl-community master (fa2160c3): modules/geo-layers/src/shared-tile-2d-layer/, shared-mvt-layer/ and tileset/ (the RFC's shared-tileset-2d/). Besides import paths and headers, the two trees differ in the places below. To check each one, I copied the deck.gl-community tests into this branch's test/modules/geo-layers/ with their imports pointed at the _Shared* exports, and ran them unchanged against this branch's source. I ran them with the repo's vitest node and headless projects (headless Chromium, SwiftShader WebGL2, macOS). Then I applied each deck.gl-community source change to this branch and ran the same tests again. Nothing is pushed.

deck.gl-community fixes and this branch

Fix Status here Location here deck.gl-community Test result on this branch
Picking converts a feature by the coordinate system of the picked sublayer, not the current viewport Missing shared-mvt-layer/shared-mvt-layer.ts:203-208 checks !this.context.viewport.resolution #867, 8bf4f228 Unit test "picks features by the coordinates its sublayer holds" fails: a feature from a LNGLAT sublayer, picked while the viewport is a map, is converted a second time. The browser test (two consumers, map → globe → map) fails: the picked ring has longitude -14576. Both pass with the fix. The existing test shared-mvt-layer.node.spec.ts:162 must then pass coordinateSystem: CARTESIAN in sourceLayer.props, as #867 does.
Lifecycle, retention, request-abort and per-consumer highlight tests at the SharedMVTLayer / SharedTileset2D boundary Behaviour present, tests missing n/a #867, 8bf4f228 All 4 pass unchanged. Only the coverage needs carrying over.
Extrusion height at the tile latitude below zoom 12 on a map; projection-mode change invalidates sublayer matrices Do not port as written. #10790 in this branch's base covers the centered case; an off-center error remains shared-mvt-layer/shared-mvt-layer.ts:131-138, 150 #870, c83a7b67 Both #870 browser tests pass on this branch unchanged. #10790 (92bb3e5dd) now scales CARTESIAN z at the viewport center below zoom 12. With #870's getMVTHeightScale added, "rise in meters at the tile latitude" fails: 76 px of rise against 46 px for the GeoJsonLayer reference, because the latitude correction is applied twice. See finding 5 for the error that remains.
Culling predicate accepts numeric and string results Not needed here deck-tile-traversal.ts:84 (=== 'outside') #879, 89c96e1d This branch is on math.gl 5, and tileset-2d/tile-2d-traversal.ts:90 makes the same comparison. The ported tests fail for two reasons: isOutsideCullingVolume is not exported, and a mocked numeric -1 result is not treated as outside. Both matter only on math.gl 4.
geojson-table result normalized to the feature array; deprecated gis.format override removed Present shared-mvt-layer.ts:121, 127; no gis option #879, 89c96e1d "unwraps a geojson-table tile" and "decodes an MVT tile into its features" (a real MVTWriter round trip) pass.
getPlaceholderInAncestors starts at the tile itself and marks only the first loaded ancestor; getPlaceholderInChildren no longer hides loaded grandchildren Missing shared-tile-2d-layer/shared-tile-2d-view.ts:293-327 #884, a399e5b7 The Tileset2D parity suite runs SharedTile2DView and this branch's own Tileset2D through the same steps. 11 of 14 fail. best-available draws the loaded z4 parents after the z5 tiles have loaded. no-overlap never draws a selected tile, even a loaded one (finding 1). All 14 pass with the fix.
onViewportLoad fires once when the tiles and the loading state change in the same update Missing shared-tile-2d-layer.ts:466 and :478 #884, a399e5b7 "reports a view load once ..." fails: 2 calls. It passes with the fix.
zoomOffset added before rounding, as in Tileset2D Missing (deck.gl-community #889 is still open and changing) deck-tileset-adapter.ts:189-193 #889 (open) Both #889 tests fail. At zoomOffset: -0.5, zoom 3.5, this branch selects z4 and Tileset2D selects z3. Integer offsets already agree, and the TileLayer docs say the offset "needs to be an integer". The difference shows only for fractional offsets, which #889 makes meaningful.

This branch also has changes that deck.gl-community lacks, and the later port must keep them:

  • SharedTileset2D.setOptions (shared-tileset-2d.ts:282) has {replace: true}, the source-metadata generation guard, and a request-scheduler rebuild when maxRequests or debounceTime changes. It also emits onUpdate, and a change of TileSource clears and refetches the metadata and reloads the cache.
  • URL-template data is compared with urlType.equal.
  • visibleMinZoom / visibleMaxZoom.
  • The SharedTileset2DListener and SharedTile2DLoadDataProps types are exported from shared-tileset-2d/index.ts, though not from the package entry.

Other findings on this branch

1. refinementStrategy: 'no-overlap' never draws a selected tile. getPlaceholderInAncestors (shared-tile-2d-view.ts:297) starts at startTile.parent, so a loaded selected tile never marks itself visible. Tileset2D starts at the tile. A selected tile with no cached ancestor goes to getPlaceholderInChildren (:310), which sets its VISIBLE bit. But updateTileStateReplace (:265) has already read isVisible for that tile, so the bit arrives too late. As a result, no-overlap draws only placeholders: cached loaded ancestors, or loaded descendants. In the parity run, at zoom 4.1 with all four z4 tiles loaded and nothing else cached, Tileset2D draws the z4 tiles and this view draws []. If you zoom out from loaded z5 to z4, the view shows the z5 tiles as placeholders while z4 loads. Once z4 has loaded, it draws nothing. The fix is the same as #884. No test here exercises 'no-overlap' or 'never'.

2. Option and metadata changes do not reselect tiles until the viewport moves. SharedTile2DView.update (shared-tile-2d-view.ts:107-124) recomputes the tile indices only when the viewport, zRange or modelMatrix changes. Tileset2D.setOptions sets this._viewport = null (tileset-2d/tileset-2d.ts:215-216), which forces a reselection; SharedTileset2D.setOptions has nothing equivalent. In a probe, a view selected z5 tiles. I then called tileset.setOptions({maxZoom: 2}) and updated the view with the same viewport: tileset.maxZoom was 2, but the view still selected z5. The layer goes through this path when maxZoom, minZoom, extent, zoomOffset or visibleMin/MaxZoom props change on an owned tileset. It also goes through it when TileSource metadata arrives after the first update. In that case, tiles chosen before minZoom/maxZoom/bounds were known stay selected until the user pans.

deck.gl-community has the same issue: the same probe on its master gives the same result (maxZoom 2, still selecting z5).

3. Evicted tiles stay reachable from every view. SharedTile2DView._state (shared-tile-2d-view.ts:187-191) gains an entry for every tile in tileset.tiles at each update. Nothing removes the entries for tiles that _resizeCache evicts (shared-tileset-2d.ts:705), and eviction does not clear tile.content. I ran a probe with maxCacheSize: 4 and panned one view across 40 positions at zoom 8. At the end the tileset held 4 tiles, and the view's _state held 124. 120 of those were evicted tiles, all still holding their content. So the cache limit does not free memory while a view lives. With several consumers, each one holds its own set.

deck.gl-community has the same issue: the same probe on its master gives 124 entries in _state, 120 of them evicted tiles with content.

4. A view that is removed from the deck stays attached to the shared tileset. Nothing removes a viewport id from _knownViewports or state.tilesetViews (shared-tile-2d-layer.ts:268, 685) once the deck stops rendering that viewport. The only exceptions are the bootstrap placeholder and a tileset replacement. _updateTileset keeps calling update() on the removed view with its last viewport. In a browser test I used a deck with views main and mini over one external _SharedTileset2D, then set views to [main] and moved main. The layer still held both views, stats.get('Consumers').count stayed at 2, and the four z5 tiles that only mini selected stayed in tileset.selectedTiles. They are pinned against eviction, and the layer's aggregate isLoaded still waits on them. TileLayer has no per-view state, so this problem is new with this layer.

deck.gl-community has the same issue: the same browser test on its master gives the same result (2 consumers, the four z5 tiles still selected).

5. Off-center extrusions below zoom 12 use the viewport-center latitude. With #10790, a CARTESIAN tile's z is scaled at the viewport center (core/src/shaderlib/project/viewport-uniforms.ts:88), while LNGLAT geometry is scaled per vertex (project_size_at_latitude). I placed an extruded polygon at latitude 60 and measured its rise in pixels against the same polygon as a GeoJsonLayer (pitch 60):

view center latitude zoom SharedMVTLayer rise GeoJsonLayer rise
60 4 55 px 56 px
54 3 39 px 47 px
45 3 26 px 37 px

The shortfall follows cos(60°)/cos(center latitude), within what pixel measurements under perspective can show. #870's per-tile factor is not the answer on this base, because it adds a second latitude factor on top of the viewport-center scale. A per-tile factor here would need cos(center)/cos(tile). That ratio changes whenever the view center moves, so the sublayer modelMatrix would have to be rebuilt on every pan. A per-vertex latitude scale for CARTESIAN in core's project_size(), like the one LNGLAT already gets, may be cleaner.

6. A custom refinementStrategy function is accepted but has no effect, and the two doc pages disagree about it. RefinementStrategy includes RefinementStrategyFunction (shared-tileset-2d.ts:17-23), and SharedTile2DView calls it with the shared tileset.tiles (shared-tile-2d-view.ts:200). SharedTile2DHeader has no isSelected / isVisible, and visibility is read from the view's private _state map. A callback therefore cannot change what draws. shared-tile-2d-layer.md:89 says callbacks are not supported. shared-tileset-2d.md:64 says they "run against view-local tile facades", and no facade exists in the code. The options are to reject functions in the type and in validation, or to implement the facade.

deck.gl-community has the same issue. Its docs go further than this branch's and list Function as a supported refinementStrategy on both pages. A probe whose callback sets isVisible = false on every tile ran twice and changed nothing: 4 of 4 selected tiles still drew, on both trees.

7. onTileError is silent by default. shared-tile-2d-layer.ts:82 defaults it to () => {}, where TileLayer defaults it to err => console.error(err). A failing tile URL produces no output here unless the app passes a handler.

deck.gl-community has the same issue: onTileError defaults to () => {} there too. Calling the default printed nothing on either tree, and TileLayer's default called console.error once.

8. Export naming is mixed. The classes are exported as experimental (_SharedTile2DLayer, _SharedTileset2D, _SharedTile2DHeader, _SharedMVTLayer). sharedTile2DDeckAdapter is exported without the prefix (geo-layers/src/index.ts:63, and again from deck.gl). If the adapter is meant to be experimental too, it should carry the prefix, so it doesn't become public API by accident.

deck.gl-community does not have this issue. It exports every class, the adapter and the types without the _ prefix, consistently.

9. A second copy of the tileset and refinement code. shared-tileset-2d.ts (756 lines) and shared-tile-2d-header.ts closely follow tileset-2d/tileset-2d.ts (737 lines) and tile-2d-header.ts. shared-tile-2d-view.ts re-implements the refinement helpers. Findings 1 and 2 and the #884 row are all places where the copy differs from Tileset2D, and in each case Tileset2D is correct. If the shared path stays a separate implementation, a parity test that runs both on the same steps would keep them aligned. The deck.gl-community shared-tile-2d-view.spec.ts is such a test, and it ports with an import change only.

10. Missing tests. Nothing here tests: 'no-overlap' or 'never'; parity with Tileset2D placeholder selection; reselection after an option change; eviction while a view lives; picking during the frames after a map ↔ globe switch; removing a view or changing its id; onViewportLoad call counts. The deck.gl-community suites listed above cover several of these.

Branch state

ib/shared-tile-layer was last updated on 2026-10-12, in 7a8912c29, which merged master up to d9e395c93 (#10792). It is 3 commits behind master c00485314b (#10849, #10859, #10861). None of the 3 touch modules/geo-layers. #10849 edits docs/whats-new.md and website/src/examples-sidebar.js, which this branch also edits. git merge-tree merges ib/shared-tile-layer into master with no conflicts. This branch's own tests pass as they stand: 6 in shared-mvt-layer.node.spec.ts and 16 in the two headless specs.

@ibgreen ibgreen changed the title RFC(geo-layers): SharedTile2DLayer and SharedMVTLayer feat(geo-layers): Tile2DLayer and MVT2DLayer with one Tileset2D Oct 14, 2026

ibgreen commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Review follow-up is pushed in 6feaaf2 and 6e74bf1, building on the API consolidation in 3ee2784.

  • One backward-compatible Tileset2D and one header implementation now serve both generations. Built-in refinement also uses one shared implementation rather than copied algorithms.
  • Selection invalidates after option/metadata changes, view state releases evicted entries, and removed/scoped-out views detach. viewIds restricts both traversal and rendering; a render-only layerFilter no longer makes the demo's independent-cache comparison misleading.
  • onViewportLoad tracks each view's loading transition, fires once, and includes the viewport. Shared-cache events resolve to the current matched layer after React state transfers.
  • Picking follows the picked sublayer's coordinate system. Low-zoom extrusion uses geographic vertex scaling instead of adding a second latitude factor. Planar clipping is rebuilt when geographic map rendering switches to a globe.
  • Public names are Tile2DLayer, MVT2DLayer, Tileset2D, and Tile2DHeader; compatibility imports remain with @deprecated Use ... TSDoc. The adapter is public and explained. The math.gl 4 numeric-culling workaround is intentionally not ported to this math.gl 5 branch.
  • Reference pages now cover ownership, metadata precedence, callbacks, stats, view scoping, and explicit compatibility limits. Tile2DLayer and MVT2DLayer have bounded live demos. The shared example has two styles, split-screen views, a real minimap, and subscription-driven counters. Desktop and expanded-mobile infobox bounds were checked not to obscure the minimap.

Validation: 46 Node tests; 141 affected headless tests passed, one skipped; live map/globe picking and off-center extrusion pixel comparisons; deterministic example smoke test; build/type checks; lint; website and example builds; 197 raw documentation pages validated; desktop/mobile light/dark rendering checked. The tested live desktop comparison made 16 requests shared versus 28 independent, with no runtime errors. Exact savings depend on viewport size and cache history.

The release-note conflict is fixed without pulling unrelated master changes into the branch. git merge-tree succeeds against current master, and GitHub reports the PR mergeable. Full repository golden-image suites were not run. Existing unrelated website warnings remain in TEST-STATUS anchors and several older pages' HTML minification.

ibgreen commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

cc @chrisgervang @athomct: the review updates are pushed through 6e74bf12c7. The implementation and validation summary is in #10367 (comment). I added current follow-ups to all six inline threads and left them open for your confirmation rather than marking them resolved.

Additional explicit responses to the detailed review:

  • Custom refinement functions now operate on view-local tile facades; changes affect that consumer's visibility without modifying another consumer's flags. The docs and tests match this behavior.
  • Default tile errors are logged rather than silently ignored.
  • Fractional zoom offsets use the same selection path as the legacy tileset, with parity coverage; the duplicated traversal/refinement implementations have been consolidated.
  • Existing source-metadata generation guards, option replacement, request-scheduler changes, URL-template equality, and visibility zoom limits are retained. Public listener/load types are exported consistently.
  • Regression coverage includes best-available/no-overlap/never refinement, option/metadata reselection, eviction, view removal, per-view callback counts, MVT decoding/lifecycle/highlighting, map/globe picking, and off-center extrusion comparisons.

The math.gl 4 numeric-culling workaround was intentionally not carried over because this branch uses math.gl 5. Full repository golden-image suites remain unrun; the affected test suites and live rendering comparisons passed. Please confirm whether the changes address your concerns; the review threads remain open.

@athomct

athomct commented Oct 14, 2026

Copy link
Copy Markdown

Thanks for the thorough revision. I re-checked every point of my earlier review on 6e74bf12c7 by running tests, not by reading the summary. These are the tests:

  • The deck.gl-community tests I ported for the first review, with only the imports renamed.
  • My earlier probes.
  • A few new tests.

I ran them with the repo's vitest node and headless projects (headless Chromium, SwiftShader WebGL2, macOS). For the parity checks, I also copied master's tileset-2d/ (c00485314) beside the branch, so the new code is checked against the old Tileset2D and not only against itself. Nothing is pushed.

The branch's own suites pass: 26 node tests in shared-mvt-layer.node.spec.ts and tile-2d-compatibility.node.spec.ts, and 66 headless tests across 8 files. Those 8 files include master's unchanged tileset-2d, tile-layer and mvt-layer specs. git merge-tree against master is clean.

Earlier review: status on 6e74bf12c7

Point Status Evidence
#867: picking converts by the picked sublayer's coordinate system Fixed The node test "picks features by the coordinates its sublayer holds" passes. So does the browser test "two consumers draw and pick one decoded tile in map, globe and map again". Both failed on e60e350a6.
#884: placeholder parity Fixed The 14-case parity suite passes 14/14 (it was 3/14). I also ran it against master's Tileset2D instead of the branch's, and added 'never' and eight more step sequences for all three strategies. All 38 cases agree.
#884: onViewportLoad fires once Fixed The ported unit test passes. I only changed its harness, to set layer.context and loadedViewIds. I also ran it on a real deck. With one view, there were 2 calls for 2 settles, the same as TileLayer. With two views, there was one call per view, and each call carried its viewport.
#870 / finding 5: extrusion Fixed Both #870 browser tests pass. The off-center probe now matches GeoJsonLayer exactly. The rows and pixel counts of the extruded box are identical, in the same scene as finding 5's table (pitch 60, polygon at latitude 60). See the table after this one.
#889: fractional zoomOffset Fixed Both #889 tests pass. At zoomOffset: -0.5 and zoom 3.5, the branch now selects z3.
#879: math.gl 4 numeric culling Agreed not needed The port no longer loads, because deck-tile-traversal.ts is gone. That is expected on math.gl 5.
1. no-overlap never draws a selected tile Fixed Covered by the parity runs above. Both no-overlap and never match master's Tileset2D.
2. No reselection after an option or metadata change Fixed setOptions({maxZoom: 2}) with an unchanged viewport now gives z5 → z2. When TileSource metadata (maxZoom: 2) arrives after the first selection, it also gives z5 → z2. As a side effect, the ported deck.gl-community test "shares one SharedTileset2D across multiple consumers and views" now fails. It relied on that bug: when metadata boundingBox arrives, both views reselect inside the extent.
3. Evicted tiles stay reachable from views Fixed With maxCacheSize: 4, after 40 pans: 4 entries in the view state and 0 evicted. Before, there were 124 entries, 120 of them evicted.
4. Removed views stay attached Fixed Tested on a real deck, not with a mocked getViewports(). See the hook section below.
6. Custom refinement functions have no effect Fixed A callback that hides every tile now draws 0 of 4. To check isolation, I used two views on one tileset with a "draw the parent instead" callback. Each view draws only its own z4 parents, with no overlap. No Tile2DHeader has isVisible or isSelected set. Updating one view leaves the other's drawn set unchanged. Worth stating in the docs: only isVisible is copied back. Facades are new objects on each call, so callbacks cannot key state on tile identity. Writes to shared objects such as userData or content still reach every view.
7. onTileError silent by default Fixed The default now calls console.error once, as TileLayer does.
8. Mixed export naming Fixed Everything is public and unprefixed. The _Shared* names from the previous head are gone rather than aliased, which is fine, since they never shipped. See new finding 4 about the remaining aliases.
9. A second copy of tileset and refinement Fixed One Tileset2D and one refinement.ts serve both the default consumer and views. Master's unchanged Tileset2D and TileLayer specs pass.
10. Missing tests Mostly fixed The new suites cover refinement strategies, reselection, eviction, removal, viewIds and callback counts. Two gaps remain. First, LayerManager.getViewports() has no core test, and the removal test mocks it (tile-2d-compatibility.node.spec.ts:213). Second, nothing compares against the pre-PR Tileset2D. I can contribute the master-parity suite and the real-deck lifecycle tests if you want them.

Off-center extrusion rise (pixels):

view center latitude zoom previous head this head GeoJsonLayer
60 4 55 56 56
54 3 39 47 47
50 4 18 18
45 3 26 37 37

The new parts

The LayerManager viewport hook. It is a pull getter (getViewports(), layer-manager.ts:228-231), not a callback, but on a real deck it does the job. I used one external Tileset2D and views main + mini:

  • View removal, with nothing else changing (the same layers, and main not moved): the tileset views go from [main, mini] to [main]. Consumers go from 2 to 1, and the four z5 tiles that only mini selected are released.
  • View id change (mini → mini2): the views become [main, mini2], and there are 2 consumers.
  • Deck re-creation over the same tileset: consumers go 2 → 0 on deck.finalize() and back to 2 on the new deck. The 8 cached tiles survive, and nothing is fetched again.

I think it is a sound API for this purpose. Two remarks: it needs a core test, and it returns every deck viewport whatever layerFilter says. See new finding 3.

viewIds. It works and releases correctly. With ['main'] there is 1 consumer and no z5 tiles. With null there are 2 consumers and 4 z5 tiles. Back to ['main'], there is 1 consumer and the z5 tiles are released. A layer scoped with viewIds requests the same 4 tiles as TileLayer.

Deprecation aliases. At runtime they work: _Tileset2D === Tileset2D and _Tile2DHeader === Tile2DHeader, from both @deck.gl/geo-layers and deck.gl. A file that uses all four aliases type-checks with no errors. The @deprecated tags themselves do not take effect, though. See new finding 4.

New findings, most severe first

1. Tileset2D._getTile recomputes the stats on every lookup, which makes each tree rebuild O(cache² × depth). This affects TileLayer too. _getTile ends with this._updateStats() (tileset-2d.ts:879). That runs for every lookup, including the create = false ancestor lookups that _rebuildTree makes through _getNearestAncestor (:884-896). Each _updateStats is O(cache): it builds the visibleTiles and loadingTiles filters and the consumer unions. Because TileLayer now runs on this class, it pays the cost as well. I measured it in Node with a 1920×1080 viewport at zoom 12. The cache was filled first, and then the view panned half a screen per frame, so every frame adds tiles. Milliseconds per frame:

cache size master Tileset2D this head, TileLayer path this head, Tile2DView path
75 0.22 3.3 3.3
300 0.51 23 22
1000 1.5 209 206

I removed only that one call and ran a 400-frame pan again. That brought it back near master: 125 ms against 108 ms at a cache of 100, 381 ms against 315 ms at 500, and 1000 ms against 717 ms at 2000. Smaller repeated scans of the same kind are _getCacheByteSize() and _updateStats() for each evicted tile (:829, :1092), and the unions rebuilt in each _getRequestPriority call (:655). Stats only need recomputing when the cache or a load state changes. That means on create, load, error and unload, plus once at the end of update / updateConsumer, which already happens.

With a slow pan at the default cache size (54 tiles, new tiles every few frames), the cost is small: 0.12 ms against 0.07 ms per frame. The cost grows with the cache size and with how often tiles arrive.

2. MVT2DLayer picks local or geographic sublayers once per layer, so in multi-view decks the result depends on view order. updateState decides geographic / globe from this.context.viewport (mvt-2d-layer.ts:149-156), and every view of the layer draws the same cached sublayers. I tested one MVT2DLayer on a real deck:

  • [MapView, GlobeView] builds LNGLAT sublayers. The globe draws the test box (1445 red pixels inside its projected bounds).
  • [GlobeView, MapView] builds CARTESIAN sublayers, and the globe view draws 0 pixels.
  • Two MapViews at zoom 13 and zoom 8 with extruded: true behave the same way. In [zoom 8, zoom 13] order, both views get CARTESIAN. So the zoom-8 view draws extrusions with the finding 5 low-zoom error that this revision fixed.

The docs say to use separate layers for map + globe (mvt-2d-layer.md:67). They also say that one layer serves "views using the same projection/rendering mode", and that map extrusions below zoom 12 use geographic geometry (:74). But the docs never draw the conclusion that two map views on either side of zoom 12 need two layers. So an app with a main view and a low-zoom minimap will not see that it has hit this. Nothing warns in either case. Any of these would close it: keep the sublayer cache per mode, use LNGLAT whenever any active view of the layer needs it, or warn when the active views disagree.

3. layerFilter no longer limits which tiles a layer loads, unlike TileLayer. _updateTileset traverses every viewport from layerManager.getViewports() (tile-2d-layer.ts:473-485). I set up a deck where layerFilter hides the layer from mini. Tile2DLayer requested 8 tiles, 4 of them the z5 tiles for mini. TileLayer requested 4. Tile2DLayer with viewIds: ['main'] also requested 4. The viewIds docs say this (tile-2d-layer.md:102). But developer-guide/views.md still presents one layer per view, scoped with layerFilter, as the way to put tiled layers into several views. So an app that moves from TileLayer and keeps its layerFilter will fetch, pin and wait on tiles for views where the layer never draws. layerFilter is a render-time callback, and activation (layers-pass.ts:440-451) also depends on visibility and on which pass ran, so I don't think the activated viewports are a reliable substitute. The simplest fix may be a sentence in views.md saying that Tile2DLayer needs viewIds for this. Another option is a dev-mode warning when a view the layer traverses never activates it.

4. The @deprecated tags on the underscore aliases have no effect. In geo-layers/src/index.ts, the tags sit above export {Tileset2D as _Tileset2D} from ... statements. TypeScript does not attach a statement-level JSDoc tag to the re-exported alias. I checked with the TypeScript 6.0.3 language service (getSuggestionDiagnostics). It flags TileLayer and MVTLayer as deprecated, but flags nothing for _Tileset2D, _Tile2DHeader, _TileLoadProps or _Tileset2DProps. A tag placed on the specifier does work: export {/** @deprecated Use Tileset2D. */ Tileset2D as _Tileset2D} from ....

5. Is deprecating TileLayer and MVTLayer in this PR intended? Both classes now carry @deprecated (tile-layer.ts:189-192, mvt-layer.ts:112-115), so every existing app sees them struck through. Yet the upgrade guide says to keep using MVTLayer for binary data, TileJSON and getRenderedFeatures, which MVT2DLayer does not support yet. Deprecating MVTLayer once MVT2DLayer reaches parity, or deprecating only TileLayer now, would avoid telling those apps to move to something that cannot replace it yet.

6. Small: docs/whats-new.md rewrites old release notes. Besides the new section, the branch removes "(experimental)" from four historical entries. Those are Boundary Sources, Composite Layer Customization (2019), layerFilter per-viewport, and disabling mercator projection (2016). These look unrelated to this PR.

ibgreen commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

cc @athomct @chrisgervang: follow-up fixes are pushed in 17b5c2a816. Thanks for the independent retesting. Responses to the six new findings:

  1. Stats/lookup cost: removed the full stats scan from _getTile, including ancestor lookups during tree rebuilds. Request priority checks query consumer sets directly instead of allocating unions per request. Reload computes its unions once; eviction subtracts each removed payload's bytes and publishes stats after the batch rather than rescanning the cache per tile. Regression tests assert that read-only lookups/priority checks do not scan stats or rebuild unions, and that eviction does not rescan bytes per tile. No extra cache was added.
  2. Mixed-view MVT rendering: render mode now considers every active viewport scoped by viewIds, not whichever viewport happened to be current. If any scoped view needs geographic geometry (globe or low-zoom extrusion), all use that geometry. Globe consumers disable planar clipping for those shared sublayers. Added both-order map/globe and high/low-map unit coverage, plus real-Deck rendering and picking of simultaneous map/globe views in both orders. The reference page explains the policy and optional separate-layer optimization.
  3. layerFilter migration: the views guide now explicitly says to use viewIds for tile loading, retention, and loading status. Render-only layerFilter is not a traversal filter, including when migrating existing per-view tiled layers.
  4. Deprecation aliases: class aliases carry tags on the export specifiers, while type aliases have tagged declarations with their original generic defaults. The main-package alias is tagged too. TypeScript language-service diagnostics are tested, and generated declarations retain the tags.
  5. Legacy MVT deprecation: removed @deprecated from MVTLayer; its API page and upgrade guide explicitly keep it supported for binary data, TileJSON, and rendered-feature queries. TileLayer retains its deprecation; MVT2DLayer remains a public new API rather than experimental.
  6. Historical notes: restored the unrelated experimental wording in all four historical release-note entries.

Coverage gaps: added core LayerManager.getViewports() tests using a real ViewManager, plus a real-Deck removal/rename/finalize/recreation test over an externally owned tileset. Also captured snapshots from the unmodified pre-PR Tileset2D at master c00485314b: 42 state comparisons exercise all three refinement strategies through both the default and independent consumers. These expectations do not compare the new refinement implementation against itself. The docs now also clarify custom-facade identity, shared userData/content, and that only isVisible is copied back.

Validation: lint, full package build, final declaration/type checks, 55 Node tests (also rerun by the commit hook), and 77 focused browser tests passed across the affected suites. The demo smoke test retains its rendering/cache/remount assertions; its software-WebGL phase timeout was increased after initialization delayed request dispatch on this busy host. An initial broad browser attempt hit Tile3D/S2 WebGPU and legacy binary-MVT picking timeouts and was stopped; that broad run is not claimed as passing. Full repository golden-image suites were not run. git merge-tree remains clean against fetched master. yarn test-website also passed: full package rebuild, production docs, 197 raw documentation pages validated, and gallery build. Existing arc source-map, TEST-STATUS anchor, and older-page HTML warnings remain.

All six inline threads remain open for reviewer confirmation; no review threads have been closed.

@ibgreen
ibgreen force-pushed the ib/shared-tile-layer branch from 17b5c2a to 6a38d15 Compare November 5, 2026 14:10
@ibgreen ibgreen changed the title feat(geo-layers): Tile2DLayer and MVT2DLayer with one Tileset2D feat(proposals): Shared Tile2dLayer and MVT2DLayer Nov 5, 2026
@ibgreen
ibgreen marked this pull request as ready for review November 5, 2026 14:43
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T14:43:59.096498Z
We couldn’t complete this review. Comment @codex review to try again.
1b30186 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge and address both numbered findings.

Summary

Adds shared tile loading through Tileset2D, with independent rendering and picking in Tile2DLayer and MVT2DLayer.

  • A shared tileset keeps tile data available to several consumers and views.
  • Tile2DLayer lets each consumer render shared tiles in its own views.
  • MVT2DLayer renders vector tiles from the shared tile cache.
  • Proposal guides and examples now live under a dedicated proposals section.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Source[Tile source] --> Cache[Tileset2D shared cache]
  Cache --> Left[Layer A view selection]
  Cache --> Right[Layer B view selection]
  Left --> RenderA[Layer A rendering and picking]
  Right --> RenderB[Layer B rendering and picking]
Loading

Reviews (4) · Last reviewed commit: "fix(geo-layers): preserve tile accountin..." · Reviewed by Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1b30186. Configure here.

@ibgreen
ibgreen merged commit 12496f0 into master Nov 5, 2026
5 of 7 checks passed
@ibgreen
ibgreen deleted the ib/shared-tile-layer branch November 5, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants