Skip to content

fix(react): remove redundant initial render redraw#10428

Open
jarnoharno wants to merge 6 commits into
visgl:masterfrom
jarnoharno:fix/react-initial-render-redraw
Open

fix(react): remove redundant initial render redraw#10428
jarnoharno wants to merge 6 commits into
visgl:masterfrom
jarnoharno:fix/react-initial-render-redraw

Conversation

@jarnoharno

@jarnoharno jarnoharno commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Closes #10429

Background

The DeckGL layout effect calls deck.redraw('Initial render') on every React commit after mount, forcing extra full scene redraws during interaction.

Change List

  • Remove the deck.redraw('Initial render') call from the layout effect.
  • Add a regression test that re-renders DeckGL with new props and asserts the wrapper never forces a redraw (a redraw() call with a reason argument). Verified the test fails against master.

Note

Low Risk
Small React integration change with a targeted regression test; relies on Deck’s normal redraw loop instead of an extra forced redraw.

Overview
Stops the DeckGL React wrapper from calling deck.redraw('Initial render') at the end of every layout effect after the deck is initialized. That forced a full scene redraw on each commit (including during interaction), on top of the existing redrawDeck path and Deck’s animation loop.

Tests now wait for readiness via an onAfterRender draw counter instead of needsRedraw, and a new case asserts that prop-only re-renders do not trigger redraw(reason) calls with a reason argument.

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

Comment thread modules/react/src/deckgl.ts Outdated
// Force initial render if Deck is initialized
if (thisRef.deck?.isInitialized) {
// Force initial render once when Deck is initialized
if (thisRef.deck?.isInitialized && !thisRef.initialRenderDone) {

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.

@ibgreen Why was this added in the first place?
87883cd#diff-7207aa699a54f22a73db1a29c5cfab4ae82000a14d2cd274f92f7631b997e13fR215-R219

redrawDeck() is called immediately before this.
I tested removing it and did not see any apparent issue. If there is no good reason I think it should be dropped.

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.

The only reason I can think of was problems with getting WebGPU rendering to work in the React binding.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WebGPU is working fine too in website examples.
Regardless of the problem, it was the wrong fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for checking this out. I went ahead and removed the redraw call and reworked the regression test.

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

I'd recommend dropping the redraw call altogether.

@jarnoharno
jarnoharno force-pushed the fix/react-initial-render-redraw branch from 9f8522b to 34b865b Compare July 9, 2026 20:05
@jarnoharno jarnoharno changed the title fix(react): only trigger initial render redraw once fix(react): remove redundant initial render redraw Jul 9, 2026
@jarnoharno
jarnoharno requested a review from missx-oai July 9, 2026 20:16
@Pessimistress

Copy link
Copy Markdown
Collaborator

Thank you for identifying the issue!

@jarnoharno
jarnoharno force-pushed the fix/react-initial-render-redraw branch from d111c95 to f62030e Compare July 11, 2026 00:34
@jarnoharno

Copy link
Copy Markdown
Contributor Author

I also pushed a fix for the CI failures. The old waitUntilReady polled deck.needsRedraw() until it went false. That only worked because master force-redraws on every React commit. Without it, the flag is cleared by the animation loop, and if CI stalls animation frames for over a second, the 1 second wait times out.

The tests now pass an onAfterRender callback and waitUntilReady resolves once a draw has completed after that render.

The DeckGL layout effect called deck.redraw('Initial render') on every
React commit after Deck initialized, forcing unnecessary full scene
redraws and hurting interaction performance.
Per review feedback, drop the deck.redraw('Initial render') call from
the layout effect instead of gating it. redrawDeck() already flushes
any pending dirty flag immediately before, so the forced redraw is
redundant. Rework the regression test to assert that the React wrapper
never forces a redraw across re-renders.
The deckgl spec's waitUntilReady polled deck.needsRedraw, which races
against the animation loop and timed out on slow CI runners once
redraws are flushed by the loop instead of on every React commit.

Replace it with a per-mutation render tracker: each mount or rerender
passes a fresh onAfterRender callback to the element, and waitUntilReady
resolves once a draw completes after that mutation. This waits on a
monotonic, publicly observable condition, keeps an explicit "change has
been rendered" barrier at every wait site, and is immune to concurrent
tests observing each other's draws.
@jarnoharno
jarnoharno force-pushed the fix/react-initial-render-redraw branch from f62030e to 82dc1f6 Compare July 11, 2026 08:36
@coveralls

coveralls commented Jul 14, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 83.164% (-0.002%) from 83.166% — jarnoharno:fix/react-initial-render-redraw into visgl:master

@chrisgervang

Copy link
Copy Markdown
Collaborator

This PR has a failing test, please fix it. Thank!

@chrisgervang

chrisgervang commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Hmm, it failed and now its passing. I wonder if its flapping?

https://github.com/visgl/deck.gl/actions/runs/29306444817/job/87002921297

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.

[Bug] DeckGL React wrapper redraws the full scene on every React commit after mount

6 participants