Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tinyjin
Copy link
Member

@tinyjin tinyjin commented Aug 20, 2025

ThorVG Lottie Player Presets

Overview

ThorVG Lottie Player now supports multiple preset configurations to optimize bundle size and performance for different use cases. This update introduces four distinct player variants:

  • Standard versions: Full-featured players with all loaders (jpg, png, webp, ttf)
  • Lite versions: Optimized players with minimal loaders (png only) for reduced bundle size

Bundle Size Comparison

  • sw-lite: ~243KB (minimal features)
  • sw: ~635KB (standard features)
  • gl/gl-lite: Similar size differences with OpenGL renderer

Feature Comparison

Preset Renderer Loaders Bundle Size
(WASM + JS)
Use Case
sw Software lottie (+expressions), jpg, png, webp, ttf ~687KB
(641 +46)
Full-featured applications
gl OpenGL lottie (+expressions), jpg, png, webp, ttf ~694KB
(635+59)
Hardware-accelerated rendering
sw-lite Software lottie, png ~288KB
(243+45)
Lightweight applications
gl-lite OpenGL lottie, png ~294KB
(236+58)
Lightweight with hardware acceleration

Project Build

npm run build
# See `example/` after build to run Lottie player demo

CDN Usage

Standard Software Renderer

<script src="https://unpkg.com/@thorvg/lottie-player@latest/dist/sw/lottie-player.js"></script>

<lottie-player></lottie-player>

Standard WebGL Renderer

<script src="https://unpkg.com/@thorvg/lottie-player@latest/dist/gl/lottie-player.js"></script>

<lottie-player></lottie-player>

Lite Software Renderer (Minimal Features)

<script src="https://unpkg.com/@thorvg/lottie-player@latest/dist/sw-lite/lottie-player.js"></script>

<lottie-player></lottie-player>

Lite WebGL Renderer (Minimal Features)

<script src="https://unpkg.com/@thorvg/lottie-player@latest/dist/gl-lite/lottie-player.js"></script>

<lottie-player></lottie-player>

NPM Usage

Standard Software Renderer

import '@thorvg/lottie-player/sw';

const player = document.createElement('lottie-player');
player.wasmUrl = "./dist/sw/thorvg.wasm"; // if needed

Standard WebGL Renderer

import '@thorvg/lottie-player/gl';

const player = document.createElement('lottie-player');
player.wasmUrl = "./dist/gl/thorvg.wasm"; // if needed

Lite Software Renderer (Minimal Features)

import '@thorvg/lottie-player/sw-lite';

const player = document.createElement('lottie-player');
player.wasmUrl = "./dist/sw-lite/thorvg.wasm"; // if needed

Lite WebGL Renderer (Minimal Features)

import '@thorvg/lottie-player/gl-lite';

const player = document.createElement('lottie-player');
player.wasmUrl = "./dist/gl-lite/thorvg.wasm"; // if needed

@tinyjin tinyjin self-assigned this Aug 20, 2025
@vercel
Copy link

vercel bot commented Aug 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
thorvg-perf-test Error Error Aug 28, 2025 6:20am

@tinyjin
Copy link
Member Author

tinyjin commented Aug 21, 2025

Vercel build is just due to break change of wasm url path. We can ignore until we release preset package.

@tinyjin
Copy link
Member Author

tinyjin commented Aug 21, 2025

1. Common Test

CDN environment:

  • SW (Standard)
  • GL (Standard)
  • SW-lite
  • gl-lite

NPM environment:

  • SW (Standard)
  • GL (Standard)
  • SW-lite
  • gl-lite

2. Regression Test

  • Default Player
  • WG
  • perf-test

3. Module bundler compatibility

  • Webpack
  • Vite

4. Framework compatibility

  • React
  • Vue
  • Svelte

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces configurable preset players for the ThorVG Lottie Player, allowing developers to choose optimized builds based on their specific use case requirements. The implementation provides four distinct variants: standard and lite versions for both software and OpenGL renderers.

Key changes include:

  • Added preset-based build system with four variants (sw, gl, sw-lite, gl-lite)
  • Refactored codebase into base player class with preset-specific implementations
  • Updated build process to generate multiple WASM builds with different loader configurations

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wasm_setup.sh Orchestrates building all WASM variants with different configurations
wasm_build.sh Handles preset-specific WASM compilation with different loader options
src/base-player.ts Core player functionality extracted into reusable base class
src/lottie-preset-player.ts Preset-specific player implementation with hardcoded renderer
src/lottie-player.ts Simplified to extend base player with configurable renderer
rollup.config.js Updated build configuration to support multiple preset variants
package.json Added export paths for all preset variants
example/*.html Updated examples to demonstrate different preset usage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@hermet hermet left a comment

Choose a reason for hiding this comment

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

What is the beneift of separating BasePlayer and PresetPlayer?

Added support for multiple Lottie player presets to provide optimized bundle sizes and renderer options for different use cases:

- Standard : single renderer with all loaders (jpg, png, webp, ttf)
- Lite : single renderer with minimal loaders (png only)

Usage:
  import '@thorvg/lottie-player/sw'      # Standard software renderer
  import '@thorvg/lottie-player/gl'      # Standard OpenGL renderer
  import '@thorvg/lottie-player/sw-lite' # Lite software renderer
  import '@thorvg/lottie-player/gl-lite' # Lite OpenGL renderer

This allows developers to choose the optimal player configuration based on their performance and bundle size requirements.

issue: thorvg/thorvg#3481
Created dedicated example pages for each Lottie web player preset to demonstrate the different configurations and their capabilities.
@tinyjin
Copy link
Member Author

tinyjin commented Aug 28, 2025

@hermet Following your recommendation, I revised the endings throughout the document for consistency.

@tinyjin tinyjin requested a review from hermet August 28, 2025 06:15
@tinyjin tinyjin force-pushed the jinny/wasm_presets branch from 8a7c764 to 38afbcd Compare August 28, 2025 06:20
@tinyjin tinyjin merged commit 9bf1f69 into main Aug 28, 2025
1 of 2 checks passed
@tinyjin tinyjin deleted the jinny/wasm_presets branch August 28, 2025 06:21
@tinyjin tinyjin restored the jinny/wasm_presets branch August 28, 2025 06:21
@tinyjin tinyjin deleted the jinny/wasm_presets branch October 26, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improve features feature New feature additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants