-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Upgrade lottie-react-native to 6.3.1 #28267
Upgrade lottie-react-native to 6.3.1 #28267
Conversation
@roryabraham do you want to review this? Happy to do so but looks like it's your issue |
Sure, sorry for the delay. Going to run a test build to make this faster to test |
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should address the breaking changes in another way than just reverting them.
+ const aspectRatioStyle = sources.sourceJson | ||
+ ? { aspectRatio: (source as any).w / (source as any).h } | ||
+ : undefined; | ||
+ | ||
+ const styleObject = StyleSheet.flatten(style); | ||
+ let sizeStyle; | ||
+ if ( | ||
+ !styleObject || | ||
+ (styleObject.width === undefined && styleObject.height === undefined) | ||
+ ) { | ||
+ sizeStyle = | ||
+ autoSize && sources.sourceJson | ||
+ ? { width: (source as any).w } | ||
+ : StyleSheet.absoluteFill; | ||
+ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that we want to simply revert the breaking changes in the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kosmydel
Hello )
You're probably right
But what's the point of depriving us of default styles?
Which we can always override using props
Which allows us to calculate the height and aspect ratio of the element without unnecessary problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we override using props? I don't really like patching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might also consider passing aspectRatio
as a value/prop instead of calculating it. Just an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be done )
But then we will have to hard code the aspect ratio )
Or
We can take the aspect ratio calculation function from the patch I made
But then does it make sense for each loti component that we use to set the aspect ratio as styles?
If with the patch we will have automatic aspect ratio support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably also put it into some useMemo
. I think that this is still much better than doing it in a patch. Especially when I am working on this related issue. And patching would require regular maintenance if the original library changes.
But there is a problem with this approach. When we move to the .lottie
files we can't access the .w
and .h
so easily, as these animations won't be JSON objects anymore. I'm not sure how should we handle it.
cc @situchan @roryabraham what do you think?
I'm OOO this week so unassigning myself as a reviewer, I think y'all should probably have it covered! |
This reverts commit d9ff6fa.
@situchan |
src/components/ConfirmationPage.js
Outdated
@@ -46,7 +46,7 @@ function ConfirmationPage(props) { | |||
source={props.animation} | |||
autoPlay | |||
loop | |||
style={styles.confirmationAnimation} | |||
style={[styles.confirmationAnimation, styles.aspectRatioLottie(props.animation)]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could possibly add some kind of wrapper to the <Lottie>
component, adding this style, instead of copying the same line several times, with the argument, that is already passed to the component.
Just an idea.
@situchan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull main
package-lock.json
Outdated
"integrity": "sha512-vhdeZstXMfuVKwnddYWjJgQ/1whGL58IJEJu/iSf0XQ5gAb4pp/+vy91mdYQLezlb8Aw4Vu3fKnqErJL2hwchg==", | ||
"version": "6.3.1", | ||
"resolved": "https://registry.npmjs.org/lottie-react-native/-/lottie-react-native-6.3.1.tgz", | ||
"integrity": "sha512-M18nAVYeGMF//bhL27D2zuMcrFPH0jbD/deBvcWi0CCcfZf6LQfx45xt+cuDqwr5nh6dMm+ta8KfZJmkbNhtlg==", | ||
"requires": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this file I generated is different from this branch.
Replace package-lock.json with this done:
ios/Podfile.lock
Outdated
@@ -188,33 +188,33 @@ PODS: | |||
- GoogleUtilities/Network (~> 7.4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need to update lottie related frameworks. Revert all other changes which are out of scope.
Just replace with this file I generated:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 8 lottie animations in the app. Let's make sure all of them are tested in all platforms.
src/styles/styles.js
Outdated
@@ -3779,6 +3779,13 @@ const styles = (theme) => ({ | |||
lineHeight: variables.lineHeightLarge, | |||
}, | |||
|
|||
aspectRatioLottie: (source) => { | |||
if (typeof source === 'object' && !source.uri) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add more safety condition here, though all Lottie JSON may include w
, h
properties.
if (typeof source === 'object' && !source.uri) { | |
if (!source.uri && typeof source === 'object' && source.w && source.h) { |
src/styles/styles.js
Outdated
if (typeof source === 'object' && !source.uri) { | ||
return {aspectRatio: source.w / source.h}; | ||
} | ||
return {aspectRatio: '1'}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer setting this undefined and let user fully customize style properties.
If both width and height are defined, they're skipped because aspectRatio overwrites them.
return {aspectRatio: '1'}; | |
return {}; |
Check this video which demonstrates all animations are working well. You should test like this on all platforms. ios.mov |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@roryabraham all yours
@ZhenjaHorbach can you please resolve the conflicts? |
Done ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@situchan has kindly retested IOS and its working, I will move this ahead
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Performance Comparison Report 📊Significant Changes To Duration
Show details
Meaningless Changes To DurationShow entries
Show details
|
@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker. |
@@ -0,0 +1,3 @@ | |||
import Lottie from './Lottie'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why Lottie.tsx
is written in TS and index.js
in JS? I think Lottie catalog can be removed and Lottie.tsx
file in components
catalog should be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
Lottie.tsx
is written in TS andindex.js
in JS?
This is already existing pattern, i.e. MapView but agree to write TS for all
I think Lottie catalog can be removed and
Lottie.tsx
file incomponents
catalog should be sufficient.
Agree. Unless platform specific or has propTypes in js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the first point, I did it by analogy with other catalogs)
And about the second one, maybe you're right
Seems a little redundant
Should I create a new PR?
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
2 similar comments
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.83-11 🚀
|
Details
Upgrade E/App to use lottie-react-native 6.3.1+
Fixed Issues
$ #28132
PROPOSAL: #28132 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
screen-recording-2023-10-08-at-235606_1uah9PAL.mp4
Mobile Web - Chrome
screen-recording-2023-10-09-at-000924_UD19wRwo.mp4
Mobile Web - Safari
screen-recording-2023-10-09-at-002042_Zf909vHa.mp4
Desktop
screen-recording-2023-10-08-at-235908_90zeamRV.mp4
iOS
screen-recording-2023-10-09-at-002514_Weq83e0S.1.mp4
Android
screen-recording-2023-10-09-at-010520_vgOYOsTn.mp4