Skip to content

fix(core): release the WebGL context of a finalized Deck's own device - #11221

Merged
chrisgervang merged 11 commits into
masterfrom
chr/react-release-context-b
Nov 21, 2026
Merged

chrisgervang merged 11 commits into
masterfrom
chr/react-release-context-b

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

For #11220

Background

Deck.finalize() doesn't free the WebGL context of the device Deck created. Browsers cap live contexts per page and drop the oldest, so finalized Decks can push out a live map's context, and the headless tests fail with "WebGL context is lost". luma.gl 10.0.0-beta.1 includes visgl/luma.gl#3791, so a device created with ownsHandle: true releases its context in destroy().

Change List

  • Deck creates its device with ownsHandle: true and destroys it once no Deck renders to the canvas
  • Deck#finalize releases the device when Deck also created the canvas
  • _releaseCanvasContext(deck): releases a passed canvas's context once it leaves the document
  • @deck.gl/react DeckGL and @deck.gl/react/legacy DeckGL call it when they unmount their own canvas
  • An app's device, gl or canvas is never released
  • The renderer's specs run in the headless project again; the temporary test-react-renderer job is removed
  • Unit tests

Generated by Claude Code


Note

Medium Risk
Alters WebGL device teardown and context lifetime management in Deck and React bindings, which could affect applications sharing canvases or managing external WebGL contexts.

Overview
Properly releases the underlying WebGL context and disposes of GPU device wrappers when Deck instances are finalized, preventing WebGL context exhaustion in long-running pages or browser test suites.

A new canvas context reference counting mechanism (release-device-context.ts) tracks active Deck instances rendering to each canvas. When a Deck-created device is finalized and no other instances share the canvas, the device wrapper is destroyed. If Deck owns the canvas or deviceProps.ownsHandle is enabled, the WebGL context itself is released after validating the canvas has been removed from the DOM, accounting for React StrictMode remounts.

Both the modern and legacy React DeckGL components now default to deviceProps.ownsHandle: true on internally managed canvases. Because context leakage is resolved, React renderer specs have been restored to the main headless test run and the temporary standalone CI job was removed.

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

Finalizing a Deck didn't free its WebGL context: Deck creates its device with
`_reuseDevices: true`, so `destroy()` is a no-op, and luma.gl leaves contexts to
garbage collection. Browsers cap live contexts per page and drop the oldest, so
pages that create and finalize Decks can lose a live map's context, and the
headless tests intermittently hit "WebGL context is lost".

- `finalize()` loses the device Deck created when Deck also created the canvas,
  once the device has initialized. Deck removes that canvas, so nothing can
  render to it again.
- `_releaseCanvasContext(deck)` releases a device Deck created on a canvas the
  app passed, one task after `finalize()`, if the canvas has left the document
  and no other Deck renders to it. Components that render their own canvas and
  never reuse it call it on unmount; `@deck.gl/react`'s `DeckGL` now does.
- A `device` or `gl` the app passed is never released.

See #11220 for the options considered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

This PR releases unused Deck-created GPU contexts while preserving contexts still in use. The latest update fixes ownership checks for canvases supplied from an iframe.

  • Deck releases its device context when it removes its own canvas.
  • App-owned canvas contexts are released after React DeckGL unmounts.

All three previous findings are addressed. No new actionable issues found.

Reviews (5) · Last reviewed commit: "fix(core): decide canvas ownership by or..." · Reviewed by Greptile

Comment thread modules/core/src/lib/deck.ts Resolved
Comment thread modules/core/src/lib/deck.ts Resolved
- A Deck given another Deck's `device` or `gl` now counts the canvas it renders
  to, so finalizing the first Deck can't lose a context the second still uses.
- `finalize()` uncounts the canvas once, so finalizing a Deck twice can't drop
  the count of another Deck on the same canvas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
Comment thread modules/core/src/lib/deck.ts Resolved
@coveralls

coveralls commented Nov 19, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.838% (+0.4%) from 82.434% — chr/react-release-context-b into master

When a release is skipped because another Deck still renders to the canvas
(for example one that was passed the device), it now waits on the canvas and
completes when that Deck is finalized, instead of leaving the context to
garbage collection. A passed canvas is checked again for being out of the
document at that point.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
chrisgervang pushed a commit that referenced this pull request Nov 19, 2026
… test patch

Takes the core fix from #11221 (cherry-picked): `finalize()` releases a device
on a canvas Deck created, and `_releaseCanvasContext` releases one on a canvas
the app passed once it leaves the document. The legacy `DeckGL` already calls
it; the renderer's DeckGL root now does too when it unmounts a canvas root.
Map overlays render to Deck's own canvas or the map's context, so they need
nothing extra.

With contexts released at the source, the browser test setup file and the
React specs' per-test helper that patched `getContext` are removed. See #11220.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
@ibgreen

ibgreen commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

For the context release PR, I am not excited about pushing so much into deck.gl.

Would this luma.gl PR help?

visgl/luma.gl#3791

`ownsCanvas` used `instanceof HTMLCanvasElement`, so a canvas from another
window (an iframe) counted as Deck's own and finalize() could lose an app's
context. Deck now owns a canvas only when it created it: its own <canvas>, or
the OffscreenCanvas of multi-canvas mode. A test passes an iframe canvas,
finalizes, and starts a new Deck on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

Copy link
Copy Markdown
Collaborator Author

Yes, it would help. With visgl/luma.gl#3791, deck.gl's part shrinks to:

  • Canvases Deck creates: Deck creates its device with ownsHandle: true and calls device.destroy() in finalize().
  • Canvases React renders: the component owns the device. It creates it, passes it to Deck as device, keeps it across StrictMode remounts, and destroys it once its canvas has been removed. That should let us drop the _releaseCanvasContext export, the canvas counting and the pending-release bookkeeping here.

I ran deck.gl's headless suite against #3791 with this PR's release switched to ownsHandle: true and destroy(): all 313 files pass and no context is lost. Without the opt-in, 316 tests still fail. I'll rework this PR on top of #3791 once it's in a luma.gl release. Until then, #11183 keeps the current commits so its browser tests stay green.


Generated by Claude Code

chrisgervang pushed a commit that referenced this pull request Nov 19, 2026
Finalized Decks don't release their WebGL context yet. In the shared headless
page, master's specs leave 14 contexts open, two short of Chromium's limit; the
renderer's specs add more and reach it, and the test device is then lost for
every later file (266 failures in CI on #11245). Until #11221 releases those
contexts, the headless project excludes `test/modules/react/fiber/**/*.spec.*`,
so it runs the same files as master; they still run in the `browser` project.
The renderer's jsdom tests still run in the `react` project.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
chrisgervang pushed a commit that referenced this pull request Nov 19, 2026


The renderer's `*.spec.*` files are excluded from the shared headless page
until #11221 releases WebGL contexts, so neither `test-coverage` nor
`test-webgpu` runs them. A new `test-react-renderer` job runs them in the
`browser` project under Xvfb, in a Chromium of their own (Ib on #11246).
Locally: 21 files, 224 tests pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-visgl__deck.gl that referenced this pull request Nov 19, 2026
….gl/react (visgl#11245)

* feat(react): copy the fiber renderer from deck.gl-community

Copies `modules/react-fiber/src` from visgl/deck.gl-community at 090b2439
(v10.0.0-alpha.3) byte for byte. Source files keep their path under
`modules/react/src`. Tests move out of `src/**/__tests__` into
`test/modules/react/fiber`, keeping their names except that browser tests
(`*.browser.test.tsx`) and the reconciler and shared tests become `*.spec.*`
files for the headless project.

This commit does not build on its own: the next commit makes the mechanical
edits (license headers, the package name and import paths), and the one after
switches the package root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* chore(react): make the copied renderer's mechanical edits

No behavior changes:

- Each copied file gets the deck.gl license header with the Deckgl Fiber
  Renderer copyright line, as agreed in visgl#11036.
- `@deck.gl-community/react-fiber` becomes `@deck.gl/react`, in doc comments,
  `RENDERER_PACKAGE_NAME` and the DevTools test.
- Test imports of the module (`../config`, `../../dom/mapbox`, ...) now name
  `@deck.gl/react/<path>`, and imports of test helpers point at their new
  location. The entry points test reads `modules/react/package.json`, and the
  tree-shaking test bundles from `modules/react/src/wrappers`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* style(react): format the two tests whose import paths grew

Biome, after the previous commit lengthened their import paths. No other change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* feat(react)!: make the copied renderer the @deck.gl/react root

BREAKING CHANGE: `@deck.gl/react` now exports the React Fiber renderer. The
previous API stays available at `@deck.gl/react/legacy`.

The packaging follows visgl#11036:

- `package.json` exports the renderer's subpaths (`/mapbox`, `/maplibre`,
  `/google-maps`, `/core`, `/layers`, `/geo-layers`, `/aggregation-layers`,
  `/mesh-layers`, `/widgets`, `/reconciler`) next to `/legacy`, with
  `react-reconciler`, `its-fine` and `client-only` as dependencies and React
  `^19.2.0` peers. `build-cjs.mjs` already shares any entry, so it needs no
  change.
- `LICENSE` and the README credit the Deck.gl Fiber Renderer.
- A `react` vitest project runs the jsdom unit and type tests, with the
  `clearMocks` and `reportError` setup the deck.gl-community config used. The
  headless project also runs `*.spec.tsx`.
- The legacy tests import `@deck.gl/react/legacy`, and the test that the root
  re-exported `/legacy` is removed.
- The website, which runs React 18, resolves the bare root to `/legacy`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): skip four copied tests until the follow-up adapts them

Each one checks something that differs in deck.gl, not in the copied code:

- entrypoints: deck.gl's package also exports `./legacy` and requires
  `@deck.gl/widgets` for it.
- wrappers: deck.gl master added `_ColorScaleWidget`, which has no wrapper yet.
- devtools: the headless project shares one page, so an earlier file has already
  loaded the renderer when this test imports it.
- utils: "false in Node.js" runs in Chromium in the headless project.

Each skip has a comment saying why. The follow-up PR re-enables them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): run the renderer's specs outside headless until visgl#11221

Finalized Decks don't release their WebGL context yet. In the shared headless
page, master's specs leave 14 contexts open, two short of Chromium's limit; the
renderer's specs add more and reach it, and the test device is then lost for
every later file (266 failures in CI on visgl#11245). Until visgl#11221 releases those
contexts, the headless project excludes `test/modules/react/fiber/**/*.spec.*`,
so it runs the same files as master; they still run in the `browser` project.
The renderer's jsdom tests still run in the `react` project.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

---------

Co-authored-by: Claude <[email protected]>
Awake999 pushed a commit to Awake999/deck.gl that referenced this pull request Nov 20, 2026
…sgl#11246)

* feat(react): copy the fiber renderer from deck.gl-community

Copies `modules/react-fiber/src` from visgl/deck.gl-community at 090b2439
(v10.0.0-alpha.3) byte for byte. Source files keep their path under
`modules/react/src`. Tests move out of `src/**/__tests__` into
`test/modules/react/fiber`, keeping their names except that browser tests
(`*.browser.test.tsx`) and the reconciler and shared tests become `*.spec.*`
files for the headless project.

This commit does not build on its own: the next commit makes the mechanical
edits (license headers, the package name and import paths), and the one after
switches the package root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* chore(react): make the copied renderer's mechanical edits

No behavior changes:

- Each copied file gets the deck.gl license header with the Deckgl Fiber
  Renderer copyright line, as agreed in visgl#11036.
- `@deck.gl-community/react-fiber` becomes `@deck.gl/react`, in doc comments,
  `RENDERER_PACKAGE_NAME` and the DevTools test.
- Test imports of the module (`../config`, `../../dom/mapbox`, ...) now name
  `@deck.gl/react/<path>`, and imports of test helpers point at their new
  location. The entry points test reads `modules/react/package.json`, and the
  tree-shaking test bundles from `modules/react/src/wrappers`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* style(react): format the two tests whose import paths grew

Biome, after the previous commit lengthened their import paths. No other change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* feat(react)!: make the copied renderer the @deck.gl/react root

BREAKING CHANGE: `@deck.gl/react` now exports the React Fiber renderer. The
previous API stays available at `@deck.gl/react/legacy`.

The packaging follows visgl#11036:

- `package.json` exports the renderer's subpaths (`/mapbox`, `/maplibre`,
  `/google-maps`, `/core`, `/layers`, `/geo-layers`, `/aggregation-layers`,
  `/mesh-layers`, `/widgets`, `/reconciler`) next to `/legacy`, with
  `react-reconciler`, `its-fine` and `client-only` as dependencies and React
  `^19.2.0` peers. `build-cjs.mjs` already shares any entry, so it needs no
  change.
- `LICENSE` and the README credit the Deck.gl Fiber Renderer.
- A `react` vitest project runs the jsdom unit and type tests, with the
  `clearMocks` and `reportError` setup the deck.gl-community config used. The
  headless project also runs `*.spec.tsx`.
- The legacy tests import `@deck.gl/react/legacy`, and the test that the root
  re-exported `/legacy` is removed.
- The website, which runs React 18, resolves the bare root to `/legacy`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): skip four copied tests until the follow-up adapts them

Each one checks something that differs in deck.gl, not in the copied code:

- entrypoints: deck.gl's package also exports `./legacy` and requires
  `@deck.gl/widgets` for it.
- wrappers: deck.gl master added `_ColorScaleWidget`, which has no wrapper yet.
- devtools: the headless project shares one page, so an earlier file has already
  loaded the renderer when this test imports it.
- utils: "false in Node.js" runs in Chromium in the headless project.

Each skip has a comment saying why. The follow-up PR re-enables them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): apply the deck.gl review of the copied renderer

The changes made while visgl#11182 and visgl#11183 were reviewed, on top of the copy:

- Re-suspended content is hidden: `cloneHiddenInstance` marks its copy, and the
  tree flattening skips hidden instances (Greptile on visgl#11182).
- Updates without an explicit priority use the live event priority, so a click
  is discrete (Greptile on visgl#11182).
- `unmountAtNode` commits the unmount before it finalizes Deck, so effect
  cleanups still see it (Bugbot on visgl#11182).
- The DOM root imports the reconciler, and the map roots the root component,
  through their entries, so each CommonJS bundle requires one copy of the
  renderer instead of inlining it (Ib on visgl#11183). `/reconciler` exports the
  error boundary as `_RootErrorBoundary` for that.
- `_ColorScaleWidget`, added to `@deck.gl/widgets` on master, gets a wrapper.
- DevTools registration is a function, `registerWithDevTools`, so a test can
  call it in the headless project's shared page.
- TSDoc on the internal declarations (Greptile on visgl#11182).

Tests: the four tests the copy skipped are adapted and re-enabled; new tests
cover each fix above, the CommonJS entries and the peer versions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* fix(react): finish unmounting when an app callback throws during teardown

From Greptile's review of visgl#11245:

- The DOM root's layout cleanup detaches the overlay and calls `onDeckChange(null)`
  first. If either throws (an `onDeckChange`, a ref cleanup or a custom detach),
  the cleanup now still clears the overlay and unmounts the root, so Deck does
  not keep running. A test throws from `onDeckChange(null)` and checks the root
  is unmounted; it fails without the change.
- Each wrapper component in `/core`, `/layers`, `/geo-layers`,
  `/aggregation-layers`, `/mesh-layers` and `/widgets` gets a one-line TSDoc
  comment, as `AGENTS.md` asks.
- `flattenTree` and `organizeList` name their variables (`roots`, `instance`,
  `descriptors`, `node`) instead of `arr`, `val`, `acc` and `curr`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): run the renderer's specs outside headless until visgl#11221

Finalized Decks don't release their WebGL context yet. In the shared headless
page, master's specs leave 14 contexts open, two short of Chromium's limit; the
renderer's specs add more and reach it, and the test device is then lost for
every later file (266 failures in CI on visgl#11245). Until visgl#11221 releases those
contexts, the headless project excludes `test/modules/react/fiber/**/*.spec.*`,
so it runs the same files as master; they still run in the `browser` project.
The renderer's jsdom tests still run in the `react` project.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* chore(react): credit the Deckgl Fiber Renderer only on files adapted from it

visgl#11245 added the "Deckgl Fiber Renderer contributors" copyright line to every
copied file. visgl#11036 puts it only on files adapted from the Deck.gl Fiber
Renderer at 9e348b6. These 48 files were written later in deck.gl-community and
have no counterpart there (the map roots, `deck-canvas`, `attach-*`, the error
boundary, the shared hooks, the wrappers and their tests), so the line is
removed. Files adapted from the renderer keep it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): check that re-suspended content comes back once it resolves

The Suspense test stopped once the fallback showed, with a promise that never
resolved, so it would pass even if hidden content never returned. It now
resolves the promise and checks that the content is back and the fallback gone
(Greptile on visgl#11246).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* style(react): make the CommonJS import comments inline

The DOM root and the three map roots explained, in a comment above the import,
why they import through an entry file. Each is now a short comment on the
import line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* style(react): drop the comments on the map roots' entry imports

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* ci: run the React renderer's browser specs in their own job until visgl#11221

The renderer's `*.spec.*` files are excluded from the shared headless page
until visgl#11221 releases WebGL contexts, so neither `test-coverage` nor
`test-webgpu` runs them. A new `test-react-renderer` job runs them in the
`browser` project under Xvfb, in a Chromium of their own (Ib on visgl#11246).
Locally: 21 files, 224 tests pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* test(react): check isBrowserEnvironment in Node.js and jsdom again

fiber.gl covered both environments: `utils.test.ts` ran in Node.js and checked
`isBrowserEnvironment` is false, `utils-browser.test.ts` ran in jsdom and checked
it is true. As `*.spec.ts` files they ran in the headless Chromium, which ignores
`@vitest-environment`, so the Node.js check had become a second browser check.
Both are `*.test.ts` files in the `react` project again, with their environment
docblocks, as `dom/ssr.test.ts` already is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

* style(react): drop the comment on the DOM root's reconciler import

`cjs-entries.node.spec.ts` already fails if the import stops going through the
`/reconciler` entry, so the comment is not needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

---------

Co-authored-by: Claude <[email protected]>

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

Your trial has ended. Reactivate Greptile to resume code reviews.

luma.gl 10.0.0-beta.1 includes visgl/luma.gl#3791: a device created with
ownsHandle: true releases its WebGL context in destroy(), even with
_reuseDevices. Deck now creates its device that way and destroys it once no
Deck renders to the canvas, instead of calling loseDevice() directly. destroy()
also detaches the device from the context and tears down its canvas context.

The renderer's DeckGL in @deck.gl/react now releases the context of the
<canvas> it rendered when it unmounts, as the legacy DeckGL does. A canvas the
app passes, and map overlays, are left alone. The React test covers both
components.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

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

Your trial has ended. Reactivate Greptile to resume code reviews.

With finalized Decks releasing their contexts, the renderer's browser specs no
longer push the shared headless page past Chromium's context limit. They run in
the headless project again, and the temporary test-react-renderer job that ran
them in their own Chromium is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

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

One ownership edge in the canvas-only device reuse path.

Comment thread modules/core/src/lib/deck.ts Resolved

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

Your trial has ended. Reactivate Greptile to resume code reviews.

With _reuseDevices, luma.gl returns the device already on a canvas, which can be
one the app created, with ownsHandle: true. Deck recorded it as its own, so
_releaseCanvasContext could destroy the app's device and its context.

Deck now marks the devices it creates with a _createdByDeck prop. luma.gl keeps
a device's props, so the mark survives when another Deck reuses the device, and
an app's device never has it. Deck records ownership only of a marked device.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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

Chris, I added two commits to this branch. The resulting teardown goes through one path in Deck.finalize(). Both React entry points declare ownership when they create the canvas, so they can use the same finalization path as standalone Deck. This removes the separate _releaseCanvasContext export and both React cleanup calls.

For the observer leak in #10356, luma.gl 10.0.0-beta.1 handles observer cleanup in device.destroy(). A Deck-created wrapper on an app-supplied WebGL canvas uses ownsHandle: false by default, so destroying the wrapper leaves the native context available for reattachment. Deck waits for other Decks using the canvas and preserves devices supplied by the app. A React-owned canvas can release its context after it leaves the document, including through StrictMode effect replay.

I reviewed the updated lifecycle paths. Lint and 21 focused Chromium tests passed, including reattachment, shared devices, and both React entry points.

@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 1 potential issue.

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 05dce44. Configure here.

setTimeout(destroy, 0);
} else {
destroy();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shared canvas teardown dropped while attached

Medium Severity

destroyCreatedDevice returns immediately when a supplied WebGL canvas is still in the document, before registering a teardown. A Deck that borrowed that device never records _createdDevice, so once the owner has finalized, later finalize() calls have nothing left to destroy. If the canvas is then removed while a borrower is still rendering, or the borrower finalizes after the canvas has left the document, the context is leaked. That undercuts the last-Deck release path this change is meant to provide, and leftover contexts can still push a live map past the browser cap.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 05dce44. Configure here.

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.

Generated by Claude Code


Traced against 05dce44:

  • A Deck that reuses a device another Deck created does record it. _createDevice keeps a device marked _createdByDeck, which every Deck-created device is, so the last such Deck destroys it at its own finalize(). That covers the StrictMode remount. Only a device the app created resolves to null, and that stays the app's.
  • The remaining gap is narrower. The removal check runs once, one task after finalize(). React removes the canvas in the same commit as the unmount, so a normal unmount passes. A canvas that stays in the document past that task with no Deck on it, as under <Activity mode="hidden">, and is removed later, is not released. The previous _releaseCanvasContext had the same one-time check.

Leaving this open for a decision on whether that case needs handling here.


Generated by Claude Code

@ibgreen ibgreen added the bug label Nov 21, 2026
@chrisgervang
chrisgervang merged commit cf6dcaa into master Nov 21, 2026
8 checks passed
@chrisgervang
chrisgervang deleted the chr/react-release-context-b branch November 21, 2026 16:24
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.

4 participants