react-native icon indicating copy to clipboard operation
react-native copied to clipboard

fix animated value synchronization on detach

Open daniel-nagy opened this issue 4 years ago • 6 comments

Summary

When an animated value node is detached, and native animations are enabled, the value is synchronized with the native state. However, this incorrectly includes the offset in the value.

The problem was introduced with this commit https://github.com/facebook/react-native/commit/d92284216f4b079079f7ee479f35c94c900bc701. This PR adds a new method called getState that returns both the raw value and offset of the animated value. I added a new method to avoid breaking changes.

Changelog

[General] [Fixed] - Fix synchronization of animation state when animation completes when using native animations.

Test Plan

daniel-nagy avatar Jul 28 '21 22:07 daniel-nagy

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: f592ad05096542e0d010c1972b7fe1f76687e78e

analysis-bot avatar Jul 28 '21 23:07 analysis-bot

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 9,177,374 -73
android hermes armeabi-v7a 8,702,655 -178
android hermes x86 9,620,032 -168
android hermes x86_64 9,585,858 -174
android jsc arm64-v8a 10,814,158 +131
android jsc armeabi-v7a 9,730,721 +33
android jsc x86 10,852,231 +47
android jsc x86_64 11,459,562 +37

Base commit: f592ad05096542e0d010c1972b7fe1f76687e78e

analysis-bot avatar Jul 28 '21 23:07 analysis-bot

Instead, what do you think about making the method signature:

getValueOffset(tag: number, callback: (value: number, offset: number) => void): void

It saves from having to create the object, and it is also more clear than getState.

And is the plan to deprecate and eventually delete getValue?

yungsters avatar Sep 10 '21 21:09 yungsters

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Apr 09 '22 02:04 github-actions[bot]

I'd like to learn more on the context with this PR:

  1. We want to carry over the animated value from unmounted native view, so that if the same native animated value is used later, we can resume animation from the last value.
  2. With the current implementation, we are actualy getting the animated value + offset. The offset is used to compensate things with a certain animation (doc).
  3. However, the problem seems when resuming animated value, the offset could be different, and we don't want to preserve the offset, but only the value?

Can you show an example where item 3 is happening and caused issues? There's no linked issues in this PR, nor test plan. Those are important for me to help merge this faster.

ryancat avatar Jul 31 '23 18:07 ryancat

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

react-native-bot avatar Sep 04 '24 05:09 react-native-bot

This PR was closed because it has been stalled for 7 days with no activity.

react-native-bot avatar Sep 11 '24 05:09 react-native-bot