Skip to content

refactor(core): honor canvas contexts throughout render passes - #10474

Merged
ibgreen merged 3 commits into
masterfrom
codex/multi-canvas-context-plumbing
Jul 27, 2026
Merged

ibgreen merged 3 commits into
masterfrom
codex/multi-canvas-context-plumbing

Conversation

@ibgreen-openai

@ibgreen-openai ibgreen-openai commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Goal

Make rendering, picking, and viewport layout consistently honor the active luma canvas context while preserving existing single-canvas behavior.

Changes

  • Accept CanvasContext or PresentationContext in internal rendering and picking options.
  • Propagate the selected context through synchronous/asynchronous point and rectangle picking, including the picking render pass.
  • Derive framebuffer dimensions, viewport coordinates, device-pixel ratio, and post-processing buffer sizes from the selected context.
  • Ensure per-view clear passes and final post-processing output use the selected canvas framebuffer.
  • Include the already-merged refactor(core): size and filter viewports by canvas #10475 viewport-layout preparation: read each view’s CSS dimensions directly from its existing canvas context, avoiding a separate canvas-size map or duplicated resize bookkeeping.
  • Support canvas-only and canvas-plus-pixel viewport filters, with inline documentation explaining why both canvas identity and pixel containment are checked.
  • Add focused regression coverage for canvas-aware picking, rendering, clear passes, post-processing output, and independent per-canvas viewport layout.

Review scope

Ten core source/test files. No new public Deck multi-canvas props, canvas lifecycle ownership, widgets, or application examples; omitted contexts preserve existing defaults.

Validation

  • Rebased onto current master (dd9b4047d6).
  • ./node_modules/.bin/tsc -p modules/core/tsconfig.json --noEmit --pretty false
  • yarn lint — passed; existing repository lint warnings remain.
  • Focused headless browser regressions: 70 tests passed across 7 files.
  • Downstream stacked feature regressions: 90 tests passed across 9 files.

Stack

  1. This PR contains context-aware rendering/picking plus the already-merged refactor(core): size and filter viewports by canvas #10475 canvas-aware viewport-layout preparation.
  2. RFC/POC: Extend View system to support multi-canvas rendering #10229 builds the multi-canvas presentation and interaction feature on top.

@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: 99c2cbfdc2

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


protected _render(options: LayersPassRenderOptions): RenderStats[] {
const canvasContext = this.device.canvasContext!;
const {canvasContext = this.device.canvasContext!} = options;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Clear views on the selected canvas framebuffer

When canvasContext is a non-default presentation context and a View has clear enabled, _render resolves that context's framebuffer here, but _drawLayers still forwards only the original target (typically null or undefined) and _drawLayersInViewport opens its clear pass with framebuffer: target. The clear consequently runs against the device's default canvas rather than the framebuffer used by the outer render pass, leaving stale color/depth in the selected canvas and potentially clearing another canvas; pass the resolved framebuffer into the per-view clear.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in 0309acd. LayersPass._render now forwards its resolved framebuffer into _drawLayers, so every per-view clear pass uses the same selected-canvas framebuffer even when the original target was null or undefined.

Regression coverage: LayersPass#uses the supplied canvas context for viewport and clear passes spies on both render-pass creations and asserts that both receive the selected framebuffer. Revalidated with 14 affected rendering/picking tests passing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Rebased onto current master; the fix remains in rebased commit 18ee6a7ae1. The selected-canvas clear regression still passes, along with the complete 70-test rendering, picking, and viewport-layout suite.


if (this.lastPostProcessEffect) {
this._resizeRenderBuffers();
this._resizeRenderBuffers(opts.canvasContext);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve post-process output against the selected canvas

When a non-default canvasContext is rendered with a built-in PostProcessEffect and the canvas target is null, this only sizes the intermediate buffers from the selected context. _postRender still gives the final effect opts.target, so PostProcessEffect/ScreenPass starts its final pass with a null framebuffer, which selects the device's default canvas rather than canvasContext.getCurrentFramebuffer(); the selected canvas receives no composited output while the default canvas is overwritten.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in 0309acd. DeckRenderer._postRender now resolves the final output as opts.target ?? opts.canvasContext?.getCurrentFramebuffer() ?? opts.target, so the last post-processing effect renders to the selected canvas while preserving existing default-canvas behavior when no alternate context is supplied.

Regression coverage: DeckRenderer#post processing renders to the supplied canvas framebuffer exercises a two-effect chain and verifies the intermediate effect receives no target while the final effect receives the selected framebuffer. Revalidated with 14 affected rendering/picking tests passing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Rebased onto current master; the fix remains in rebased commit 18ee6a7ae1. The two-effect regression still confirms that only the final effect targets the selected canvas framebuffer; all 70 rendering, picking, and viewport-layout tests pass.

@coveralls

coveralls commented Jul 23, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.297% (+0.01%) from 83.287% — codex/multi-canvas-context-plumbing into master

@ibgreen-openai
ibgreen-openai force-pushed the codex/multi-canvas-context-plumbing branch from 05f8f9f to c15183d Compare July 27, 2026 18:29
@ibgreen
ibgreen merged commit cce6552 into master Jul 27, 2026
5 checks passed
@ibgreen
ibgreen deleted the codex/multi-canvas-context-plumbing branch July 27, 2026 18:39
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.

4 participants