feature: add enableGPUCanvas param to allow GPU Canvas content to render for WebGL2 React variant - #442
Merged
Merged
Conversation
…der for WebGL2 React variant
There was a problem hiding this comment.
🟢 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
enableGPUCanvasparam for the React runtime. Applicable for the "@rive-app/react-webgl2" builds.useOffscreenRendererto true, which is not compatible with the deferred renderer for GPU canvas, we make it false IF the user opts in withenableGPUCanvas: true