software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.67k stars 1.27k forks source link

onPress not work correctly #5977

Open pigeonmal opened 2 months ago

pigeonmal commented 2 months ago

Description

(first i thought is bug from react-native, but after checks, is from react-native-reanimated) I try to create my bottom sheet. onPress work only one time, when pressable component is in root. Sometimes it's just the first time click, sometimes is after many clicks, and after does not work anymore. onPressIn work perfectly

The bug is on v0.73.7 (new arch, bridgless false) and v0.74.0 (new arch, bridgless true), tested only on Android.

This is video of the bug:

https://github.com/software-mansion/react-native-reanimated/assets/40658543/32760efb-1c29-4bcf-b51f-cd9a40c95f90

Steps to reproduce

(TEST ON ANDROID, v0.73.7, and v0.74.0, new arch)

1) clone my reproducer 2) try building, and verify the bug

Snack or a link to a repository

https://github.com/pigeonmal/react-native-onpress-bug

Reanimated version

3.9.0

React Native version

0.74.0

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Fabric (New Architecture)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

v27855 commented 1 month ago

Familiar issue from my project, a few things I tried for my case:

  1. My React Native version is 0.72.7, and the Reanimated version is 3.7.1. This issue only occurs on Android.
  2. If I upgrade Reanimated to 3.10.*, this issue will be resolved, but it will cause another initialization issue for both iOS and Android.
  3. The issue affects onPress and onLongPress, while onPressIn and onPressOut work fine, but it's not ideal to use them.
  4. It is related to the Animate.View component from Reanimated. The issue is resolved if I use Animate.View from React Native instead.
  5. Not related to react-native-gesture-handler (Updated from below)
  6. This issue only occurs in the build version on Android.
  7. Not all the Animate.View from Reanimated has this issue, only wrapped by a parent component which has position: absolute
pigeonmal commented 1 month ago

2. If I upgrade Reanimated to 3.10.*, this issue will be resolved, but it will cause another initialization issue for both iOS and Android.

Oh I will try to update to 3.10 for test, but what is your initialization issue ?

v27855 commented 1 month ago

Few updates for this issue:

  1. This issue only occurred on Samsung Devices, tested on Galaxy s22.
  2. I updated reanimated to 3.10.0, and react-native to 0.74.1. The initialization issue disappeared. But the onPress issue still exists.
  3. Found this issue on stackoverflow, which is similar case for me. Now it may related to react-native-gesture-handler.
  4. The onPress event can triggered through the remote of Android Studio.

You may try using onPressIn to check is that we are same issue

Now I'm confused and hopeless on this issue, after making a big effort to upgrade the react-native and finding out it may not related to the version of reanimated.

pigeonmal commented 1 month ago

onPressIn work perfectly

Yes for me onPressIn work perfectly like you, so I think it's the same issue. I try to update to 0.74.1, and reanimated to 3.11.0, and still the same issue. (I tested on android phone, not samsung). Check my reproducer https://github.com/pigeonmal/react-native-onpress-bug