react / react/react-native

[Android][New Arch][Pressable] the `locationY` and `locationX` on Android are inconsistent

Offen
#53,366 8 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs: Triage :mag: Platform: Android
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

Description

To make a separate issue of:
https://github.com/facebook/react-native/issues/36710#issuecomment-3204826621

It's been like 1 year there is many issues reported on Android about onPress not fired (in issues of this repo and by a lot of end-user).
Since I cannot reproduce because a lot of this issue are "random", I was looking for an alternative with an onPressOut workaround.
Was able to implement a full working workaround on iOS (scroll management, hitslop, ...) but when switching to Android everything was broke. My solution was based on locationY and locationX but after investigation, I noticed that the value of locationY and locationX on Android is not correct.

For exemple, when the onPressOut is triggered because the touch goes out of the screen, the locationY is equal to pageY.
When the onPressOut is trigger after the touch leave the Pressable, but still on another Pressable (stacked Button for exemple). The locationY looks like it's the value inside the second Pressable (expected 80, but received 15 for exemple).

Impact Touchables (WithoutFeedBack, Opacity, ...).

I don't know if it's the root-cause of all onPress issue, but might not help to handle it correctly.

In the code, found out that there is a "Legacy" / "non-legacy" logic that might explain why it's only on new-arch.

https://github.com/facebook/react-native/blob/d1a1020a4ab2f9bc5075598465b61fd83a45abd0/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt#L113

Regards

Steps to reproduce
  1. Create two Pressable with onPressOut, log the locationX and locationY
  2. Start pressing the first Pressable the slide quickly to the second one.
  3. The onPressOut of the first one is triggered but display invalid value locationX/Y (supposed to be the calculated values of the second Pressable).
React Native Version

0.80.2

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.6
  CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Memory: 13.99 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.16.0
    path: ~/.nvm/versions/node/v22.16.0/bin/node
  Yarn:
    version: 1.22.17
    path: ~/.yarn/bin/yarn
  npm:
    version: 11.5.1
    path: ~/.nvm/versions/node/v22.16.0/bin/npm
  Watchman:
    version: 2025.07.14.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13930704
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.1
    path: /usr/local/opt/bin/javac
  Ruby:
    version: 3.4.5
    path: /usr/local/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 19.1.1
    wanted: ^19.1.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.80.2
    wanted: ^0.80.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
See console.log of reproducer / video
MANDATORY Reproducer

https://github.com/Dallas62/rn-pressabe-issue-location

Screenshots and Videos

https://github.com/user-attachments/assets/5c6ba929-e44a-440c-909e-7b41c893c347

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne bei ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt in der Nähe der referenzierten Zeile und führe den obligatorischen rn-pressabe-issue-location-Reproduktionsfall auf Android mit aktivierter neuer Architektur aus. Vergleiche locationX und locationY aus dem onPressOut des ersten Pressable, während du in das zweite oder aus dem Bildschirm hinaus bewegst; abgeschlossen ist es, wenn die gemeldeten Koordinaten mit den erwarteten Werten des betroffenen Pressable übereinstimmen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, kotlin, react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
52/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.