-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Animated: Optimize onUserDrivenAnimationEnded
Deopt
#48511
Open
yungsters
wants to merge
3
commits into
facebook:main
Choose a base branch
from
yungsters:export-D67872307
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+99
−126
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Jan 6, 2025
This pull request was exported from Phabricator. Differential Revision: D67872307 |
Summary: While refactoring `Animated`, I noticed that many subclasses of `AnimatedNode` override `__attach` without invoking the superclass method, even though we do this for `__detach`. In order to minimize surprise (e.g. if someone were to add logic into `AnimatedNode.prototype.__attach`), this diff updates all method overrides to invoke `super.__attach()`. Changelog: [Internal] Differential Revision: D67884975
This pull request was exported from Phabricator. Differential Revision: D67872307 |
yungsters
added a commit
to yungsters/react-native
that referenced
this pull request
Jan 7, 2025
Summary: Pull Request resolved: facebook#48511 {D60499583} added a new`onUserDrivenAnimationEnded` listener that requires `AnimatedValue` instances to have up-to-date values reported by `onAnimatedValueUpdate` (if native driver is in use). Previously, the only way to ensure `onAnimatedValueUpdate` events were always fired to update JavaScript values in `AnimatedValue` instance was to attach a listener — even an empty one. This is exactly what D60499583 did: it traverses `props` for `AnimatedNode` instances and attaches listeners to them. However, this is really inefficient and makes the code extra convoluted. Instead, this diff changes `AnimatedValue` so that it always subscribes to changes in `__attach`, and then it cleans up the extraneous props traversal and "empty listener" logic. Changelog: [Internal] Differential Revision: D67872307
yungsters
force-pushed
the
export-D67872307
branch
from
January 7, 2025 01:40
9fe42e9
to
a1fbc81
Compare
Summary: Currently, `AnimatedNode` implements logic to start listening to updates on the current native node if a listener is added. However, the `startListeningToAnimatedNodeValue` native module method only supports native tags for instances of `AnimatedValue`, which is a subclass of `AnimatedNode`. In fact… * On Android, [`startListeningToAnimatedNodeValue`](https://fburl.com/code/bdsl4sro) throws if the node is not an instance of `ValueAnimatedNode`. * On iOS, [`startListeningToAnimatedNodeValue`](https://fburl.com/code/hlpk1rzk) does nothing if node is not an instance of `RCTValueAnimatedNode`. As such, this refactors `AnimatedNode` to never manage this subscription for native nodes. Instead, the logic is moved into the `AnimatedValue` subclass, ensuring that we never accidentally try to `startListeningToAnimatedNodeValue` with non-`AnimatedValue` native tags. Changelog: [Internal] Differential Revision: D67884973
Summary: Pull Request resolved: facebook#48511 {D60499583} added a new`onUserDrivenAnimationEnded` listener that requires `AnimatedValue` instances to have up-to-date values reported by `onAnimatedValueUpdate` (if native driver is in use). Previously, the only way to ensure `onAnimatedValueUpdate` events were always fired to update JavaScript values in `AnimatedValue` instance was to attach a listener — even an empty one. This is exactly what D60499583 did: it traverses `props` for `AnimatedNode` instances and attaches listeners to them. However, this is really inefficient and makes the code extra convoluted. Instead, this diff changes `AnimatedValue` so that it always subscribes to changes in `__attach`, and then it cleans up the extraneous props traversal and "empty listener" logic. Changelog: [Internal] Differential Revision: D67872307
This pull request was exported from Phabricator. Differential Revision: D67872307 |
yungsters
force-pushed
the
export-D67872307
branch
from
January 7, 2025 08:10
a1fbc81
to
a2230ad
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
{D60499583} added a new
onUserDrivenAnimationEnded
listener that requiresAnimatedNode
instances to have up-to-date values reported byonAnimatedValueUpdate
(if native driver is in use).Previously, the only way to ensure
onAnimatedValueUpdate
events were always fired to update JavaScript values inAnimatedNode
instance was to attach a listener — even an empty one. This is exactly what D60499583 did: it traversesprops
forAnimatedNode
instances and attaches listeners to them.However, this is really inefficient and makes the code extra convoluted. Instead, this diff changes
AnimatedNode
so that it always subscribes to changes in__attach
, and then it cleans up the extraneous props traversal and "empty listener" logic.Changelog:
[Internal]
Differential Revision: D67872307