-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some touchable components are not working (Native Android devices only) #44643
Comments
Can we get a reproducer? As otherwise it's extremely hard to debug this issue. |
Yes, will follow later today. |
Any news on this? |
|
I edited the original post. This is the repro: https://github.com/DrZoidberg09/RN-Android-Touch-Issue/ |
same issue !! onPressIn and onPressOut is work, but onPress not work only! |
@cortinico Anything else you need from me to look into this? |
on Samsung devices onPress doesn't work. All customers with Samsung devices (S23, S24) are reporting it. any solution to make it work? |
Just chiming in to say that we have been struggling with this as well. Both this issue and #36710 describe our problem quite well, although #36710 got hijacked and closed based on an unrelated bug being addressed (the solved bug had to do with the new architecture, while the OP stated his problem existed before the new architecture was even created). Looking forward to any movement on this issue, because its random nature makes it effectively impossible to reliably reproduce. |
In my scenario, I can reproduce this error 100% of the time (onPress does not respond, but interestingly, the animation effect of TouchableOpacity still shows). I have tested it with Expo 51, Expo 50, React Native 0.74.1, and React Native 0.73.6. The test environment includes Samsung S23 and S24. In a real device environment, even onPressIn and onPressOut do not work, whereas on the emulator, onPressIn and onPressOut respond normally, but onPress does not respond. My scenario is similar to a step-by-step installation guide Page, which is built with a ScrollView in RN. There are about 7 pages within the ScrollView. If a Modal is opened within these pages, the onPress of buttons inside the Modal does not respond. Currently, I have disabled react-native-screens and used onPressOut instead of onPress. Although it works, it causes accidental clicks when scrolling (due to onPressOut). Additionally, to add more context, my ScrollView contains nested ScrollViews. In this environment, onPress 100% fails to respond. The issue does not occur with non-nested ScrollViews. |
@imransilvake @DrZoidberg09 Using react-native-handler-gesture to build a button can temporarily solve this problem. Here is the sample code: export default function Pressable({ onPress, children, style, disabled }) { return ( |
@cortinico In my scenario, the TextInput also cannot be focused. This is indeed a peculiar issue. |
I have the same issue with our app. iOS and Android emulator work fine. iOS production app works fine. Recently though, the Android production app has become relatively unusable. You can log in and within a few seconds, pretty much every pressable item becomes unresponsive. |
@gtwilliams03 If the buttons are not working, you can try the following code: export default function Pressable({ onPress, children, style, disabled }) { return ( |
@tcloudAce Thank you - however this issue is pretty much with anything pressable (not just a button). Buttons, navigation tabs, etc. I should also add that the app responds to presses for a very short period of time (<3 seconds) and then ceases responding to any taps anywhere on the Android device screen. The emulators work fine so this is very difficult to reproduce/test. |
In my case, changing the component layout and applying the above code temporarily solved my problem. The only thing that is certain is that iOS and Android often cannot use the same layout. Code that runs successfully and without issues on Android usually works on iOS, but not the other way around. Moreover, this issue is not only present in the latest versions of React Native but has existed in many past versions as well. I hope this helps everyone. |
Can we get a non-expo reproducer using this template instead: The provided repro is quite involved (uses expo router) and I'd like to isolate this issue as much as possible. |
Tried to reproduce it with pure RN and the repo you shared. So far, I could not reproduce it. Even with the RN-Navigation header issue shown in the other Expo based repro. So far, it seems it's neither react-native nor react-navigation, but Expo(-router). But I will keep trying to reproduce it in the next days. |
That's sometimes related to |
I have react-native-screens and react-navigation stack also running in the repro. Here it works fine. In the main project with Expo it is not. Another weird behavior: If I run Expo development build on the native device most is working pretty ok besides onPress in the header bar. (onPressOut and In is working nicely though). However, if I build a proper apk and run it on the native (Samsung) device. Everything pressable in a stack is not working, incl. every list, button, etc. (Also the positioning of position absolute items is different if I use development build or an apk on the same device...) |
This seems to be very close to the issue as well: software-mansion/react-native-screens#2150 |
@cortinico I could track it down to expo-router. Please look at the github repo. I added a reproducer for each: pure RN, expo with router and expo without router. The two repos without router work. With router it does not. |
Great so let's close it for now and move the conversation over to: expo/expo#30032 |
I was encountering a similar issue -- TouchableOpacity (and other wrappers of Pressable) not working on Android but working fine in iOS. However, I was able to fix the issue by adding a |
I have done a little digging into Pressability.js In my testings of this wonky behaviour.
onPressIn and onPressOut are not using the same State machine conditions, and thus, are not impacted by the issue. Haven't fixed (as adding the prev event to the function is surely not what is supposed to happen), and i am trying to understand a bit more to not do shit, but maybe it can help someone understand more the issue. |
I investigated it a little more and from what I see this is a case of measure not synchronizing correctly with the coordinates of touches. On Android with new architecture the touches will be returned as coordinates relative to the root view. So if the screen you are using is 300 x 700 pixels, it will fall somewhere between that. The Pressablity.js file, mentioned by @littleski then takes those touch coordinates and compares them to the coordinates of the responder (returned by the measure function),
BUT ONLY on the responder move:
And that is why this issue only appears on some android devices which are more sensitive. Emulators and less sensitive devices will never trigger the onResponderMove callback. I found out that this issue can be reproduced on emulators just by moving the mouse a little bit during a touch. As for the reason why this bug even occurs at all, it comes down to the data returned from the measure. The pageX and pageY in some special circumstances will return coordinates far exceeding the boundaries of the screen. From what I tested for now, this is a case for both For now I don't know how to fix it. |
It's definitely a react-native-pager-view issue, since tab-view also relies on that, for now I simply swapped all the buttons in the app with this component
And it seems to work good enough |
Pigging backing on @DominikHinc UiManager
So here is the difference between new arch and old which seems logic. need to dig a bit in the Java to understand the difference and what may have been broken in the new arch java binding. |
@littleski turns out all I had to do was to implement this callstack/react-native-pager-view#836 |
The repro doesn't use this. It's more than likely that this is just a workaround for one lib. I don't use this package either. Might help understand the issue tho. |
i'm also faced same issue after enabling new architecture. |
@ap9101 Thank you for your comment, however, when I upgraded our project to |
Description
For me this issue still the issue #36710 persists on RN 0.74.1, Expo 51.0.8 and react-native-screens 3.31.1 running with fabric.
Same problem: Some components, e.g. custom buttons in the header bar or some modals (not all). This happens only on native Android devices. iOS or Android emulator are fine.
Additionally, native buttons work. Only "normal" RN components don't.
onPressIn works fine, normal onPress does not.
Steps to reproduce
Have the mentioned setup. Use Expo Router with custom buttons or wix rnui ActionSheet (therefore probably not related to third party libs)
React Native Version
0.74.2
Affected Platforms
Runtime - Android
Areas
Fabric - The New Renderer
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/DrZoidberg09/RN-Android-Touch-Issue/
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: