Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tomekzaw
marked this pull request as ready for review
October 31, 2026 08:38
This branch has not been deployed
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:
ScrollEvent.getEventData()builds the payload one field at a time from Java. It creates 6WritableNativeMaps (oneinitHybridcall each) and makes 20put*calls, so each scroll event costs 26 calls into C++. Scroll events are sent up to once per frame on the UI thread while scrolling.Now Kotlin fills a
DoubleArraywith the 9 numeric fields and makes one call,ScrollEventHelper.nativeCreateScrollPayload. C++ builds the whole payload as oneWritableNativeMap. This is the same approach as the touch payload in #59554. The payload has the same keys and values as before.Changelog:
[ANDROID] [CHANGED] - Build the scroll event payload in one JNI call
Test Plan:
Time per
getEventData()call (timer around it inEvent.dispatchModern) on a PlaygroundScrollViewwith 300 rows,scrollEventThrottle={16}and anonScrollhandler, swiped up and down withadb shell input swipefor the whole window:ScrollEvent.getEventData()For comparison, an unchanged path timed in the same runs (
UpdateStatemount items) moved by 0–6%.Setup:
./gradlew :packages:rn-tester:android:app:assembleRelease -PreactNativeArchitectures=arm64-v8a, R8 on) with default feature flags, compiled withcmd package compile -m speed.mainand this PR (16 processes per build).Payload check: on the moto g57 power, a Playground screen shows the
nativeEventof the last scroll event as JSON. After the same swipe onmainand with this PR, the keys match, and so docontentInset,contentOffset,contentSize,layoutMeasurement,targetandresponderIgnoreScroll. Only the time-dependent fields (velocityand the timestamp) differ.Checks:
yarn cxx-api-build, thenyarn cxx-api-validate(Doxygen 1.16.1): all 12 snapshots match. The new header addsScrollEventHelperto the 4 Android snapshots.yarn format-check-cppandyarn format-check-kotlinpass.Pointer events build their payloads the same way, but they're off by default (
dispatchPointerEvents), so I left them out.🤖 Generated with Claude Code