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

Support lottie-react-native for RNW vNext #3278

Closed
namrog84 opened this issue Sep 30, 2019 · 26 comments
Closed

Support lottie-react-native for RNW vNext #3278

namrog84 opened this issue Sep 30, 2019 · 26 comments
Assignees
Labels
Deliverable Major item tracked for top-level planning in ADO enhancement Extensions Tracks issues against community modules and extensions Partner: Facebook Partner: Stream (label may be applied by bot based on author) Partner: Xbox (label may be applied by bot based on author)
Milestone

Comments

@namrog84
Copy link
Contributor

https://github.com/react-native-community/lottie-react-native

Used by 62k repos and about 12k stars.

Lottie component for React Native (iOS and Android)

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as JSON with bodymovin and renders them natively on mobile!

@ghost ghost added the Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) label Sep 30, 2019
@chrisglein chrisglein added this to the vNext Milestone 4 milestone Sep 30, 2019
@chrisglein chrisglein added good first issue and removed Needs: Triage 🔍 New issue that needs to be reviewed by the issue management team (label applied by bot) labels Sep 30, 2019
@chrisglein
Copy link
Member

This would be a great thing to do after we have our view managers story up and running (after M3).

@chrisglein chrisglein added the Partner: Xbox (label may be applied by bot based on author) label Oct 11, 2019
@namrog84
Copy link
Contributor Author

namrog84 commented Oct 17, 2019

Everything in there seems to be for C# .NET and I don't really see a C++/WinRT way of using that.

@chrisglein chrisglein reopened this Oct 17, 2019
@chrisglein
Copy link
Member

Accidental close

@chrisglein chrisglein added Extensions Tracks issues against community modules and extensions must-have p1 Partner: Stream (label may be applied by bot based on author) labels Oct 29, 2019
@stmoy stmoy changed the title Add Lottie support for RNW Support lottie-react-native for RNW vNext Nov 11, 2019
@chrisglein chrisglein added the Deliverable Major item tracked for top-level planning in ADO label Nov 26, 2019
@chrisglein
Copy link
Member

Partner is currently unblocked with their existing lottie implementation. We will need to wait for some improvements from Composition before lottie support can be added without either codegen or the overhead of .NET. Moving to M5 as we no longer need this to exist M4.

@jonthysell
Copy link
Contributor

Using some weird workarounds (like taking the json they loaded from disk, and resaving it back to disk, to be reloaded by LottieWindows, and doing too much on the UI thread), but this is their sample app: 😃

example app

@jonthysell
Copy link
Contributor

PR started here: lottie-react-native/lottie-react-native#692

@simeoncran
Copy link

The developer passes in integer start frame and end frame. I can convert those into progress percentages given a total number of frames, which I'm currently doing by multiplying the duration in seconds by a hard-coded framerate.

But with rounding, there's no guarantee that the exact specified frames will be played back.

I don't think it should matter. Frames are floating point numbers so they're already subject to rounding elsewhere in the system. Do you have any repros where it's definitely displaying the wrong thing so that I can investigate?

@simeoncran
Copy link

Using some weird workarounds (like taking the json they loaded from disk, and resaving it back to disk, to be reloaded by LottieWindows, and doing too much on the UI thread), but this is their sample app: 😃

You should be able to pass a stream to LottieVisualSource. That API was hidden due to a missing attribute, but that has been fixed and will be available in V7.0 (preview expected this week).
Is the problem with too much work on the UI thread something in LottieVisualSource or is it something you can fix? LottieVisualSource does most of it's loading on a separate thread. Maybe more needs to moved off.

@jonthysell
Copy link
Contributor

Using some weird workarounds (like taking the json they loaded from disk, and resaving it back to disk, to be reloaded by LottieWindows, and doing too much on the UI thread), but this is their sample app: 😃

You should be able to pass a stream to LottieVisualSource. That API was hidden due to a missing attribute, but that has been fixed and will be available in V7.0 (preview expected this week).
Is the problem with too much work on the UI thread something in LottieVisualSource or is it something you can fix? LottieVisualSource does most of it's loading on a separate thread. Maybe more needs to moved off.

Looking at the 7.0.0-preview4 now. The UI threading issues has nothing to do with LottieWindows and were just how I wrote my prototype - explicitly dispatching everything on the UI thread to avoid thread mismatch issues and just prove I could get their example app up and running. I have since then gone through and redone the threading properly.

@aschultz
Copy link
Member

aschultz commented Jan 4, 2021

@jonthysell I took a stab at a C++/WinRT implementation.
lottie-react-native/lottie-react-native#714

@jonthysell
Copy link
Contributor

@aschultz I'm glad to see another implementation, I'll take a look at it.

I think, unfortunately, there's no solution that meets everyone's needs:

Requirement C# C++/WinRT
Dynamically load assets at runtime
Codepush / bundle-only updates
Non-managed code

Until there's a full C++ implementation of lottie, with loading json at runtime, I think we'll need both solutions, and let app developers pick which version works best for them. For some customers, requiring them to publish a native app update to change assets is a deal-breaker. For other customers, introducing managed code (especially having to switch to a managed app) is a deal-breaker.

@aschultz
Copy link
Member

aschultz commented Jan 4, 2021

@jonthysell I was thinking that the C++/WinRT version might work for both scenarios. It defers the loading of the IAnimatedVisualSource back to the app (via ILottieSourceProvider), so devs can choose whether to use codegen or LottieWindows to fulfill the requests.

interface ILottieSourceProvider
{
    Microsoft.UI.Xaml.Controls.IAnimatedVisualSource GetSourceFromName(String name);
    Microsoft.UI.Xaml.Controls.IAnimatedVisualSource GetSourceFromJson(String json);
}

A C++ app could elect to only implement GetSourceFromName for now, and then add support for JSON once a better dynamic loader is available to them.

This also allows use of both modes in the same app -- codegen for built-in animations, JSON for remotely fetched content -- based on whether the React code passes in a string or JSON for a source.

@chrisglein chrisglein modified the milestones: 0.64, 0.65 Jan 7, 2021
@chrisglein
Copy link
Member

@jonthysell @aschultz Do we think that we'll be able to have a canonical C++/WinRT version that works for both scenarios? If not, how can we guide people looking for lottie to an option that works for them? Do we need a fork? Does one get merged with a readme presenting the other as an option? How do we get this more discoverable than 2 in progress PRs? (#714 and #700)

@chrisglein chrisglein modified the milestones: 0.65, 0.66 Apr 24, 2021
@emilioicai
Copy link

hey guys, lottie-react-native 4.0.0 has been finally released. Sorry for the delay, it has been very painful to test and still I think there may be some issues so I would appreciate if you could give it a try.

BTW, react-native-safe-modules 1.0.1 has also been released including @jonthysell changes

@jonthysell jonthysell modified the milestones: 0.66, 0.67 Sep 1, 2021
@chrisglein chrisglein modified the milestones: 0.67, Backlog Nov 17, 2021
@jonthysell
Copy link
Contributor

jonthysell commented Jan 31, 2022

I've signed off on lottie-react-native/lottie-react-native#714, hopefully this will make it easier for people to take the dependency on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deliverable Major item tracked for top-level planning in ADO enhancement Extensions Tracks issues against community modules and extensions Partner: Facebook Partner: Stream (label may be applied by bot based on author) Partner: Xbox (label may be applied by bot based on author)
Projects
None yet
Development

No branches or pull requests

8 participants