Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fabric support for iOS#955

Merged
matinzd merged 15 commits into
lottie-react-native:masterfrom
alfonsocj:fabric-ios
Jan 17, 2023
Merged

Fabric support for iOS#955
matinzd merged 15 commits into
lottie-react-native:masterfrom
alfonsocj:fabric-ios

Conversation

@alfonsocj

@alfonsocj alfonsocj commented Dec 16, 2022

Copy link
Copy Markdown
Contributor

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.

Comment thread apps/fabric/ios/Podfile.lock
Comment thread packages/core/ios/Fabric/LottieAnimationViewComponentView.h
Comment thread packages/core/ios/Fabric/LottieAnimationViewComponentView.mm
Comment thread packages/core/ios/Fabric/LottieContainerView.h
Comment thread packages/core/ios/Fabric/RNLottieFabricConversions.h
Comment thread packages/core/ios/LottieReactNative/ContainerView.swift Outdated
@alfonsocj

Copy link
Copy Markdown
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

Comment thread packages/core/src/specs/LottieAnimationViewNativeComponent.ts
@alfonsocj

alfonsocj commented Dec 19, 2022

Copy link
Copy Markdown
Contributor Author

@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.

Comment thread packages/core/ios/LottieReactNative/ContainerView.swift
@alfonsocj alfonsocj marked this pull request as ready for review December 20, 2022 16:46
@alfonsocj

Copy link
Copy Markdown
Contributor Author

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

@matinzd

matinzd commented Dec 20, 2022

Copy link
Copy Markdown
Member

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

@matinzd matinzd self-requested a review December 20, 2022 17:00
Comment thread packages/core/ios/LottieReactNative/ContainerView.swift
Comment thread packages/core/ios/Fabric/LottieAnimationViewComponentView.h
Comment thread packages/core/src/specs/LottieAnimationViewNativeComponent.ts
Comment thread packages/core/lottie-react-native.podspec
@alfonsocj

Copy link
Copy Markdown
Contributor Author

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

@matinzd

matinzd commented Jan 4, 2023

Copy link
Copy Markdown
Member

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

I am going to test this tonight. πŸš€

@matinzd

matinzd commented Jan 5, 2023

Copy link
Copy Markdown
Member

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

@matinzd

matinzd commented Jan 5, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown

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

matinzd commented Jan 11, 2023

Copy link
Copy Markdown
Member

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

alfonsocj commented Jan 11, 2023

Copy link
Copy Markdown
Contributor Author

@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

matinzd commented Jan 11, 2023

Copy link
Copy Markdown
Member

@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

alfonsocj commented Jan 11, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

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

@matinzd

matinzd commented Jan 11, 2023

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@alfonsocj

Copy link
Copy Markdown
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

alfonsocj commented Jan 11, 2023

Copy link
Copy Markdown
Contributor Author

@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

matinzd commented Jan 17, 2023

Copy link
Copy Markdown
Member

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

@matinzd matinzd left a comment

Copy link
Copy Markdown
Member

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.

4 participants