perf: Improve get icons#46886
Conversation
|
@mkhutornyi 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] |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.mp4Android: mWeb Chromemchrome.mp4iOS: Nativeios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
neil-marcellini
left a comment
There was a problem hiding this comment.
Looks good thanks. One NAB which could be done in a follow up, or not at all.
| const avatarURL = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]?.avatarURL; | ||
|
|
||
| const isSameAvatarURL = iconFromCache?.icon?.source === avatarURL; | ||
| const isDefaultWorkspaceAvatar = !avatarURL && typeof iconFromCache?.icon?.source !== 'string'; |
There was a problem hiding this comment.
NAB: It might be more reliable and simple to set a flag in the cached value, e.g. isDefaultWorkspaceAvatar. Maybe in the future there's a case where the source is not a string and it's not a default workspace avatar.
|
✋ 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/neil-marcellini in version: 9.0.21-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.0.21-4 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.0.21-4 🚀
|
Details
On the trace provided by Jason, we observed that
getIconsconsumes ~400ms as a whole. On the heavy accounts that we have with ~15k reports, we were able to reproduce something similar and got around ~108ms.The fix is to avoid re-calculating default workspace icons if there's no change. This helps in reducing the execution time to ~54ms.
Before:
After:
Fixed Issues
$ #45528
PROPOSAL:
Tests
Steps:
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android-web.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
Screen.Recording.2024-08-07.at.3.27.28.PM.mov
MacOS: Desktop
desktop.mp4