Remote .svga URL fails to load on Web or Mobile Player
Missing Access-Control-Allow-Origin headers on CDN/OSS, or mixed HTTP requests from an HTTPS page.
Serve SVGA files over HTTPS with valid CORS headers and verify reachability in Mobile Player.
Installation steps, dynamic replacement snippets, and cleanup examples below build on each official repository README. Check the support matrix above before choosing a package.
Several original SVGA repositories on GitHub are now archived (read-only), while Web Lite, HarmonyOS, and community Flutter continuations remain actively maintained. Verify compatibility before choosing a package.
| Platform | Package / Repo | Latest Release | Formats | Audio | Upstream Status | Recommended Path |
|---|---|---|---|---|---|---|
| iOS | SVGAPlayer (CocoaPods) | 2.5.7 | 1.x & 2.0 | Supported | Upstream repo archived (read-only) | Use 2.5.7 in production (includes entity-reuse mask fix) |
| Android | SVGAPlayer-Android (JitPack) | 2.6.1 | 1.x & 2.0 | Supported (SVGASoundManager) | Upstream repo archived (read-only) | Pin 2.6.1 and configure ProGuard Wire/Proto keep rules |
| Web (Classic) | svgaplayerweb (npm) | 2.3.2 | 1.x (needs JSZip) & 2.0 | Supported (needs howler.js + ID3) | Upstream repo archived (read-only) | Use only when SVGA 1.x or embedded audio is required |
| Web Lite | svga (npm) | 2.1.1 | 2.0 only | Not supported | Actively maintained | Default choice for mobile web, Vue 3, and React (< 18 KB gz) |
| Flutter | svgaplayer_flutter / flutter_svga | 2.2.0 (official) | 2.0 only | Package-dependent | svgaplayer_flutter archived; use flutter_svga | Prefer active community package flutter_svga on pub.dev for Dart 3+ |
| HarmonyOS | @tb-open/svga (OHPM) | Active on OHPM | 2.0 | Check OHPM docs | Actively maintained | Use SvgaPlayerV2 and SvgaController on HarmonyOS NEXT |
Native CoreAnimation renderer that loads SVGA files from the app bundle or a remote server.
Note: The official SVGAPlayer-iOS GitHub repository is archived read-only; the final CocoaPods tag is 2.5.7 (fixing mask loss when reusing VideoEntity). Swift projects work seamlessly via an Objective-C bridging header.
Add the dependency to your Podfile, then run pod install.
target 'MyApp' do
pod 'SVGAPlayer', '~> 2.5'
endCreate SVGAPlayer and SVGAParser, assign the parsed videoItem, and start the animation.
SVGAPlayer *player = [[SVGAPlayer alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[self.view addSubview:player];
SVGAParser *parser = [[SVGAParser alloc] init];
[parser parseWithNamed:@"posche" inBundle:nil completionBlock:^(SVGAVideoEntity *videoItem) {
if (videoItem != nil) {
player.videoItem = videoItem;
[player startAnimation];
}
} failureBlock:nil];After importing SVGAPlayer in your bridging header, parse and play animations asynchronously.
let player = SVGAPlayer(frame: CGRect(x: 0, y: 0, width: 240, height: 240))
player.loops = 1
player.clearsAfterStop = true
view.addSubview(player)
let parser = SVGAParser()
parser.parse(withNamed: "posche", in: nil, completionBlock: { [weak player] videoItem in
guard let item = videoItem else { return }
player?.videoItem = item
player?.startAnimation()
}, failureBlock: { error in
print("SVGA parse failed:", error)
})Replace avatar bitmaps or overlay localized labels on named imageKey sprites.
if let avatar = UIImage(named: "user_avatar") {
player.setImage(avatar, forKey: "avatar_slot")
}
let text = NSAttributedString(
string: "VIP Lv.10",
attributes: [
.font: UIFont.boldSystemFont(ofSize: 22),
.foregroundColor: UIColor.white
]
)
player.setAttributedText(text, forKey: "banner_text_slot")Reset dynamic overrides and clear player references before reusing cells or tearing down views.
player.stopAnimation()
player.clearDynamicObjects()
player.clear()
player.videoItem = nilNative Android Canvas renderer that loads animations from assets or a remote server.
Note: SVGAPlayer-Android is archived read-only on GitHub. Pin 2.6.1 via JitPack and keep Wire/Proto classes in ProGuard.
Add the JitPack repository to the root build.gradle, then add the dependency to app/build.gradle.
// root build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
// app/build.gradle
implementation 'com.github.svga:SVGAPlayer-Android:2.6.1'Add SVGAImageView to your layout, point it at an animation, and enable autoplay.
<com.opensource.svgaplayer.SVGAImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:source="posche.svga"
app:autoPlay="true" />Initialize the shared parser once in Application.onCreate, then decode from assets or network URLs.
// Application.onCreate()
SVGAParser.shareParser().init(this)
// Activity / Fragment
SVGAParser.shareParser().decodeFromAssets("posche.svga", object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
svgaImageView.setVideoItem(videoItem)
svgaImageView.startAnimation()
}
override fun onError() {
// Fallback or error telemetry
}
})Bind dynamic bitmaps and styled TextPaint values onto matching imageKey layers.
val dynamicEntity = SVGADynamicEntity()
dynamicEntity.setDynamicImage(avatarBitmap, "avatar_slot")
val textPaint = TextPaint().apply {
color = Color.WHITE
textSize = 28f
isFakeBoldText = true
}
dynamicEntity.setDynamicText("VIP Lv.10", textPaint, "banner_text_slot")
svgaImageView.setImageDrawable(SVGADrawable(videoItem, dynamicEntity))
svgaImageView.startAnimation()Enable clearsAfterDetached for RecyclerView safety and release audio resources on exit.
svgaImageView.clearsAfterDetached = true
svgaImageView.clearsAfterStop = true
svgaImageView.stopAnimation(true)
svgaImageView.clear()
// Release 2.6.0+ audio sound pool when exiting screen
SVGASoundManager.release()Full-featured web player with SVGA 1.x support (via JSZip), audio playback, and IE compatibility mode.
Note: svgaplayerweb (SVGAPlayer-Web) is archived upstream, but remains required whenever you need SVGA 1.x support or embedded MP3 audio playback.
Install from npm or load the CDN build directly.
npm install svgaplayerweb --save
<!-- or load directly -->
<script src="https://cdn.jsdelivr.net/npm/svgaplayerweb@2.3.2/build/svga.min.js"></script>Create a container, instantiate Player and Parser, then load and play the animation.
<div id="demoCanvas"></div>
<script>
const player = new SVGA.Player('#demoCanvas');
const parser = new SVGA.Parser('#demoCanvas');
parser.load('rose.svga', (videoItem) => {
player.setVideoItem(videoItem);
player.startAnimation();
});
</script>Include JSZip for 1.x ZIP files and howler.js for ID3-prefixed audio tracks.
<script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/howler@2.2.4/dist/howler.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/svgaplayerweb@2.3.2/build/svga.min.js"></script>Attach dynamic image URLs or canvas text before calling startAnimation().
parser.load('gift.svga', (videoItem) => {
player.setImage('https://example.com/avatar.png', 'avatar_slot')
player.setText(
{ text: 'Welcome VIP', family: 'sans-serif', size: '24px', color: '#ffffff' },
'banner_text_slot'
)
player.setVideoItem(videoItem)
player.startAnimation()
})Clear dynamic objects and canvas buffers on SPA route transitions.
player.clearsAfterStop = true
player.stopAnimation()
player.clearDynamicObjects()
player.clear()Lightweight player for mobile web, under 60 KB (under 18 KB gzipped), with WebWorker parsing.
Note: Recommended for modern web apps (< 18 KB gzipped), using WebWorker parsing and OffscreenCanvas/ImageBitmap. Supports SVGA 2.0 without audio.
Install from npm or use the unpkg CDN build.
npm i svga
<!-- or load directly -->
<script src="https://unpkg.com/svga/dist/index.min.js"></script>Create a Parser, load the animation, mount it to a canvas, and start playback.
import { Parser, Player } from 'svga'
const parser = new Parser()
const svga = await parser.load('xx.svga')
const player = new Player(document.getElementById('canvas'))
await player.mount(svga)
player.start()Always destroy both player and parser on unmount to avoid leaking WebWorkers and image bitmaps.
// React useEffect pattern (same cleanup applies in Vue 3 onBeforeUnmount)
useEffect(() => {
const parser = new Parser()
const player = new Player({ container: canvasRef.current!, loop: 0 })
let disposed = false
parser.load('/assets/gift.svga').then(async (svga) => {
if (disposed) return
await player.mount(svga)
player.start()
})
return () => {
disposed = true
player.stop()
player.clear()
player.destroy()
parser.destroy()
}
}, [])Mutate parsed VideoEntity replacement maps before mounting onto the player.
const svga = await parser.load('/assets/gift.svga')
const img = new Image()
img.crossOrigin = 'anonymous'
img.src = 'https://example.com/avatar.png'
await img.decode()
svga.replaceElements['avatar_slot'] = img
await player.mount(svga)
player.start()Use the built-in DB helper and frame cache options to avoid re-downloading repeated gifts.
import { DB, Parser, Player } from 'svga'
const db = new DB()
let svga = await db.find('gift_v2')
if (!svga) {
svga = await parser.load('/assets/gift.svga')
await db.insert('gift_v2', svga)
}
const player = new Player({
container: document.getElementById('canvas') as HTMLCanvasElement,
isCacheFrames: true,
isUseIntersectionObserver: true
})
await player.mount(svga)
player.start()Flutter implementation built on CustomPainter that loads animations from local assets or a remote server.
Note: The original svgaplayer_flutter (2.2.0) repo is archived upstream. For Dart 3 null safety and recent Flutter releases, evaluate the active pub.dev community package flutter_svga.
Add the dependency to pubspec.yaml.
dependencies:
svgaplayer_flutter: ^2.0.0Use SVGASimpleImage for the simplest integration, or SVGAAnimationController for full playback control.
SVGASimpleImage(
resUrl: 'https://github.com/svga/SVGA-Samples/blob/master/angel.svga?raw=true',
)Pair SVGAAnimationController with SingleTickerProviderStateMixin and always dispose the controller.
// pubspec.yaml — check pub.dev/packages/flutter_svga for current version
// dependencies:
// flutter_svga: ^latest
import 'package:flutter/material.dart';
import 'package:flutter_svga/flutter_svga.dart';
class SvgaBanner extends StatefulWidget {
const SvgaBanner({super.key});
@override
State<SvgaBanner> createState() => _SvgaBannerState();
}
class _SvgaBannerState extends State<SvgaBanner> with SingleTickerProviderStateMixin {
late final SVGAAnimationController _controller;
@override
void initState() {
super.initState();
_controller = SVGAAnimationController(vsync: this);
SVGAParser.shared.decodeFromAssets('assets/gift.svga').then((videoItem) {
if (!mounted) return;
_controller.videoItem = videoItem;
_controller.repeat();
});
}
@override
Widget build(BuildContext context) => SVGAImage(_controller);
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}Assign dynamic images or TextPainters on videoItem.dynamicItem before playback.
videoItem.dynamicItem.setImageWithUrl('https://example.com/avatar.png', 'avatar_slot');
videoItem.dynamicItem.setText(
TextPainter(
text: const TextSpan(
text: 'VIP Lv.10',
style: TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold),
),
),
'banner_text_slot',
);Dispose unused MovieEntity / VideoEntity objects when switching gifts to free decoded textures.
_controller.stop();
_controller.videoItem?.dispose();
_controller.dispose();SVGA player for HarmonyOS NEXT with declarative UI 1.0 and 2.0 components.
Note: Actively maintained for HarmonyOS NEXT declarative UI 1.0 & 2.0 via OHPM.
Install with OHPM.
ohpm install @tb-open/svgaInitialize SVGA, create a controller, and render the animation with SvgaPlayerV2.
import { Svga, SvgaController, SvgaPlayerV2 } from '@tb-open/svga'
// AbilityStage.onCreate
Svga.init(this.context)
private controller: SvgaController = new SvgaController({
loops: 3,
fillMode: 'forwards',
autoRelease: true,
clearsAfterStop: true
})
SvgaPlayerV2({
url: $r('app.media.example_animation'),
controller: this.controller
})
.width(300)
.height(150)SvgaPlayerV2 accepts bundled $r resources, HTTPS URLs, and app sandbox file paths.
SvgaPlayerV2({
url: 'https://example.com/assets/gift.svga',
controller: this.controller
})
.width(300)
.height(300)Bind dynamic user images and text labels onto named slots through SvgaController.
this.controller.setImage('https://example.com/avatar.png', 'avatar_slot')
this.controller.setText({
text: 'VIP Lv.10',
fontColor: '#FFFFFF',
fontSize: 22
}, 'banner_text_slot')Use autoRelease: true and release the controller inside aboutToDisappear().
aboutToDisappear(): void {
this.controller.stop()
this.controller.release()
}Beyond native mobile and web browsers, SVGA is commonly integrated in mini programs and server pipelines.
WeChat Mini Program Canvas 2D adapters exist under the svga org. UniApp H5 targets can use Web Lite (svga), while native App builds typically delegate to native plugins or renderjs.
Browse svga/docsPython / CINo official svga-python package exists on PyPI—use standard zlib + protobuf compiled from svga.proto for CI checks, frame extraction, and 2.0 packing.
Read Python guideProtobuf SpecReview v1.x movie.spec, v2.x MovieEntity fields, imageKey conventions, and RGBA memory budgets.
Open Format SpecMissing Access-Control-Allow-Origin headers on CDN/OSS, or mixed HTTP requests from an HTTPS page.
Serve SVGA files over HTTPS with valid CORS headers and verify reachability in Mobile Player.
Decoded RGBA pixel memory ∑(width × height × 4) exceeds GPU/heap limits, or recycled views leak VideoEntity instances.
Inspect decoded RGBA memory in Online Player, downscale oversized sprites, and always call clear()/dispose() on teardown.
R8/ProGuard stripped or renamed Wire and generated Protobuf classes.
Add -keep rules for com.squareup.wire.** and com.opensource.svgaplayer.proto.** in proguard-rules.pro.
Using Web Lite (no audio), missing global window.Howl in Classic player, missing ID3v2 header, or browser autoplay block.
Use svgaplayerweb 2.3.2 with howler.js triggered from a user interaction, or audition tracks natively in Online Player.
Download open-source test files covering dynamic imageKey slots, matteKey masks, MP3 audio, and SVGA 1.x compatibility.