-
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
TextInput becomes slow after lots of typing #20119
Comments
👋 @gnprice thanks for the writeup, I've added a couple more tags that seem to be more related to the issue. Sadly AFAIK the TextInput is an hard portion to work with, and currently there is a bit of bus factor in terms of devs that know how it works "deeply". So it may take some time before this get fixed, fingers crossed. |
After few tests I`ve discovered that clean InputText (without any styling) works normally (sometimes fps going down, but app is not freezing). But if I add some styling to input (e.g. fontSize) then typing process is going to be laggy more and more. Unstable behavior is appear much faster if quantity of styling options is more. It seems that something went wrong with styling span generation (size, lineHeight, letterSpace and so on) inside of the logic of the text shadow nodes code. For now, i have to remove all styling from inputs, to get app works. Maybe that helps someone. Cheers! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
(ok ignore the bot) |
Hi, I'm experiencing the same problem with 3 separate react native apps under developpement. I have conducted my small tests with the slightlyest modified basic App (but trying with "PureComponent" - see below) with the following versions :
There are differences, but as far as I can tell, the behaviour is basically the same : performances drop after a couple of hundreds of typing (300 words / 1000 carateres). So, could this be inherent to react native &/or mobile dev ? There are aggravating factors, though :
My projects must allow the user to compose large pieces of texts, so I guess I will keep an eye on it, and try various workarounds to mitigate it (unmount the component + no Thanks a lot for any update on this issue.
|
I don't know if this is in any way helpful, but I started dev-ing on an earlier RN version for my app (I think it might have been .53) and didn't notice the slowdown issue until after I had upgraded my RN version to .55 (and now also seeing it in .56). To wit, not 100% SURE it wasn't there back then, but it does make me wonder if something introduced in .54 might be causing the issue. |
This issue started in 0.54 and still exists today. Any chat app that uses a text input that persists between messages becomes unusable after only a few minutes if chatting. I wish there was some way to get this fixed. |
@stueynet a workaround for chat is to force React to unmount and remount on the text input when the user sends a message. |
for me the solution was to do the following https://snack.expo.io/@jerson/text-input-slow-fix _onChange = (label) => {
if (this.timeoutUpdate) {
clearTimeout(this.timeoutUpdate);
}
this.timeoutUpdate = setTimeout(() => {
this.input.setNativeProps({
text: label
});
}, 100);
this.setState({ label })
} |
Any updates on that? Still reproducible in 0.57rc4. Just create a new react native project and use this simple App class:
As the TextInput is unstyled, you won't see it, just click in the top left corner, then the cursor appears. After several recursions (3-5) of typing and clearing the whole text, the lag is noticable, from then on the lag increases every time you clear. On our test device, also other apps are slow then, e.g. the Chrome address bar lags just like the RN TextInput. Only a restart of the device fixes it, but it appears again after some recursions of typing and clearing. |
OK I have been elbows deep in this issue for a week, I would not have considered myself strong on the Native code side of things, but I think I can at least confirm the original hypothesis that large numbers of spans are being created... By attaching a breakpoint in From what I can tell this is caused by the combination of a few things -
I tried changing the second param to the previous length of the text, however unfortunately this makes the What did seem to help for me was to add What this does not explain is the experiencing of this issue without clearing or deleting text - that I have no clue about - but certainly as per @Netdesk and @stueynet above I was still seeing the performance issues after clearing text even after applying the patch from #19645 . Hopefully this points someone with more knowledge of the Android TextInput code in the right direction |
In my case, the TextInput becomes slow when starting typing. I noticed that autocorrect takes some time to suggest words on the keyboard and so I turned it off. Now it works better. I know it's not the best solution, but ... ¯ \ _ (ツ) _ / ¯
|
Not the ideal solution, but I've also found that turning off autoCorrect as suggested above has a significant positive performance impact with large text. Device: Samsung Galaxy S10 |
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. |
There's no reason to believe this has been fixed. Stale-bot please go away. |
We are having similar issues on React Native 0.67 and Android 13 users. We have a chat screen with a TextInput at the bottom. Removing everything but |
Did you find any solution for this? |
How can such an essential component be buggy since 5 years? Not asking to annoy somebody, just questioning, if there's something wrong with notifications, some missing label, or whatever is needed that this issue is seen by some maintainer. |
we had to rewrite the input component in our app 4 years ago! it wonders me that I get a notification from this topic once in a while and seems like the original issue has not been fixed yet! |
Would you be willing to share the fixed component? |
unfortunately, I don't have access to the code since I left the company 3 years age |
The problem seems to solve for me (but I'll still test a lot more). If you want to understand the app and the problem I had: In my app I have a component named Exercise with View, several Text and a TextInput. before scrollEnabled={false} and autoCorrect={false} I stopped using state and tried ref but did not work. The problem: |
I've still seen this in RN 0.70 (within an expo app on Android). I took a few approaches:
I'll see how this goes, but I've had good reports so far. |
See more info in this comment #20119 (comment) Possible solution: For example
Now react-native does like this:
Instead we could add logic in the TextInput API, in case user types 5 characters per second:
It could enabled by default or disabled by default with a prop The issue was opened 6 years ago. |
Does it reproduce on the new architecture? |
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. |
Stale-bot please go away — there's no reason to think this has been fixed. |
Environment
(*) In my test app, actually v0.55.4 plus the patch from #19645 . Others on #19126 report the same symptoms using v0.56.
Description
After typing a lot of text into a controlled TextInput, like ~500 char on a recent fast phone, we start dropping frames. It gets worse the more you type; at ~1000 char, we very frequently drop frames and the app looks noticeably laggy.
Reproducible Demo
The original repro is by @s-nel: https://github.com/s-nel/rn19126
Originally reported at #19126 (comment); more discussion in subsequent comments in that thread.
In particular, here's the video from that repro:
Here's a video by @s-nel on my test app, with this description:
Here's my description of replicating that repro, again in my test app:
That was on a Pixel 2 XL; the numbers will probably vary with hardware.
Background from previous bug
This bug seems closely related to #19126; the repro steps and symptoms seem to be exactly the same, except quantitatively much less severe. (The original reports of #19126 describe clearing the input as part of the repro; I now think that was probably a red herring.)
The extreme symptoms of #19126 were absent in v0.54, introduced in v0.55, and fixed in v0.56 by #19645 . As I wrote when I figured out the cause of that (leading to the one-line fix in #19645):
I think we're now looking at exactly that underlying bug. It may well have been present in v0.54 and earlier releases; I don't think we have any data on that. [EDIT: @piotrpazola finds below that the bug is present in v0.50, and absent in v0.49.]
I don't know anything more about what causes it; even the hypothesis that we're ending up with large numbers of text shadow nodes is just an inference from how it interacts with the line fixed in #19645. So, more debugging is required.
I don't expect to do that debugging myself, because these remaining symptoms are no longer one of the top issues in our own app. But I hope somebody else will!
The text was updated successfully, but these errors were encountered: