Skip to content

RFC/POC: Extend View system to support multi-canvas rendering#10229

Open
ibgreen wants to merge 14 commits into
masterfrom
ib/multi-canvas-rfc
Open

RFC/POC: Extend View system to support multi-canvas rendering#10229
ibgreen wants to merge 14 commits into
masterfrom
ib/multi-canvas-rfc

Conversation

@ibgreen

@ibgreen ibgreen commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator
image

RFC: Multi-Canvas Presentation for deck.gl

  • Status: Draft
  • Authors: deck.gl contributors
  • Target release: TBD
  • Related:

Summary

Add a multi-canvas presentation mode to deck.gl built on luma.gl 9.3 PresentationContexts.

The proposal adds:

  • DeckProps.canvases?: (string | HTMLCanvasElement)[]
  • View.canvasId?: string

When canvases is defined, deck.gl creates or uses an offscreen-backed default device canvas and presents rendered output into one or more DOM canvases. Views are assigned to canvases by canvasId. Each canvas gets its own PresentationContext, event handling root, and controller binding.

This enables a single Deck instance to render multiple independently interactive views into separate canvases on a normal web page, while keeping React basemaps and other View children bound to the correct view and canvas.

A proof-of-concept app demonstrates four independently navigable city maps on one page, each with its own basemap, controller, and filtered data.

Motivation

deck.gl today assumes a single presentation surface. This makes certain layouts awkward or impossible without creating multiple Deck instances:

  • editorial pages with maps embedded between text
  • small multiples with independent interaction
  • dashboards that mix multiple maps and normal DOM content
  • layouts where each map panel needs its own basemap and DOM subtree

Creating multiple Deck instances works, but it duplicates GPU state, layer setup, animation loops, and application plumbing. luma.gl 9.3 introduces the missing primitive: one device can present to multiple canvases through multiple PresentationContexts.

This RFC proposes a deck.gl integration that:

  • preserves a single Deck and single layer graph
  • allows view-level routing to presentation canvases
  • keeps basemaps view-bound rather than introducing a separate map-to-canvas API

Goals

  • Support multiple presentation canvases from one Deck instance.
  • Assign views to canvases with a small extension to the existing View model.
  • Keep React View children, including basemaps, colocated with the correct canvas.
  • Support dynamic updates to the canvases prop, including add/remove/reorder.
  • Support independent controllers per canvas/view.
  • Keep picking and event routing scoped to the source canvas.
  • Preserve current single-canvas behavior when canvases is not supplied.

Non-Goals

  • Changing non-React overlay integrations in v1:
    • @deck.gl/mapbox
    • @deck.gl/google-maps
    • @deck.gl/arcgis
  • Adding a separate basemap-to-canvas API.
  • Supporting multi-canvas with externally supplied non-offscreen WebGL contexts.
  • Replacing the existing single-canvas API.

Background

luma.gl 9.3 supports multiple PresentationContexts per device. deck.gl can use this by separating:

  1. the device's default rendering surface, which becomes offscreen in multi-canvas mode
  2. the presentation surfaces, one per DOM canvas
  3. the deck.gl view graph, which decides which views render into which presentation target

This RFC treats canvas assignment as a property of a View, not of a layer or basemap. That keeps the model consistent:

  • View.id binds child content to the view
  • View.canvasId binds the view to a presentation canvas

Proposal

Public API

DeckProps.canvases

canvases?: (string | HTMLCanvasElement)[];

@ibgreen ibgreen changed the title Ib/multi canvas rfc feat(core) Extend View system to support multi-canvas rendering Apr 16, 2026
@ibgreen ibgreen changed the title feat(core) Extend View system to support multi-canvas rendering RFC/POC: Extend View system to support multi-canvas rendering Apr 16, 2026
@ibgreen
ibgreen requested a review from heshan0131 April 16, 2026 18:05

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72fa41c755

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread modules/core/src/lib/deck.ts Outdated
Comment on lines +1761 to +1762
if (!canvasViewports.length) {
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear canvases when no views render to them

When running in multi-canvas mode, canvases with zero mapped viewports are skipped via continue, so they are never rendered or presented again. If a view is removed or reassigned to another canvas at runtime, the old frame remains visible indefinitely on the now-unused canvas, producing stale content during dynamic layout/view updates.

Useful? React with 👍 / 👎.

@ibgreen ibgreen mentioned this pull request May 2, 2026
59 tasks
@ibgreen-openai
ibgreen-openai force-pushed the ib/multi-canvas-rfc branch 2 times, most recently from 79b90e5 to 8ba7afe Compare June 12, 2026 16:53
@ibgreen-openai
ibgreen-openai changed the base branch from master to ib/multi-canvas-event-manager-prep June 12, 2026 17:02
@coveralls

coveralls commented Jun 12, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 83.248% (+0.08%) from 83.17% — ib/multi-canvas-rfc into master

@Pessimistress Pessimistress left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Did you test widgets at all? I did not see any changes to the widget manager on placement handling w/ multiple canvases.

  • I strongly recommend that you exclude react from the initial PR. The implementation looks very hacky and not conforming to reactive patterns. And this is adding on top of existing complex React flow with known bugs.

Comment thread docs/api-reference/core/deck.md Outdated
Comment thread docs/api-reference/core/deck.md Outdated
Comment thread docs/api-reference/react/deckgl.md Outdated
Comment thread docs/developer-guide/views.md Outdated
new MapView({id: 'tokyo', canvasId: 'canvas-tokyo', controller: true})
];

<DeckGL canvases={['canvas-london', 'canvas-tokyo']} views={views} layers={layers}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use a non-react example here? DeckGL react component creates the canvas, so what are the canvas ids in this case?

Comment thread modules/core/src/lib/canvas-manager.ts Outdated
});
}

private _getCanvasEventRoot(canvas: HTMLCanvasElement): HTMLElement {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Deck currently has an option to customize the event root by class name, this seems to be breaking the use case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Deck currently has an option to customize the event root by class name, this seems to be breaking the use case.

I had codex address this comment, could use another look.

Comment thread modules/core/src/lib/widget-manager.ts Outdated
Comment thread modules/react/src/deckgl.ts Outdated
@ibgreen-openai
ibgreen-openai force-pushed the ib/multi-canvas-event-manager-prep branch from 85cee04 to ff8fefb Compare June 15, 2026 16:43
Base automatically changed from ib/multi-canvas-event-manager-prep to master June 25, 2026 13:38
@chrisgervang chrisgervang added this to the v9.4 milestone Jun 29, 2026
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