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 performance in shine animation #56

Closed
wants to merge 1 commit into from

Conversation

hotchemi
Copy link

@hotchemi hotchemi commented Oct 1, 2018

Thank you for the amazing library!

While using shine animation we noticed it uses so much CPU power and leaks memory, and after changing to use fade animation that kind of thing never happens.

After comparing two animation logic we realized differences below:

  • Activate useNativeDriver option
  • Fix to start animation only when finished

So this PR addresses above two points. What do you think?

ref: #33

- Activate useNativeDriver option
- Fix to start animation in callback only when finished
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.08%) to 83.761% when pulling bc2d569 on hotchemi:hotchemi/tweak_shine into d26d2ca on mfrachet:master.

@mfrachet
Copy link
Owner

mfrachet commented Oct 2, 2018

Hello and thanks for the PR! 😄

I'm sorry, I'm from Europe and can't answer you as soon as I would like 😅 .

Can you fix the problem concerning the test coverage?

Again, thank you! 👌

@@ -27,9 +28,12 @@ const Shine = ({ children }) => {
Animated.timing(animation, {
toValue: END_VALUE,
duration: DURATION,
useNativeDriver,
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure useNativeDriver is useful right there since it's not applicable to marginLeftanimation (https://facebook.github.io/react-native/docs/animations#caveats) 😊

]).start(() => {
start();
]).start((e) => {
if (e.finished) {
Copy link
Owner

Choose a reason for hiding this comment

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

Well, I don't know if it's a way to solve the problem:

When calling start, we start the animation. I think the callback is immediately called. What is it's not finished yet? Does it mean that we would run the animation only once?

Thanks for your help 👍

Copy link

Choose a reason for hiding this comment

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

I also see this issue and testing (e.finished) does fix the memory leak we are seeing.

The callback to start is called when the animation is complete and not immediately, so we must test if it finished correctly or was terminated for some reason, otherwise any cancelled or stopped animation will just be started again.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure the OP will continue this pr 😅

You'd like to take the point on a separate PR? Or would you like me to dot it? 😊

Copy link

Choose a reason for hiding this comment

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

Would be great if you could do it - I was in the midst of forking and fixing to be able to pull in our package.json :)

Copy link

Choose a reason for hiding this comment

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

But useNativeDriver is not needed and crashes for me as per you comment marginLeft is not supported

@mfrachet
Copy link
Owner

Close and fixed in the v1.3.0 release, changelog here:

https://github.com/mfrachet/rn-placeholder/blob/master/CHANGELOG.md

@hotchemi hotchemi deleted the hotchemi/tweak_shine branch October 15, 2018 17:19
@hotchemi
Copy link
Author

Ooh sorry I forgot to address but thank you guys! @mfrachet @kabram 🙇

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