-
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
[Android] Inverted FlatList + Text Input causing ANR on android 13 #35350
Comments
#35155 |
Interestingly the TextInput works for me on the device but stops working once it's next to an inverted FlatList. So I am not entirely sure if it's related, but I will test the reproduction of the issue you mentioned as well! |
Observations I made:
style={{
transform: [{scaleY: -1}],
}}
contentContainerStyle={{
transform: [{scaleY: -1}],
}}
Still looking for the place that's causing the issue 🔍 |
@hannojg we had the same problem with our app. We are using the inverted FlatList in our chat screen. One time I wasn't typing, I was just receiving messages and the app froze. So I'm not 100% sure the TextInput is needed to repro. The workaround we implemented was to invert the list with styles instead of the prop. You can check the solution in this Github issue. Ah! And also this issue was happening only for Pixel devices with Android 13. Since the first family of devices to get Android 13 was the Pixel, maybe that's why we only saw this issue in Pixel devices. |
Wow thx for sharing this information, will give it a try! What I found is, that you don't even need a list. You just need two views that have <View
style={{
flex: 1,
backgroundColor: 'red',
transform: [{scaleY: -1}],
}}>
<View
style={{
transform: [{scaleY: -1}],
}}>
{/* Some more children inside here that got inverted */} However, I still need to input text constantly into a TextInput to cause the ANR 😅 |
Okay, the issue doesn't happen anymore if I also add <View
style={{
flex: 1,
backgroundColor: 'red',
transform: [{scaleX: -1}, {scaleY: -1}],
}}>
<View
style={{
transform: [{scaleX: -1}, {scaleY: -1}],
}}> Going to dig into the native code to see where the issue happens, maybe also a bug with yoga? |
@hannojg @JuanAlejandro sorry for telling this, this problem was occured at real device of galaxy22 with google play system version - 22.07.01, but, after updating google play system version to '22.10.01'. the problem was disappeared. ( i could not test my local, that device is our customer. ) |
This is a temporary addition to help circumvent a bug on android. Long term we want to fix the root cause of the problem. - RN issue: facebook#35350 - Expensify issue: Expensify/App#11321 (comment)
I just found the offending line that's causing the issue. If I remove the react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java Lines 441 to 483 in e504141
|
This is a temporary addition to help circumvent a bug on android. Long term we want to fix the root cause of the problem. - RN issue: facebook#35350 - Expensify issue: Expensify/App#11321 (comment)
So at this point, I was able to reproduce the issue with just a native android project (no react native involved). It's a bug in the android framework. I tried to create an issue ticket on the AOSP, however, after creation, I get weird permission errors and the bug ticket just disappears. Sorry for the ping, but maybe @cortinico you can help with opening a bug ticket for the android team (I recall you were an android engineer? 😅 )? The bug report for the native android looks like this:Setting
|
You can do so by yourself here: |
Closign also as it's a Android Bug apparently. Feel free to reopen if they send you here |
@hannojg Hi, have you opened a bug ticket for the android team? Same issue here. |
Yeah that's the point, opening a bug ticket at https://issuetracker.google.com/issues doesn't work for me and results in permission errors. |
I will have a try. And I noticed that you have forked the React Native repo and added a |
@hannojg I believe I succeeded to add it with the correct info and at the right place (the issue tracker is a jungle 😅) https://issuetracker.google.com/issues/261572772 |
@EmilScherdin unfortunately not, I can't open that issue either: |
The issue is closed. Then what is the workaround or any update in react native? Can someone help me please |
Summary: This PR is a result of this PR, which got merged but then reverted: - #37913 We are trying to implement a workaround for #35350, so react-native users on android API 33+ can use `<FlatList inverted={true} />` without running into ANRs. This is the native part, where we add a new internal prop named `isInvertedVirtualizedList`, which can in a follow up change be used to achieve the final fix as proposed in #37913 However as NickGerleman pointed out, its important that we first ship the native change. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [ADDED] - Native part of fixing ANR when having an inverted FlatList on android API 33+ Pull Request resolved: #38071 Test Plan: - Check the RN tester app and see that scrollview is still working as expected - Add the `isInvertedVirtualizedList` prop as test to a scrollview and see how the scrollbar will change position. Reviewed By: rozele Differential Revision: D47062200 Pulled By: NickGerleman fbshipit-source-id: d20eebeec757d9aaeced8561f53556bbb4a492e4
Summary: This PR is a result of this PR, which got merged but then reverted: - #37913 We are trying to implement a workaround for #35350, so react-native users on android API 33+ can use `<FlatList inverted={true} />` without running into ANRs. As explained in the issue, starting from android API 33 there are severe performance issues when using scaleY: -1 on a view, and its child view, which is what we are doing when inverting the ScrollView component (e.g. in FlatList). This PR adds a workaround. The workaround is to also scale on the X-Axis which causes a different transform matrix to be created, that doesn't cause the ANR (see the issue for details). However, when doing that the vertical scroll bar will be on the wrong side, thus we switch the position in the native code once we detect that the list is inverted, using the newly added `isInvertedVirtualizedList` prop. This is a follow up PR to: - #38071⚠️ **Note:** [38071](#38071) needs to be merged and shipped first! Only then we can merge this PR. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - ANR when having an inverted FlatList on android API 33+ Pull Request resolved: #38073 Test Plan: - Check the RN tester app and see that scrollview is still working as expected - Add the `internalAndroidApplyInvertedFix` prop as test to a scrollview and see how the scrollbar will change position. Reviewed By: cortinico Differential Revision: D47848063 Pulled By: NickGerleman fbshipit-source-id: 4a6948a8b89f0b39f01b7a2d44dba740c53fabb3
…book#38071) Summary: This PR is a result of this PR, which got merged but then reverted: - facebook#37913 We are trying to implement a workaround for facebook#35350, so react-native users on android API 33+ can use `<FlatList inverted={true} />` without running into ANRs. This is the native part, where we add a new internal prop named `isInvertedVirtualizedList`, which can in a follow up change be used to achieve the final fix as proposed in facebook#37913 However as NickGerleman pointed out, its important that we first ship the native change. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [ADDED] - Native part of fixing ANR when having an inverted FlatList on android API 33+ Pull Request resolved: facebook#38071 Test Plan: - Check the RN tester app and see that scrollview is still working as expected - Add the `isInvertedVirtualizedList` prop as test to a scrollview and see how the scrollbar will change position. Reviewed By: rozele Differential Revision: D47062200 Pulled By: NickGerleman fbshipit-source-id: d20eebeec757d9aaeced8561f53556bbb4a492e4
@hannojg is this issue already fixed in react-native v0.72.4? |
Any chances that your fix is also applied to 0.71? :) @hannojg |
It looks like as of now it's only applied in 0.73: 3dd816c |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Is this actually fixed? |
Description
When having a
FlatList
and aTextInput
in one view and theFlatList
has theinverted={true}
prop set and the android device is on API 33 (Android 13) the app will freeze/die in an ANR.Screen.Recording.2022-11-15.at.12.52.22.mov
Version
0.70.5
Output of
npx react-native info
Steps to reproduce
yarn
yarn start
yarn android
, make sure the app launches on a device with android API 33 (Android 13)Snack, code example, screenshot, or link to a repository
https://github.com/hannojg/RN-AndroidAPI33-TextInput-ANR
The text was updated successfully, but these errors were encountered: