-
Notifications
You must be signed in to change notification settings - Fork 3k
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: optimise composer send behaviour #30168
perf: optimise composer send behaviour #30168
Conversation
… perf/optimise-composer-send
… perf/optimise-composer-send
… perf/optimise-composer-send
@aimane-chnaif 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] |
@hurali97 please fix conflict |
… perf/optimise-composer-send
Figuring out why Reassure tests are failing and will update the PR accordingly. |
@aimane-chnaif All green now ! |
As it's failing on main, someone will fix urgently so let's wait |
@hurali97 please pull main. It's fixed now |
… perf/optimise-composer-send
return (
<ReportActionItemCreated
reportID={props.report.reportID}
policyID={props.report.policyID}
+ personalDetails={personalDetails}
/>
); Can we apply this change in ReportActionItem.js to fix this issue? Screen.Recording.2024-01-30.at.3.21.41.PM.movScreen.Recording.2024-01-30.at.3.07.50.PM.mov |
… perf/optimise-composer-send
@aimane-chnaif Thanks for doing a regression. I have fixed these issues now 👍 |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
Seems like auto-focus composer when switch chat is broken on staging web. Works fine on production. Deploy blocker maybe? (for future reference: staging - v1.4.34-0, production - v1.4.33-5) Screen.Recording.2024-01-31.at.12.03.58.PM.mov |
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 think we can now merge this as no bugs found at this moment from our side.
But still be on a look out for any regressions QA is reporting since this is big refactor.
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.
Let's go then, code looks good to me, this was a massive effort, thanks everyone!
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.
Let's go then, code looks good to me, this was a massive effort, thanks everyone!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.35-0 🚀
|
I believe this PR caused this regression: #35559 |
prevProps.report.isOptimisticReport === nextProps.report.isOptimisticReport && | ||
prevProps.report.statusNum === nextProps.report.statusNum && | ||
_.isEqual(prevProps.report.pendingFields, nextProps.report.pendingFields) && | ||
prevProps.currentReportID === nextProps.currentReportID, |
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.
@hurali97 Not sure this was mentioned before but why keys here are inconsistent with useMemo here?
App/src/pages/home/ReportScreen.js
Lines 173 to 203 in 9ab4fe9
const report = useMemo( | |
() => ({ | |
lastReadTime: reportProp.lastReadTime, | |
reportID: reportProp.reportID, | |
policyID: reportProp.policyID, | |
lastVisibleActionCreated: reportProp.lastVisibleActionCreated, | |
statusNum: reportProp.statusNum, | |
stateNum: reportProp.stateNum, | |
writeCapability: reportProp.writeCapability, | |
type: reportProp.type, | |
errorFields: reportProp.errorFields, | |
isPolicyExpenseChat: reportProp.isPolicyExpenseChat, | |
parentReportID: reportProp.parentReportID, | |
parentReportActionID: reportProp.parentReportActionID, | |
chatType: reportProp.chatType, | |
pendingFields: reportProp.pendingFields, | |
isDeletedParentAction: reportProp.isDeletedParentAction, | |
reportName: reportProp.reportName, | |
description: reportProp.description, | |
managerID: reportProp.managerID, | |
total: reportProp.total, | |
nonReimbursableTotal: reportProp.nonReimbursableTotal, | |
reportFields: reportProp.reportFields, | |
ownerAccountID: reportProp.ownerAccountID, | |
currency: reportProp.currency, | |
participantAccountIDs: reportProp.participantAccountIDs, | |
isWaitingOnBankAccount: reportProp.isWaitingOnBankAccount, | |
iouReportID: reportProp.iouReportID, | |
isOwnPolicyExpenseChat: reportProp.isOwnPolicyExpenseChat, | |
notificationPreference: reportProp.notificationPreference, | |
}), |
App/src/pages/home/ReportScreen.js
Lines 645 to 661 in 9ab4fe9
memo( | |
ReportScreen, | |
(prevProps, nextProps) => | |
prevProps.isSidebarLoaded === nextProps.isSidebarLoaded && | |
_.isEqual(prevProps.reportActions, nextProps.reportActions) && | |
_.isEqual(prevProps.reportMetadata, nextProps.reportMetadata) && | |
prevProps.isComposerFullSize === nextProps.isComposerFullSize && | |
_.isEqual(prevProps.betas, nextProps.betas) && | |
_.isEqual(prevProps.policies, nextProps.policies) && | |
prevProps.accountManagerReportID === nextProps.accountManagerReportID && | |
prevProps.userLeavingStatus === nextProps.userLeavingStatus && | |
prevProps.report.reportID === nextProps.report.reportID && | |
prevProps.report.policyID === nextProps.report.policyID && | |
prevProps.report.isOptimisticReport === nextProps.report.isOptimisticReport && | |
prevProps.report.statusNum === nextProps.report.statusNum && | |
_.isEqual(prevProps.report.pendingFields, nextProps.report.pendingFields) && | |
prevProps.currentReportID === nextProps.currentReportID, |
notificationPreference
is good example. It's added in useMemo but not in memo. This caused #35562
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.35-7 🚀
|
childVisibleActionCount: reportAction.childVisibleActionCount, | ||
childOldestFourAccountIDs: reportAction.childOldestFourAccountIDs, | ||
childType: reportAction.childType, | ||
person: reportAction.person, |
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.
Is this referenced somehere? I can't find it anywhere.
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.
Ah that would be for threads, it would have to be used for that little element showing how many replies are in thread, who responded, right?
Details
This fixes major things wrong with
ReportScreen
and it's children,ReportActionCompose
andComposerWithSuggestions
. The highlight is thepersonalDetails
prop fromonyx
as on high traffic accountspersonalDetails
becomes a huge object and is expensive to pass as a prop and have the component render/ re-render. So each time a message is sent, we are manipulating onyx for thereport_
,reportActions_
andpersonalDetails
keys first with the optimistic data and then with the successful data. Most of theReportScreen
and it's children doesn't really needpersonalDetails
as a prop from onyx as they are passing that prop to certain utility functions to calculate for example, icon. So thispersonalDetails
prop can be removed and we can use directly from the utility as we haveOnyx.connect
already present in the utility files.Apart from this, some props including
report
andreportActions
have been simplified to become lightweight so that the can be passed easily down to the children. Previously, we were passing the whole object and it had properties that we don't need. Also, to prevent unnecessary re-rendering ofReportActionCompose
the empty state is lifted and moved toReportActionCompose
alongside theSendButton
andEmojiButton
. Also,sortedReportActions
aren't really needed to pass toReportActionsListItemRenderer
as it uses the prop to only evaluate whether it's a group or not. So we have passed a new propdisplayAsGroup
to the component directly instead of passing the whole actions array.Fixed Issues
$ #26347
PROPOSAL: #26347 (comment)
Tests
Testing Steps:
Open a Report and focus the composer
Start typing some letters and then hit send
Once the message is sent, start typing again and then press send
No message should be present in the composer and the behaviour should feel smooth
Verify that no errors appear in the JS console
Offline tests
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
Android: Native
android-recording.mov
Android: mWeb Chrome
android-web-recording.mov
iOS: Native
ios-recording.mp4
iOS: mWeb Safari
ios-web-recording.mp4
MacOS: Chrome / Safari
web-recording.mov
MacOS: Desktop
desktop-recording.mov