Skip to content

fix(react): apply the deck.gl review of the copied fiber renderer - #11246

Merged
chrisgervang merged 19 commits into
masterfrom
chr/react-fiber-review
Nov 20, 2026
Merged

chrisgervang merged 19 commits into
masterfrom
chr/react-fiber-review

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #11245. For #11036

Background

The changes made while #11182 and #11183 were reviewed, applied on top of the unchanged copy in #11245. The context release from #11183 is not included; it is its own work stream in #11221.

Change List

  • cloneHiddenInstance: hide re-suspended content
  • resolveUpdatePriority: use the live event priority
  • unmountAtNode: commit the unmount before finalizing Deck
  • DOM and map roots: import through entries, one CommonJS copy each
  • /reconciler: export _RootErrorBoundary for the DOM root
  • _ColorScaleWidget: add the wrapper
  • registerWithDevTools: export the DevTools registration
  • TSDoc on internal declarations
  • DOM root teardown: unmount even when an app callback throws
  • TSDoc on each wrapper component; descriptive names in flattenTree and organizeList
  • Re-enable the four tests feat(react)!: copy the fiber renderer from deck.gl-community as @deck.gl/react #11245 skipped
  • Unit tests for each fix, the CommonJS entries and peer versions

Verified locally: yarn test-fast (lint, node and react projects, 51 files) and the renderer's headless specs run on their own (21 files).


Note

Low Risk
Changes are localized to @deck.gl/react reconciler lifecycle handling, package bundling, and tests without affecting core deck.gl rendering.

Overview
Applies follow-up refinements and lifecycle fixes to the React Fiber renderer in @deck.gl/react.

Key reconciler updates include marking suspended instances as hidden so Suspense fallbacks exclude re-suspended layers, querying live event priorities via getCurrentEventPriority, and synchronously flushing unmount work before finalizing Deck. Component teardown in DeckGL is hardened with a try/finally block so roots still unmount cleanly if consumer callbacks throw.

Additionally, this adds a component wrapper for _ColorScaleWidget, routes map overlay imports through common entry points to prevent module duplication in CommonJS builds, and adds comprehensive tests covering bundle structure, React peer dependency compatibility, and unmount ordering alongside a dedicated CI job for React renderer browser specs.

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


Generated by Claude Code

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
No behavior changes:

- Each copied file gets the deck.gl license header with the Deckgl Fiber
  Renderer copyright line, as agreed in #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
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
BREAKING CHANGE: `@deck.gl/react` now exports the React Fiber renderer. The
previous API stays available at `@deck.gl/react/legacy`.

The packaging follows #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
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
The changes made while #11182 and #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 #11182).
- Updates without an explicit priority use the live event priority, so a click
  is discrete (Greptile on #11182).
- `unmountAtNode` commits the unmount before it finalizes Deck, so effect
  cleanups still see it (Bugbot on #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 #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 #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
…down

From Greptile's review of #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
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
@coveralls

coveralls commented Nov 19, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.519% (+0.08%) from 82.441% — chr/react-fiber-review into master

Base automatically changed from chr/react-fiber-copy to master November 19, 2026 21:05
#11245 was squash-merged, so its copied files arrive on master as new files and
every file this branch changed conflicts. Each conflict keeps this branch's
version, which is the copy plus the review changes; `setup.ts` and the two
`react` project settings that used it stay removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
@chrisgervang
chrisgervang requested a review from ibgreen November 19, 2026 21:18
@chrisgervang
chrisgervang marked this pull request as ready for review November 19, 2026 21:18
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes since the previous review appear safe to merge.

Summary

This PR improves the React renderer’s Suspense behavior, cleanup order, and CommonJS imports, and expands its tests.

  • Suspended content stays out of deck.gl until it can return.
  • React cleanup finishes before the Deck instance is finalized.
  • DOM and map roots share the renderer's package entrypoints.
  • React updates use the priority of the active browser event.
  • React apps can render the Color Scale widget as a component.
  • React renderer browser specs run in their own CI job.
  • Internal renderer helpers and React wrappers explain their roles more clearly.

The earlier request to test Suspense recovery is addressed. No new actionable issues were found in the changes since the previous review.

Reviews (7) · Last reviewed commit: "style(react): drop the comment on the DO..." · Reviewed by Greptile

…from it

#11245 added the "Deckgl Fiber Renderer contributors" copyright line to every
copied file. #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
@chrisgervang
chrisgervang changed the base branch from master to chr/react-fiber-headers November 19, 2026 21:22
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 #11246).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
Base automatically changed from chr/react-fiber-headers to master November 19, 2026 22:26
Comment thread modules/react/src/dom/google-maps.tsx Resolved
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
Comment thread modules/react/src/dom/components.tsx Resolved
// Copyright (c) vis.gl contributors
// Copyright (c) Deckgl Fiber Renderer contributors

// @vitest-environment jsdom

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.

Hmm for these two util files I'm curious if we're carrying the intent over from fiber.gl.

Most deck modules do not consider SSR, but I think fiber might have. Are we keeping the env coverage while also conforming the test setup to how deck does it?

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.

They had lost it: 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. Fixed in 7abd94e: both are *.test.ts files in the react project again, utils.test.ts with @vitest-environment node (checks isBrowserEnvironment is false) and utils-browser.test.ts with jsdom (true), the way dom/ssr.test.ts already runs. Root SSR coverage stayed in ssr.test.ts throughout.


Generated by Claude Code

ibgreen commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Could we run the Fiber browser specs in a separate CI job until the context-release work in #11221 lands? The 21 files passing on their own is a good baseline, but both test-ci and test-webgpu skip them on the current head. Running just yarn exec vitest run --project browser test/modules/react/fiber under Xvfb in its own job would give the specs a fresh Chromium process, without putting them back on the shared headless page that hit the WebGL context limit. Once context release lands, we can verify the full shared suite with Fiber re-enabled.



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

Copy link
Copy Markdown
Collaborator Author

Added in 204c14e: a test-react-renderer job runs npx vitest run --project browser test/modules/react/fiber under Xvfb, with the same setup as test-webgpu. Locally that runs the 21 renderer spec files, and all 224 tests pass. Once #11221 is on master, the headless exclusion and this job can both come out.


Generated by Claude Code

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
`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
@chrisgervang
chrisgervang added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit 7657de4 Nov 20, 2026
10 checks passed
@chrisgervang
chrisgervang deleted the chr/react-fiber-review branch November 20, 2026 00:43
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