Skip to content

feature: add enableGPUCanvas param to allow GPU Canvas content to render for WebGL2 React variant - #442

Merged
zplata merged 2 commits into
mainfrom
js/enable-gpu-canvas
Sep 3, 2026
Merged

feature: add enableGPUCanvas param to allow GPU Canvas content to render for WebGL2 React variant#442
zplata merged 2 commits into
mainfrom
js/enable-gpu-canvas

Conversation

@zplata

@zplata zplata commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator
  • Adds the new enableGPUCanvas param for the React runtime. Applicable for the "@rive-app/react-webgl2" builds.
  • Because the React runtime defaults the useOffscreenRenderer to true, which is not compatible with the deferred renderer for GPU canvas, we make it false IF the user opts in with enableGPUCanvas: true

Copilot AI 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.

🟢 Approval recommended

The implementation and coverage support the intended behavior, with only non-blocking documentation and warning-text corrections remaining.

Pull request overview

Adds GPU Canvas support for the WebGL2 React runtime while resolving its incompatibility with the offscreen renderer.

Changes:

  • Adds and forwards enableGPUCanvas.
  • Resolves renderer defaults for GPU Canvas and imported files.
  • Adds tests, cleanup safeguards, dependency updates, and a Storybook example.
File summaries
File Description
src/hooks/useRive.tsx Resolves renderer mode and safely cleans up instances.
src/hooks/useRiveFile.ts Re-imports files when GPU Canvas mode changes.
src/components/Rive.tsx Exposes the new component prop.
src/types.ts Documents renderer option behavior.
src/utils.ts Exports defaults and adds safe teardown.
test/useRiveGpuCanvas.test.tsx Tests renderer-mode resolution.
examples/src/components/GPUCanvasDeferred.tsx Demonstrates GPU Canvas scenarios.
examples/src/components/GPUCanvasDeferred.stories.ts Registers the example story.
examples/.storybook/main.ts Configures WebGL2 for Storybook.
package.json Updates Rive runtime dependencies.
package-lock.json Locks updated runtime versions.
Review details
  • Files reviewed: 10/13 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread examples/.storybook/main.ts Outdated
Comment thread src/hooks/useRive.tsx Outdated
Comment thread src/utils.ts Outdated

@bodymovin bodymovin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@zplata
zplata merged commit 76bc972 into main Sep 3, 2026
1 check passed
@zplata
zplata deleted the js/enable-gpu-canvas branch September 3, 2026 13:42
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.

3 participants