Feat/webgl context attributes #3344
Open
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.
Description
Add webglContextAttributes prop for Canvas (web platform)
This PR adds support for configuring WebGL context attributes on the web platform, enabling features like
preserveDrawingBuffer
which is essential for canvas capture/screenshot functionality.Motivation
Currently, it's not possible to capture/screenshot canvas content on web because the WebGL context is created without
preserveDrawingBuffer: true
. This PR allows developers to configure WebGL context attributes to enable this and other WebGL-specific features.Changes
webglContextAttributes
prop toCanvasProps
andSkiaBaseViewProps
.web.ts
files)Implementation Details
The implementation converts boolean values to numbers as required by CanvasKit's WebGLOptions interface:
Usage
Testing
Visual Example
You can view a quick demo of this feature (not included in the PR) at this link
Platform Impact
Checklist
Other notes
If you'd like some extra context on why I ran into this problem and what I am trying to accomplish you can contact me gabe@novig.co, first time contributing to open source so please let me know if I am missing anything important in the contribution guidelines here. Great package that has made our work life and native apps render graphs fast and awesome! While porting our existing application to web we encountered this webGL edge case (react native for web)