Skip to content

(android): implement persistent CPU performance mode and lifecycle stability guards - #120

Open
acedmicabhishek wants to merge 4 commits into
LottieFiles:mainfrom
acedmicabhishek:main
Open

(android): implement persistent CPU performance mode and lifecycle stability guards#120
acedmicabhishek wants to merge 4 commits into
LottieFiles:mainfrom
acedmicabhishek:main

Conversation

@acedmicabhishek

Copy link
Copy Markdown

I had issue with .lottie
Android's SurfaceFlinger has a hardcoded rule to destroy the GL context for out-of-focus screens. The existing Android-lottie implementation struggles to successfully re-hook the rendering context to newly active windows, which leads to .lottie hot-reload issues and dropped render hooks.

To bypass this OS-level limitation and drastically improve remount efficiency, this update introduces a native caching system and exposes two new properties for granular performance tuning.

Improvements

  • Persistent Memory Caching (performanceMode): Introduced a global playerCache that allows the DotLottiePlayer instance to survive view detachment. This entirely eliminates the expensive JSON/binary parsing overhead when remounting the same animation (e.g., when navigating between tabs in a Bottom Navigation Bar).
  • Cache Identification (cacheId): Added support for unique cache identifiers to accurately store and retrieve specific player instances.
  • Lifecycle Stability Guards: Resolved rare Window composer not found crashes. The render-loop is now immediately paused during onDetachedFromWindow, and explicit disposal cleanup has been added to the Compose wrapper.
  • Frame State Persistence: Enhanced RAM mode to automatically save and restore the current frame index across surface recreations, ensuring a visually seamless experience for the end user.

React Native Integration
These changes were designed in tandem with updates to the @lottiefiles/dotlottie-react-native bridge. By exposing performanceMode and cacheId through the bridge, React Native applications can now achieve premium UI responsiveness on Android by caching heavy animation models directly in native memory.

@changeset-bot

changeset-bot Bot commented May 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2d12427

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant