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

Fabric support for iOS #955

Merged
merged 15 commits into from Jan 17, 2023
Merged

Conversation

alfonsocj
Copy link
Contributor

@alfonsocj alfonsocj commented Dec 16, 2022

Summary

Adding Fabric support for iOS.

  • Update podspec file to match new architecture's paved path.
  • Implementation of LottieAnimationViewComponentView objective-c++ class that uses existing ContainerView.swift.

@alfonsocj
Copy link
Contributor Author

@AlexanderEggers, here's what I have so far. The fabric example works, but I still have to figure out a frame issue that prevents ContainerView's animationView not visible (because the frame is (0.0, 0.0, 0.0, 0.0)) here

@alfonsocj
Copy link
Contributor Author

alfonsocj commented Dec 19, 2022

@AlexanderEggers I tested on Android and it seems like it's accepting the structs. The problem I see now is I get this error when the animation ends
java.lang.AssertionError: Method overloading is unsupported: com.facebook.react.uimanager.events.RCTModernEventEmitter#receiveEvent
This happens when the sendOnAnimationFinishEvent method runs and receiveEvent gets called. Can you reproduce this? It's happening to me on the fabric example in master as long as loop prop is set to false which is when the onAnimationFinish gets triggered.

@alfonsocj alfonsocj marked this pull request as ready for review December 20, 2022 16:46
@alfonsocj
Copy link
Contributor Author

@emilioicai @AlexanderEggers @matinzd I think the PR is ready!

@matinzd
Copy link
Collaborator

matinzd commented Dec 20, 2022

I am going to test it this weekend. Thanks for the PR!

@matinzd matinzd self-requested a review December 20, 2022 17:00
@alfonsocj
Copy link
Contributor Author

Happy New Year! @matinzd, did you have a chance to test it?

@matinzd
Copy link
Collaborator

matinzd commented Jan 4, 2023

Happy New Year! @matinzd, did you have a chance to test it?

I am going to test this tonight. 🚀

@matinzd
Copy link
Collaborator

matinzd commented Jan 5, 2023

I ran into some issues while building and testing it last night. I will give more update on it later today.

@matinzd
Copy link
Collaborator

matinzd commented Jan 5, 2023

Try playing with examples and adding the view to different hierarchies. It starts throwing an error.

Screenshot 2023-01-05 at 09 22 15

Video:

Untitled.mp4

@bukhari-flip
Copy link

I think the Cannot read property '_nativeTag' of null appeared when fast reload was enabled. Because when an error appeared and then you force to refresh the app, the error will disappear.

This behavior happened on both iOS and Android.

@matinzd
Copy link
Collaborator

matinzd commented Jan 11, 2023

I think the Cannot read property '_nativeTag' of null appeared when fast reload was enabled. Because when an error appeared and then you force to refresh the app, the error will disappear.

This behavior happened on both iOS and Android.

I think we might need to refactor javascript code as well. There are some deprecated methods used in our js files.

@alfonsocj
Copy link
Contributor Author

alfonsocj commented Jan 11, 2023

@matinzd, which deprecated methods are you referring to? I'd be happy to refactor those.
Are you referring to AnimatedLottieView being a class based component with lifecycle events like componentDidUpdate?

@matinzd
Copy link
Collaborator

matinzd commented Jan 11, 2023

@matinzd, which deprecated methods are you referring to? I'd be happy to refactor those. Are you referring to AnimatedLottieView being a class based component with lifecycle events like componentDidUpdate?

Sorry, my bad. I thought we are still using dispatchViewManagerCommand and dispatchCommand.

@alfonsocj
Copy link
Contributor Author

alfonsocj commented Jan 11, 2023

I'm not sure why that's happening on Fabric when using fast reload. It's related to the native component having a ref. I couldn't reproduce the issue when removing the ref from the native component in LottieView.tsx.

@alfonsocj
Copy link
Contributor Author

@matinzd, let me know when you can test my findings. I'll investigate further what's going on with the refs.

@matinzd
Copy link
Collaborator

matinzd commented Jan 11, 2023

@matinzd, let me know when you can test my findings. I'll investigate further what's going on with the refs.

Ok, I found the issue. According to this note first callback of ref will be initiated as null during the first render of DOM (it is related to react internals). So if we wrap ref with null check it fixes the problem. But I don't know if this is a good idea.

  _captureRef(ref: React.ElementRef<typeof NativeLottieAnimationView>) {
+   if (ref === null) {
+      return
+   }

    this._lottieAnimationViewRef = ref;
    if (this.props.autoPlay === true) {
      this.play();
    }
  }

@alfonsocj
Copy link
Contributor Author

I think this makes sense. I don't see any issues with not assigning the ref until it's not null.

@alfonsocj
Copy link
Contributor Author

I added color filters to the example. I see those working fine on iOS. Android is not getting them.

@alfonsocj
Copy link
Contributor Author

Android is getting the values and assigning a color filter. I think the problem is that the color filter keypath for Android is not the same than for iOS.

@alfonsocj
Copy link
Contributor Author

alfonsocj commented Jan 11, 2023

@matinzd have you tried using a lottie animation that includes a text before? I tried one that uses Roboto font and it crashes on Android since the font is not there. I tried adding it to assets/font but that didn't work.
All this to try the textFilters (which works on iOS)

@matinzd
Copy link
Collaborator

matinzd commented Jan 17, 2023

Hey @alfonsocj ,
Example upgrade is ready! Try rebasing/updating your branch.

Copy link
Collaborator

@matinzd matinzd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚀

@matinzd matinzd merged commit ebed44e into lottie-react-native:master Jan 17, 2023
@matinzd matinzd mentioned this pull request Mar 27, 2023
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.

None yet

4 participants