-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
perf: fix (comment) input performance #11684
Conversation
1bb443b
to
00778aa
Compare
This isn't something that was introduced by this PR, but I find it sort of alarming how great the difference between |
2bdb548
to
3220710
Compare
Any update here, @hannojg? |
Yeah, this PR aims do to two things:
For the first point I went with a different approach an created a fix for within react native itself. Once this PR is merged I will revisit this PR and make it only about the performance improvement :) |
Okay, cool. Shall we update the holds then to reference the PR we're waiting on: Expensify/react-native#50? |
Definitely! (However there will be the need for a follow up PR where we update the react native version in this repository, however I can only create this PR once Expensify/react-native#50 got merged 😅 ) |
Oh yeah, agree @roryabraham |
Also as an update, I am not sure if the problem is really fixable within react native's code base.
Which this PR is about. Will still wait for meta's final response if they agree on this. |
…f/fix-input-performance
…f/fix-input-performance
I'm a bit behind on this PR. What are the next steps?
Did we get anywhere here? |
We found a native fix. I am double-checking today If this PR is still needed 😊 |
Awesome @hannojg |
Dope! What's the verdict? |
@trjExpensify So I did another performance check, on my weakest device it shows that there is room for improvement. However, I'd like to redo the PR. As the original PR also aimed to fix the selection bug on android, i used for example the imperative API to update the selection of the input, which introduced a lot of regressions. If I understand you correctly, you like to keep this original PR right? |
Not necessarily man, it has just been open for a long time in this limbo draft and I see from time-to-time other issues on hold for it / referenced as potentially fixing a related problem. So I don't have a strong opinion on proceeding with this PR (just that we do something with it haha), Closing it and starting over elsewhere for the performance considerations is probably better. |
@trjExpensify Alright awesome, let's do that please. Also we should create a performance issue first and start from there. |
OK. That works for me. But we close this, we need to create a PR to update the fork version on the NewDot repo as well. That PR can be linked to solving the original issue #8349. Meanwhile, the upstream branch is still not merged Expensify/react-native#55. |
Let's close this PR. |
Details
I was investigating a performance (and crash) issue when typing a comment for a report.
I was able to reproduce the issue on iOS, where I noticed that the JS thread completely dies when you are typing (typing super slow seems fine, but typing a bit faster caused a massive slowdown):
video_before.mp4
In addition to that I also get some warnings:
After:
After fixing the issue the JS thread is almost not impacted at all. It's only impacted when starting typing. I also want to improve performance for that as well, however, that's for another PR:
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2022-10-08.at.17.56.34.mp4
The main fix was to remove the text input from the
state
of theReportActionCompose
. On each keystroke, it re-rendered ~3 times. Now it doesn't re-render at all when just typing (it does when starting and stopping typing, but that's for other PRs to improve).Removal of the space after emojis:
When I started working on this I realized an inconsistency in behaviour when adding emojis between the composer on the report screen and the composer when editing a sent message/action.
I made the behaviour equal, and when adding emojis there is no additional space added. This was discussed and decided on slack: https://expensify.slack.com/archives/C035J5C9FAP/p1665560521827199
Fixed Issues
$ #8349
PROPOSAL: GH_LINK_ISSUE(COMMENT)
Tests
Testing adding emojis:
When adding emojis make sure that no additional whitespace gets added. This behavior has changes as discussed (see link above)
Testing android selection menu
(Only needed on android)
The following is a list of regression tests to run against this PR to make sure everything is working as expected.
Regression tests:
Test plan
Helper list to confirm you ran every test
All platforms, make sure for web to run on every browser (Safari, Chrome, Firefox, Edge):
Selection is not reset after selecting an emoji
screen-2022-10-12_01.10.50.mp4
Broken emojis are rendered when picked from the picker in a series
screen-2022-10-12_01.35.38.mp4
Cursor position is broken
screen-2022-10-12_01.46.21.mp4
Steps.
Expected: it should be at the end of the pasted text.
Adding emoji via EmojiPicker in replacement for multiple lines creates a delay before the composer height is calculated.
screen-2022-10-19_01.19.07.mp4
Selected Emoji is placed in the wrong position.
[Web]
Pasting image does not send the attached text message.
CTRL+V
to paste the image.Expected: Pressing send on the attachment modal should first send the text and then the image. (See staging for correct behaviour).
There is a delay before Composer expands the height on the web.
screen-2022-11-16_19.39.59.mp4
Cursor position is not focused after picking a emoji in Composer.
screen-2023-01-05_00.03.18.mp4
Content flashing while pasting
Cmd + A
to select the whole content in the composer.screen-2023-01-05_00.11.41.mp4
Edit Message: Copy-pasting is slow.
screen-2023-01-09_16.19.55.mp4
Cursor jumping or moving positions after picking emoji.
screen-2023-01-09_16.26.09.mp4
Compose text is not cleared after sending the message
bug1-web.mov
QA Steps
Same as in testing section above.
Testing adding emojis:
Testing android selection menu
(Only needed on android)
PR Author Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
The reviewer will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Screenshots
Web
Screen.Recording.2022-10-14.at.3.08.26.PM.mov
Mobile Web - Chrome
android_chrome.mp4
Mobile Web - Safari
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2022-10-14.at.15.10.37.mp4
Desktop
Screen.Recording.2022-10-14.at.3.18.25.PM.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2022-10-14.at.15.01.11.mp4
Android
SVID_20221014_150501_1.mp4