Skip to content

Support caller-owned projection engines in Deck - #11112

Open
ibgreen wants to merge 2 commits into
codex/prepared-crsfrom
codex/projection-engine
Open

ibgreen wants to merge 2 commits into
codex/prepared-crsfrom
codex/projection-engine

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Requires #11106

Background

Deck resolves custom-view and layer-source CRS definitions through a module-global math.gl engine. Applications cannot select their own registered algorithms, grids or backend consistently. Add Deck({projectionEngine}), defaulting to the existing math.gl engine, so definitions resolve through a caller-owned factory while prepared descriptors remain an explicit bypass.

The contract is math.gl's CRSEngine (getCRS, createProjection, createProjectionAsync), because rendering requires descriptor metadata as well as point transforms. Keep engine configuration immutable while in use; replace the object to change execution. null restores the default. Deck never mutates or disposes the factory. Built-in coordinate aliases and MapView/GlobeView camera models retain their existing semantics.

Change List

  • Expose the selected engine through Deck and layer context
  • Scope resolved CRS caches and execution keys by engine
  • Refresh source conversions and custom views on engine replacement
  • Isolate custom-view initialization between Deck instances
  • Ignore obsolete view/source results after replacement
  • Preserve prepared-descriptor passthrough from Support prepared CRS descriptors in CustomProjectionView #11106
  • Unit tests cover defaults, replacement, isolation, errors and ownership
  • Documentation explains configuration, lifecycle and built-in coordinate semantics

Verified: full package build, lint, 75 focused browser tests and 123 Node tests pass. Final-head CI passes coverage, WebGPU, website, Python and projection-example checks. Greptile and Bugbot pass; Codex review is unavailable due to account quota.

#11030 owns typed bitmap mesh inputs; #11031 owns image-to-position CRS mapping. This PR exposes layer.context.projectionEngine and marks projectionChanged when it changes. #11031 should consume that engine with createProjectionAsync during mesh preparation and rebuild generated UVs on replacement instead of importing the global engine. Its existing mesh/version guard can reject stale output. This core PR does not duplicate the still-unmerged BitmapLayer implementation. Merge order: #11106, this PR; integrate the context service into #11031 on top of #11030.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T05:20:21.221255Z
We couldn’t complete this review. Comment @codex review to try again.
8e00889 PR opened
ℹ️ 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 14, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous view-refresh issue is fixed.

Summary

Adds caller-owned projection engines to Deck, with engine-specific CRS caches and refreshed views and layer conversions on replacement.

  • Custom projection views resolve CRS definitions through Deck’s selected engine.
  • Layers use Deck’s selected engine to resolve source coordinate systems.

Reviews (2) · Last reviewed commit: "Reinitialize application views when proj..." · Reviewed by Greptile

Comment thread modules/core/src/lib/view-manager.ts Resolved
@coveralls

coveralls commented Nov 14, 2026 •

Copy link
Copy Markdown

Coverage Status

Coverage is 83.405% — codex/projection-engine into codex/prepared-crs. No base build found for codex/prepared-crs.

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

Thank you. The per-engine caches and the generation guard for replaced engines look solid. The tests cover replacement and isolation well. The focused specs pass for me (45 tests). I found one bug and one API question.

  1. Built-in OSMTile512 fails with an injected engine. Only the default engine's cache contains WGS84_CRS, GLOBE_CRS and OSM_TILE_CRS (utils/crs.ts:107). The alias switch does not handle 'OSMTile512'. MVTLayer uses this string as its coordinateSystem. In a CustomProjectionView, or in a second view, the string goes to engine.getCRS. Results from a headless probe at this head:

    • With the default engine, resolveCRS('OSMTile512') returns OSM_TILE_CRS.
    • With createProjectionEngine({projections: [equalEarth]}), it rejects with "Unsupported CRS definition: OSMTile512; resolve it first".
    • With the same engine, GLOBE_CRS.signature rejects with "Projection plugin is not registered: geocent".
    • A LayerManager with a CustomProjectionViewport and a layer with coordinateSystem: 'OSMTile512' loads with the default engine. With the injected engine, onError gets "loading coordinateSystem: Unsupported CRS definition: OSMTile512; resolve it first", and the layer does not load.

    This contradicts deck.md: "Built-in geographic/Cartesian aliases ... retain their existing semantics." Please check the three built-ins before the per-engine cache, or seed each engine map with them. Please also add a test with an injected engine and coordinateSystem: 'OSMTile512'.

  2. Deck now holds clones of the caller's views. _setViews clones each CustomProjectionView, and it clones all views when the engine changes. In a probe, getView('main') === myView is false. Deck initializes only the clone, so myView.makeViewport(...) returns null. Before this PR, Deck initialized the caller's object. Also, View.clone() calls new constructor({...props}), so a subclass loses state that is not in props. The clone isolates a view that two Deck instances share with different engines. That case is rare, but the cost applies to all users. Could CustomProjectionView keep its state per engine, for example in a WeakMap<CRSEngine, ...>? Then Deck can keep the caller's object. If you prefer the clone, please document that getView() returns an internal copy.

Small items:

  • A layer whose coordinateSystem equals a prepared view descriptor's signature uses that descriptor and does not call the engine (layer-manager.ts:508). I think that this is correct. One sentence in deck.md would make it explicit.
  • LayerContext.projectionEngine is required in an exported type. Code that builds a LayerContext by hand gets a type error. Consider making it optional, or note it in whats-new.md.

}
let resolvedCRS = engineCaches.get(engine);
if (!resolvedCRS) {
resolvedCRS = engine === defaultProjectionEngine ? defaultResolvedCRS : new Map();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An injected engine starts with an empty map. So 'OSMTile512' (used by MVTLayer) and GLOBE_CRS.signature go to engine.getCRS and fail. Please check the built-ins first, or seed this map with the same three entries as defaultResolvedCRS.

? previous
: view;
: engineChanged || view instanceof CustomProjectionView
? view.clone({})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With this clone, deck.getView(id) returns a copy. The caller's view also stays uninitialized, so makeViewport() on it returns null. Could the view keep per-engine state instead?


export type LayerContext = {
/** Caller-owned CRS and transform factory selected by Deck. */
projectionEngine: CRSEngine;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

projectionEngine is required in the exported LayerContext type. Code that builds a context by hand gets a type error. Please make it optional, or note it in whats-new.md.

`getCRS` is not sufficient for geographic views.

Custom projection views and layer source `coordinateSystem` definitions use this
engine. Prepared view descriptors bypass resolution. Built-in geographic/Cartesian

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggest: "Layers whose coordinateSystem equals a prepared descriptor's signature also use that descriptor."

@athomct

athomct commented Nov 24, 2026

Copy link
Copy Markdown

This is a reminder about my review of 16 November. The four inline threads above have no answer yet:

  • utils/crs.ts:107 (bug): an injected engine cannot resolve 'OSMTile512' or GLOBE_CRS.signature. So MVTLayer does not load in a CustomProjectionView. Check the built-ins before the per-engine cache, or seed each engine map with them.
  • view-manager.ts:430: Deck clones the caller's views, so getView() returns a copy. Can the view keep its state for each engine instead?
  • layer-manager.ts:35: make projectionEngine optional in LayerContext, or note the type change in whats-new.md.
  • deck.md:291: add one sentence about layers whose coordinateSystem equals a prepared descriptor's signature.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants