-
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: refactor heavy operations when user starts to type #28469
perf: refactor heavy operations when user starts to type #28469
Conversation
@robertKozik Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
… perf/refactor-heavy-operations-for-draft
@hurali97 Can you resolve conflicts? I'll test it and do the reviewer checklist today |
@robertKozik Hur is off this week, will try to find someone to solve the conflicts |
Thanks @gedu ! |
@robertKozik I fix it but don't have permission to push to Hur branch, he should be back on Monday |
… perf/refactor-heavy-operations-for-draft
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
Looking at this PR from @sebryu https://github.com/Expensify/App/pull/30031/files could we use both potentially? |
… perf/refactor-heavy-operations-for-draft
@mountiny I have removed the code that conflicts with Sebs' approach. |
test build running here https://github.com/Expensify/App/actions/runs/6645315083 @robertKozik could you test this gain please? |
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪 |
… perf/refactor-heavy-operations-for-draft
On it 👀 |
@hurali97 sorry for late review, could you please resolve the conflicts? |
… perf/refactor-heavy-operations-for-draft
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code changes look good to me, thank you very much for your patience on this one
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@@ -87,6 +87,7 @@ Onyx.connect({ | |||
const policyExpenseReports = {}; | |||
Onyx.connect({ | |||
key: ONYXKEYS.COLLECTION.REPORT, | |||
waitForCollectionCallback: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caused serious regression. App crashes when request expense
Screen.Recording.2023-11-03.at.8.40.55.PM.mov
Anyone please raise quick fix? Or can I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just encountered this issue too. Pushing a fix soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.96-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.97-7 🚀
|
Details
This fixes the bottleneck which happens on slower devices when user switches a Report and starts to type and as a result the main thread gets blocked. The underlying root cause is mainly the
chatReports
being re-created because ofOnyx.merge
being called for setting draft status.There are also other optimisations including removing the
lodashGet
where it takes noticeable milliseconds, refactoring two loops into one ingetOrderedReportIDs
, callupdateUnread
only if unread count is changed from the previous one and other changes which are mentioned in the proposal.Note:
In the proposal, we proposed to pass only
allReportDict
keys toJSON.Stringify
but it turns out that we can't really do that since we have a lot of unit test failing because of it and the most of the app functionality depends on re-ordering the reportIDs based on changing in values for a report.Given that we are still able to score better results because we separated out the functionality for draft given a smoother user experience when user starts to type.
Before
recording-before.mp4
After
recording-after.mp4
Below is the screenshot after adding
initialValue
towithOnyx
:Fixed Issues
$ #28359
PROPOSAL: #28359
Tests
Test Steps
Go to any chat and type in a letter
On web and desktop, Pencil icon should be visible in the LHN
On Mobile, you've to navigate back to see the Pencil icon
Removing the entered letter from compose, should remove the Pencil icon from the LHN, hence the draft status
Verify that no errors appear in the JS console
Offline tests
Same as test
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting 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)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
recording-after.mp4
Mobile Web - Chrome
mobile-chrome.mov
Mobile Web - Safari
mobile-safari.mp4
Desktop
desktop-recording.mov
iOS
ios-recording.mp4
Android
android-recording.mp4