react-native: [Android] Inverted FlatList + Text Input causing ANR on android 13
Description
When having a FlatList
and a TextInput
in one view and the FlatList
has the inverted={true}
prop set and the android device is on API 33 (Android 13) the app will freeze/die in an ANR.
Version
0.70.5
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1 Pro
Memory: 96.63 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK:
API Levels: 28, 29, 30, 31, 32, 33
Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
System Images: android-32 | Google APIs ARM 64 v8a, android-32 | Google APIs Intel x86 Atom_64, android-32 | Google Play ARM 64 v8a, android-33 | Google APIs ARM 64 v8a, android-33 | Google Play ARM 64 v8a
Android NDK: 21.4.7075529
IDEs:
Android Studio: Chipmunk 2021.2.1 Patch 1 Chipmunk 2021.2.1 Patch 1
Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
Languages:
Java: 17.0.5 - /Users/hannogodecke/.jenv/shims/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
- Clone this repository
- Run
yarn
- Run
yarn start
- Run
yarn android
, make sure the app launches on a device with android API 33 (Android 13) - Open the app
- Open the developer tools and enable the performance monitor
- Focus the text input
- Run the following in your terminal:
adb shell input text "Lorem\ ipsum\ dolor\ sit\ amet,\ consetetur\ sadipscing\ elitr,\ sed\ diam\ nonumy\ eirmod\ tempor\ invidunt\ ut\ labore\ et\ dolore\ magna\ aliquyam\ erat,\ sed\ diam\ voluptua.\ At\ vero\ eos\ et\ accusam\ et\ justo\ duo\ dolores\ et\ ea\ rebum.\ Stet\ clita\ kasd\ gubergren,\ no\ sea\ takimata\ sanctus\ est\ Lorem\ ipsum\ dolor\ sit\ amet.\ Lorem\ ipsum\ dolor\ sit\ amet,\ consetetur\ sadipscing\ elitr,\ sed\ diam\ nonumy\ eirmod\ tempor\ invidunt\ ut\ labore\ et\ dolore\ magna\ aliquyam\ erat,\ sed\ diam\ voluptua.\ At\ vero\ eos\ et\ accusam\ et\ justo\ duo\ dolores\ et\ ea\ rebum.\ Stet\ clita\ kasd\ gubergren,\ no\ sea\ takimata\ sanctus\ est\ Lorem\ ipsum\ dolor\ sit\ amet."
- Run it repeatedly until the app freezes (for me it takes ~ 3 repetitions until the ANR happens. On a real Pixel 4 of a colleague the app almost freezes immediately).
Snack, code example, screenshot, or link to a repository
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 32 (16 by maintainers)
Commits related to this issue
- workaround: invert list manually on android as per: https://github.com/facebook/react-native/issues/35350#issuecomment-1317465434 — committed to margelo/expensify-app-fork by hannojg 2 years ago
- add `verticalScrollbarPosition` prop to `ScrollView` 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: https://git... — committed to hannojg/react-native by hannojg 2 years ago
- add `verticalScrollbarPosition` prop to `ScrollView` 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: https://git... — committed to Expensify/react-native by hannojg 2 years ago
- Add inputType textNoSuggestions in react-native to disable the autocomplete functionality (comment, comment-2, user-comment, user-comment-2) android:inputType=“textFilter|textNoSuggestions” P | type ... — committed to fabOnReact/react-native by fabOnReact 2 years ago
- Add workaround for android API 33 ANR when inverting ScrollView (#37913) Summary: As explained in this issue: - https://github.com/facebook/react-native/issues/35350 starting from android API 33 th... — committed to facebook/react-native by hannojg a year ago
- Add workaround fix for #35350 See also: https://github.com/facebook/react-native/pull/37913#issuecomment-1602240775 — committed to hannojg/react-native by hannojg a year ago
- Add workaround for android API 33 ANR when inverting ScrollView (#38071) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/... — committed to facebook/react-native by hannojg a year ago
- Add workaround for android API 33 ANR when inverting ScrollView (#38071) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/... — committed to juniorklawa/react-native by hannojg a year ago
- Add workaround fix for #35350 (#38073) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/37913 We are trying to implement ... — committed to facebook/react-native by hannojg a year ago
- Add workaround fix for #35350 (#38073) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/37913 We are trying to implement ... — committed to billnbell/react-native by hannojg a year ago
- Add workaround fix for #35350 (#38073) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/37913 We are trying to implement ... — committed to billnbell/react-native by hannojg a year ago
- Add workaround fix for #35350 (#38073) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/37913 We are trying to implement ... — committed to billnbell/react-native by hannojg a year ago
- Add workaround for android API 33 ANR when inverting ScrollView (#38071) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/... — committed to zhxlp/react-native by zhxlp a year ago
- Add workaround for android API 33 ANR when inverting ScrollView (#38071) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/... — committed to facebook/react-native by hannojg a year ago
- Add workaround fix for #35350 (#38073) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/37913 We are trying to implement ... — committed to facebook/react-native by hannojg a year ago
- Add workaround for android API 33 ANR when inverting ScrollView (#38071) Summary: This PR is a result of this PR, which got merged but then reverted: - https://github.com/facebook/react-native/pull/... — committed to expo/react-native by hannojg a year ago
- 緩解在Android 13上,在輸入欄打字會變得越來越慢、產生ANR的問題: https://github.com/facebook/react-native/issues/35155 https://github.com/facebook/react-native/issues/35590 https://github.com/facebook/react-native/issues/35... — committed to howg0924/react-native-gifted-chat by howg0924 9 months ago
It shouldn’t be closed for sure; seems like it is still an ongoing issue based on multiple threads on the very same topic.
An issue that seems quite huge to be honest and should be part of priorities; but should it be on react-native or Android?
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
scaleY: -1
androtationX: 180
for two nested views causes an ANR on android API 33On Android 13 we are noticing an ANR, when we have two views that have each:
scaleY: -1
rotationX: 180
set.
In the video, you can see a green view, the parent of a blue view (and the blue view has a lot of children (list)). Both views have the transformation properties set (creating an “inverted” effect).
We then have an
EditText
rendered underneath these views. When entering text the ANR happens. This is much easier to reproduce on a real device. We are reproducing with a Pixel 4 Android API 33 emulator. Here you need to enter text rapidly with the help ofadd shell input text
to cause the ANR.In the bottom right you can see a small FPS counter (using Choreographer), and you can see that the app starts to freeze at some point.
The full reproduction: https://github.com/hannojg/AndroidScaleYReproductionANR-
I also attached an
adb bugreport
(it’s from an emulator, so no sensitive data)The important code part to reproduce:
Thanks in advance for checking!
https://user-images.githubusercontent.com/16821682/203284168-c5c6ad81-338f-4132-8f9f-c220d1d448f9.mov
I just found the offending line that’s causing the issue. If I remove the
view.setRotationX
line the issue stops happening. At this point I am not sure whether this is a react native or an android bug. Will dig deeper:https://github.com/facebook/react-native/blob/e504141583fc2b695fb42a1037edf92c89ae552a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java#L441-L483
Any chances that your fix is also applied to 0.71? 😃 @hannojg
The android bug tracker seems to be working again: https://issuetracker.google.com/issues/287304310
Meanwhile I am preparing a workaround fix for within react native.
It looks like as of now it’s only applied in 0.73: https://github.com/facebook/react-native/commit/3dd816c6b7bcd9cc4c21199f0b645755fb97f50f
@t0nyh0 check this: https://github.com/facebook/react-native/issues/30034#issuecomment-1063980066
I also can’t open this sadly
Re-opening as this seems to affect a significant number of users, although this seems to be an Android-specific issue (and not an RN one).
@EmilScherdin can you (or someone else) open another issue on Google’s issue tracker to report this?
Okay, the issue doesn’t happen anymore if I also add
scaleX: -1
👀 :Going to dig into the native code to see where the issue happens, maybe also a bug with yoga?