Repository navigation
[Android] Keep HasChildPressedStateDelay in minified builds - #4654
Conversation
…dState works in minified builds
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Add and distribute the consumer rule packages/react-native-gesture-handler/android/consumer-rules.pro, packages/react-native-gesture-handler/android/build.gradle, packages/react-native-gesture-handler/package.json |
The rule retains HasChildPressedStateDelay and its setHasChildPressedStateDelay(Boolean) method. The Android build registers the rule, and the package includes it in its published files. |
Suggested reviewers: j-piasecki, coado
Priority:
Severity of issue fixed: Medium
Merge Risk: 
Minimal · up to 9cc24
-
The ProGuard protection is correctly distributed, so this change is ready to merge.
Pre-merge checks: 
3
-
Full details: Linked Issues check
-
Explanation
Issue
#4652requires that Android delaysChildPressedState={false} take effect in minified release builds. The reflective lookup in NativeViewGestureHandler.kt uses Class.forName("com.facebook.react.uimanager.HasChildPressedStateDelay").getMethod("setHasChildPressedStateDelay", Boolean::class.javaObjectType), which is java.lang.Boolean. The new android/consumer-rules.pro contains -keep interface com.facebook.react.uimanager.HasChildPressedStateDelay { void setHasChildPressedStateDelay(java.lang.Boolean); }. The interface name and the parameter type both match the reflective lookup, so R8 keeps the interface name and the setter. android/build.gradle adds consumerProguardFiles 'consumer-rules.pro' to defaultConfig, so the rule reaches consumer builds. The PR test plan reports that the minified delay drops from +102 ms to +0 ms for delaysChildPressedState={false}, and that mapping.txt no longer renames the interface. The keep rule addresses the requirement. The#4653consequence is a separate issue and is not a requirement of this PR. The rule is a consumer rule, so it does not change the library's own build output. No coding requirement remains unmet.
Full details: Out of Scope Changes check
-
Explanation
The PR changes three files. android/consumer-rules.pro adds the keep rule for the reflectively accessed interface and setter, which implements
#4652. android/build.gradle registers the rule as a consumer ProGuard file, which makes the rule effective for consumers. package.json adds android/consumer-rules.pro to the published files list, so the rule ships with the package. Each change connects directly to the fix. No unrelated change was found. The packaging change was assessed from the change summary and the diff of build.gradle; the package.json diff was not read directly, but the summary states a one-line addition to files.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Description
On Android,
delaysChildPressedState={false}has no effect in a release build that R8 minifies. ATouchableinside such aScrollViewstill enters its pressed state only after the tap timeout, exactly like one in aScrollViewthat keeps the delay.NativeViewGestureHandlerlooks upHasChildPressedStateDelay.setHasChildPressedStateDelayby reflection, since the interface only exists since React Native 0.87. Nothing else references it, so R8 renames the interface and drops its methods.getMethodthen throws, the setter staysnulland the option becomes a no-op.This adds a consumer ProGuard rule that keeps the interface and its setter, and lists it in the package
filesso it is published.Fixes #4652
Test plan
Tested on an API 34 emulator with
basic-example(RN 0.88.0) in release builds, with aScrollViewof each kind holding aTouchable. I logged the time from the raw touch-down toonPressInafter a 400 ms hold (adb shell input swipe x y x y 400):delaysChildPressedState={false}delaysChildPressedState={true}In the minified
mapping.txt,HasChildPressedStateDelayis no longer renamed.Not tested on React Native versions older than 0.87, where the interface does not exist and the rule matches nothing.