Skip to content

feat(lottie): native Lottie decoding via vendored ThorVG#65

Merged
LeadcodeDev merged 1 commit into
mainfrom
feat/lottie-native
Jul 19, 2026
Merged

feat(lottie): native Lottie decoding via vendored ThorVG#65
LeadcodeDev merged 1 commit into
mainfrom
feat/lottie-native

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Closes #52 — implementation of the GO decision documented in the issue (evaluation: dotlottie-rs disqualified by its Conan-requiring stale crates.io alpha; velato by its missing CPU renderer and fidelity gaps; thorvg 0.5.0 vendored builds in 30s via cc-rs with zero new system deps).

  • Default-on lottie-native feature (components → rustmotion re-export → cli transitively); cargo check --no-default-features compiles clean and restores the frames_dir-or-nothing behavior
  • Frame mapping from the JSON's fr/ip/op (t×speed, modulo duration on repeat, clamped otherwise); byte order proven by test (ThorVG ABGR8888 low-byte-R ≡ RGBA bytes — red lottie renders red, not blue)
  • Thread-safety for the rayon-parallel pipeline: thread_local! engine (ThorVG is !Send), per-call animation/canvas, global frame cache keyed (source-hash, frame, w, h) with clear-at-128 eviction (the studio re-requests identical frames in a loop)
  • Invalid JSON/missing file → one warning per source, zero pixels, never a panic; frames_dir keeps priority; the audit's lying doc-comment ("falls back to static SVG") is gone

Tests: 6 new (byte order, repeat wrap, repeat clamp, speed equivalence, invalid-JSON resilience, frames_dir priority). 345 total, all green.

Verify: cargo test --workspace → 345 passed ✓ · --no-default-features check ✓ · cargo fmt --check ✓ · clippy gated ≤1 ✓

The lottie component rendered nothing without pre-rendered frames_dir.
Now decodes src/data natively through the thorvg crate (vendored
cc-rs build, ~30s, no system deps beyond the C++ compiler skia
already requires) behind a default-on lottie-native feature
(--no-default-features restores the old behavior and compiles clean).

- frame mapping: t*speed against the JSON's fr/ip/op, modulo duration
  when repeat else clamped; ABGR8888 u32 low-byte-R reinterprets as
  RGBA bytes (byte order locked by a red-vs-blue pixel test)
- thread_local ThorVG engine per rayon worker (!Send), per-call
  animation+canvas, global frame cache (fnv(source), frame, w, h)
  with naive clear-at-128 eviction; per-source one-shot warning on
  invalid JSON, never a panic
- frames_dir keeps priority (backward compat); stale 'falls back to
  static SVG' doc-comment removed (audit finding)
@LeadcodeDev
LeadcodeDev merged commit cfee996 into main Jul 19, 2026
@LeadcodeDev
LeadcodeDev deleted the feat/lottie-native branch July 19, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(lottie): native Lottie decoding (evaluation)

1 participant