-
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
[NoQA] Memoize expensive calls in ReportActionsList renderItem #27957
Conversation
/** Report for this action */ | ||
report: reportPropTypes.isRequired, | ||
|
||
/* Whether the option has an outstanding IOU */ |
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.
/* Whether the option has an outstanding IOU */ | |
/** Whether the option has an outstanding IOU */ |
Reviewer Checklist
Screenshots/VideosWeb27957.Web.movMobile Web - ChromeScreen_Recording_20230922_134433_Chrome.mp4Mobile Web - Safari27957.mWeb.Safari.mp4Desktop27957.Desktop.moviOSSimulator.Screen.Recording.-.iPhone.SE.3rd.generation.-.2023-09-22.at.13.42.41.mp4Android27957.Android.webm |
@mountiny Should @janicduplessis be required to complete the recordings? |
@janicduplessis I thin kit would be great if you could get into habit of adding the recordings But seems like you got ti covered now so if everything tests well now maybe we can proceed, what do you think? |
Yup, everything looks good and I verified the re-render has decreased from before. |
@mollfpr In that case I think we can complete your checklist and merge |
@mountiny There's one NAB we need to solve. |
I see thnaks! |
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.
LGTM and tests well 👍
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.
Thanks
✋ 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.3.73-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.73-1 🚀
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.74-0 🚀
|
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.3.74-3 🚀
|
shouldHideThreadDividerLine={shouldHideThreadDividerLine} | ||
report={report} | ||
action={reportAction} | ||
displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedReportActions, index)} |
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 line created a bug in offline mode. More details in #32101
action={reportAction} | ||
displayAsGroup={ReportActionsUtils.isConsecutiveActionMadeByPreviousActor(sortedReportActions, index)} | ||
shouldDisplayNewMarker={shouldDisplayNewMarker} | ||
shouldShowSubscriptAvatar={ |
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.
We don't want to show subscript avatar if it is money request: #38974
Details
Some of the operations we do in ReportActionsList renderItem are pretty expensive since this function is executed for every items in the render window every time the render window changes. To improve performance of FlatList scrolling we need to move any expensive computation inside a memoized component. This way when FlatList re-renders to display new items but the data did not change only the new rendered items will need to render.
We were already memoizing ReportActionItem, but renderItem still contains some expensive calls, specifically
isConsecutiveActionMadeByPreviousActor
which has to do some date comparaisons. I moved those to a new componentReportActionsListItemRenderer
which will prevent any re-renders coming from from FlatList for items that were already rendered. This reduces the number of calls toisConsecutiveActionMadeByPreviousActor
from the number of currently rendered item (~100 depending on the FlatList window size) to just the new items being added (usually 10 since this is the batch size).Fixed Issues
$ #27972
Tests
Make sure there are no behaviour change when scrolling in a chat.
Using react profile we can observe render time for new FlatList batches goes from ~100ms to ~30ms.
Offline tests
QA Steps
No specific QA steps, general regression testing should catch any issues we might stumble upon
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
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android