feat(apple): add WebGPU renderer - #41
Draft
tinyjin wants to merge 5 commits into
Draft
Conversation
|
DotLottieView.useWebGPU opts into ThorVG's WebGPU (Metal) backend on iOS and macOS, which rasterises straight into a CAMetalLayer instead of building a CGImage and uploading it through Core Image on the platform thread every frame. (Off by default) Intorudce DotLottieFlutterRenderer, the method-channel handler, is renderer-agnostic. It's implemented once per backend, so adding one does not touch the switch. usage: ``` DotLottieView( sourceType: 'asset', source: 'animation.lottie', autoplay: true, useWebGPU: true, // iOS/macOS only ) ```
renderer() answers with "sw", "gl" or "wg".
A fallback remounts the default renderer
to this result as well
usage:
```
DotLottieViewController? _controller;
DotLottieView(
sourceType: 'asset',
source: 'animation.lottie',
onViewCreated: (controller) => _controller = controller,
onLoad: () async {
final renderer = await _controller?.renderer(); // 'sw' | 'gl' | 'wg'
debugPrint('renderer: $renderer');
},
)
```
GPU rendering option & sample - android : toggle OpenGL - iOS/macos : toggle WebGPU - others: hidden Live stats in test page - FPS, memory usage (MEM)
cover experimental OpenGL/WebGPU rendering usage
tinyjin
force-pushed
the
jinny/wgpu-support
branch
from
August 17, 2026 19:14
35c5627 to
4c53cd1
Compare
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.
Overview
DotLottieFlutterRenderer(swift), the apple method-channel handler, is renderer-agnostic.DotLottieViewController.renderer()to query current activated renderer.CPU vs GPUtest programMetal/WebGPU Support
usage
Note
The existing GPU option flag for android is
useOpenGL, so the webgpu option parameter is also set to beuseWebGPU. We may want to revise renderer option into a single, such asString rendrer = 'sw | gl | wg'. For now leaving as-is for consistency.Example Enhancement
Monitor per-platform GPU rendering vs CPU (default). This example is built similar to dotlottie-ios' test example.