You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Android with New Architecture, a ScrollView with maintainVisibleContentPosition draws one stale frame when an item is prepended. The rows move down by the height of the new item for one frame, then move back. In a chat list with live traffic this happens on every incoming message
The bug needs two conditions, both can be encountered when utilising virtualised list (observed first with LegendList 3):
The anchor child and the item children move in the same Fabric mount, so the helper corrects the scroll offset for that mount
Nothing in that mount changes the size of the content container. In LegendList the container height is an Animated.Value, so it reaches native in a separate update. If the content resizes in the same mount, the layout pass invalidates the ScrollView and the frame is correct. That is why a plain prepend of flex children does not show it
The stale frame comes from MaintainVisibleScrollPositionHelper. In didMountItems it calls scrollToPreservingMomentum on the ReactScrollView, but nothing invalidates the ScrollView in that frame. View.scrollTo only calls postInvalidateOnAnimation, which lands in the next frame. The moved children have already invalidated themselves for the current frame, so the current frame draws the new child positions through the old ScrollView display list, which still holds translate(-oldScrollY)
Description
On Android with New Architecture, a
ScrollViewwithmaintainVisibleContentPositiondraws one stale frame when an item is prepended. The rows move down by the height of the new item for one frame, then move back. In a chat list with live traffic this happens on every incoming messageThe bug needs two conditions, both can be encountered when utilising virtualised list (observed first with LegendList 3):
Animated.Value, so it reaches native in a separate update. If the content resizes in the same mount, the layout pass invalidates theScrollViewand the frame is correct. That is why a plain prepend of flex children does not show itThe stale frame comes from
MaintainVisibleScrollPositionHelper. IndidMountItemsit callsscrollToPreservingMomentumon theReactScrollView, but nothing invalidates theScrollViewin that frame.View.scrollToonly callspostInvalidateOnAnimation, which lands in the next frame. The moved children have already invalidated themselves for the current frame, so the current frame draws the new child positions through the oldScrollViewdisplay list, which still holdstranslate(-oldScrollY)Steps to reproduce
yarn && yarn android(yarn berry)ScrollViewafter mount to see the jump stopReact Native Version
0.86.3
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
https://github.com/Critteros/rn-android-mvcp-one-frame-jump
Screenshots and Videos
Reproduction:
issue.mp4
With invalidation:
invalidation-workaround.mp4