Skip to content

Android: preserve NestedScrollView fling nested-scroll lifecycle - #57972

Open
AmatoGiulio wants to merge 1 commit into
react:mainfrom
AmatoGiulio:android-nested-scrollview-fling
Open

Android: preserve NestedScrollView fling nested-scroll lifecycle#57972
AmatoGiulio wants to merge 1 commit into
react:mainfrom
AmatoGiulio:android-nested-scrollview-fling

Conversation

@AmatoGiulio

Copy link
Copy Markdown

Summary:

ReactNestedScrollView is generated from ReactScrollView, but the generated class extends AndroidX NestedScrollView.

For ordinary non-paging flings, the generated override currently invokes the reflected OverScroller directly and calls postInvalidateOnAnimation(). That bypasses NestedScrollView.fling(), so AndroidX never starts its TYPE_NON_TOUCH nested-scroll lifecycle.

This change keeps ReactScrollView unchanged and adjusts only the generated nested variant:

  • pagingEnabled continues to use the existing flingAndSnap() path;
  • ordinary ReactNestedScrollView flings delegate to super.fling(correctedVelocityY);
  • React Native still initiates/owns the fling and keeps its existing momentum-event handling;
  • the generator validates that the copied scroller branch exists exactly once before replacing it, failing closed if the source shape changes.

The generated ReactNestedScrollView.kt is regenerated from the updated generator.

Changelog:

[ANDROID] [FIXED] - Preserve the AndroidX non-touch nested-scroll lifecycle during ordinary ReactNestedScrollView flings.

Test Plan:

Generator validation:

node generate-nested-scroll-view.js
node generate-nested-scroll-view.js --verify

PASS

The same transformation was also regenerated successfully from the current 0.87-stable source shape.

RN 0.87 Android runtime probe with useNestedScrollViewAndroid=true, comparing stock and patched source with identical native fling velocities:

case                      velocity      stock NT  patched NT   stock y   patched y
ordinary-low              2500          0         1            178.29    178.29
ordinary-high             8000          0         1            1345.14   1345.14
top-edge                  -6000         0         1            0.00      0.00
bottom-edge                6000         0         1            18357.7   18357.7
deceleration-normal        6000         0         1            816.00    816.00
deceleration-fast          6000         0         1            201.90    201.90
perf-tag                   5000         0         1            594.67    594.67
paging                     6000         0         0            842.29    842.29
snap-interval              6000         0         0            960.00    960.00
snap-offsets               6000         0         0            2400.00   2400.00
disableIntervalMomentum    6000         0         0            1440.00   1440.00
programmatic               -             0         0            720.00    720.00

For ordinary deterministic flings, stock and patched final distances were identical (0.00% delta) while the patched source opened the AndroidX non-touch nested-scroll lifecycle. decelerationRate preserved the same fast/normal ratio (0.2474 in both variants).

A physical touch-fling probe also changed from TOUCH/NON_TOUCH = 1/0 stock to 1/1 patched.

Paging/snap cases remained on flingAndSnap() with NON_TOUCH = 0 in both variants and identical endpoints. Interruption and deterministic reversal (+8000 → touch interrupt → -8000) also passed.

The paging/snap branch is intentionally unchanged.

@meta-cla

meta-cla Bot commented Aug 16, 2026

Copy link
Copy Markdown

Hi @AmatoGiulio!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Aug 16, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla 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 Aug 16, 2026
@AmatoGiulio
AmatoGiulio marked this pull request as ready for review August 16, 2026 15:36
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 16, 2026
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant