Fix native-driven props dropped on Animated.FlatList/SectionList under shared animated backend (#57178)#57178
Open
zeyap wants to merge 1 commit into
Open
Fix native-driven props dropped on Animated.FlatList/SectionList under shared animated backend (#57178)#57178zeyap wants to merge 1 commit into
zeyap wants to merge 1 commit into
Conversation
|
@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108155219. |
…r shared animated backend (react#57178) Summary: ## Changelog: [Internal][Fixed] - Fix native-driven props dropped on Animated.FlatList/SectionList under shared animated backend Under the shared animated backend (`cxxNativeAnimatedEnabled` + `useSharedAnimatedBackend`), a `useNativeDriver: true` animation on `Animated.FlatList` or `Animated.SectionList` (or any class composite that wraps a host) was silently dropped — e.g. an opacity fade never committed, so the content stayed at its initial value. Root cause: `AnimatedProps.#connectShadowNode` resolves the target shadow node via `getNodeFromPublicInstance(target.instance)`. `FlatList`/`SectionList` are class components (not `forwardRef`-to-host), so the ref is the composite instance, which has no `__internalInstanceHandle`; `getNodeFromPublicInstance` returns `null` and `connectAnimatedNodeToShadowNodeFamily` is never called. The C++ shared backend commits animated props only through a connected `ShadowNodeFamily` and has no viewTag fallback when `useSharedAnimatedBackend` is enabled, so the value is dropped. `Animated.View` and `Animated.ScrollView` are unaffected because their ref is the host instance; with `cxxNativeAnimatedEnabled` alone the legacy viewTag path still commits, so this only regresses once the shared backend is on. Fix: in `#connectShadowNode`, resolve the shadow node from the host instance rather than the composite — try the instance, then `getNativeScrollRef()` (covers `FlatList`/`SectionList`), then fall back to the host tag that `#connectAnimatedView` already resolved via `findNodeHandle`, looked up natively with `findShadowNodeByTag_DEPRECATED`. The `#connectAnimatedView` viewTag path is unchanged. Reviewed By: cipolleschi, javache Differential Revision: D108155219
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
Changelog:
[Internal][Fixed] - Fix native-driven props dropped on Animated.FlatList/SectionList under shared animated backend
Under the shared animated backend (
cxxNativeAnimatedEnabled+useSharedAnimatedBackend), auseNativeDriver: trueanimation onAnimated.FlatListorAnimated.SectionList(or any class composite that wraps a host) was silently dropped — e.g. an opacity fade never committed, so the content stayed at its initial value.Root cause:
AnimatedProps.#connectShadowNoderesolves the target shadow node viagetNodeFromPublicInstance(target.instance).FlatList/SectionListare class components (notforwardRef-to-host), so the ref is the composite instance, which has no__internalInstanceHandle;getNodeFromPublicInstancereturnsnullandconnectAnimatedNodeToShadowNodeFamilyis never called. The C++ shared backend commits animated props only through a connectedShadowNodeFamilyand has no viewTag fallback whenuseSharedAnimatedBackendis enabled, so the value is dropped.Animated.ViewandAnimated.ScrollVieware unaffected because their ref is the host instance; withcxxNativeAnimatedEnabledalone the legacy viewTag path still commits, so this only regresses once the shared backend is on.Fix: in
#connectShadowNode, resolve the shadow node from the host instance rather than the composite — try the instance, thengetNativeScrollRef()(coversFlatList/SectionList), then fall back to the host tag that#connectAnimatedViewalready resolved viafindNodeHandle, looked up natively withfindShadowNodeByTag_DEPRECATED. The#connectAnimatedViewviewTag path is unchanged.Reviewed By: cipolleschi, javache
Differential Revision: D108155219