Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Gzip and Zip animation detection for File and ContentProvider animations in Compose #2490

Open
MSDarwish2000 opened this issue Apr 7, 2024 · 2 comments

Comments

@MSDarwish2000
Copy link
Contributor

Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.

Is your feature request related to a problem? Please describe.
You have done great work, adding support for G-zipped animations, but this feature depends on file extension for content providers and file sources. This is good for most cases, but in some cases when dealing with data without extensions from external sources or pre-existing data where migration is hard, an alternative method may be needed.

Describe the solution you'd like
One solution that won't introduce breaking changes would be using isGzipCompressed and isZipCompressed which are already present in the codebase and used by RawRes and Asset. I think it is a better and foolproof detection method but may need early file probing.

Describe alternatives you've considered
Another method could be adding optional argument to each LottieCompositionSpec (except JsonString of course), which allows users to explicitly specify the animation type.

Additional context
Not applicable

@gpeal
Copy link
Collaborator

gpeal commented Apr 7, 2024

Compose doesn't use the header magic bytes like the view code path but in the next release, it will check for file extension. Would that be sufficient for your use case?
#2488

@MSDarwish2000
Copy link
Contributor Author

Compose doesn't use the header magic bytes like the view code path but in the next release, it will check for file extension. Would that be sufficient for your use case? #2488

Thank you for your quick response. For me, this isn't sufficient as my Gzip files have no extensions. Actually, this PR was what I'm talking about.

Of course, migrating user data is possible, but it is more error prone than just supporting detecting the format using magic bytes or specifying the type explicitly. As a workaround, I can copy the LottieAnimation and rememberLottieComposition functions and force the type myself in case you prefer not implementing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants