Skip to content
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

fix: Improve AccountListMenu/Item performance #26379

Merged
merged 9 commits into from
Aug 15, 2024

Conversation

owencraston
Copy link
Contributor

@owencraston owencraston commented Aug 13, 2024

Description

  1. What is the reason for the change?
  • reduce unnecessary re renders of the AccountsListMenu and AccountsListItem component
  • reduce tech debt
  • adopt better patterns like memoizing callbacks, lifting state to parent components and memoizing smaller components
  1. What is the improvement/solution?
  • memoize AccountsListItem

  • remove getSelectedInternalAccount form AccountsListItem since this component already has a prop called selected that uses the same logic. Lifting this state to the parent means that the AccountsListItem will not need to re render. Also a change in the getSelectedInternalAccount would trigger a re render of all its parents which is unnecessary.

    • This prop is now required to make up for the fact that we don't have the state anymore
  • memoize callbacks in the AccountListMenu

  • This PR has minor changes and should not effect any user flows. It does not require QA before merging

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/accounts-planning/issues/512

Manual testing steps

  • import / create a wallet
  • create as many accounts as you can
  • each time you create an account, the new account should be selected
  • open the account menu and select a new account, the account should become globally selected
  • select an account, click the three dots beside it, go to account details, click on view private key, put password, the private key should be displayed

Screenshots/Recordings

Before

After

Screen.Recording.2024-08-14.at.12.13.19.PM.1080.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@owencraston owencraston force-pushed the improve-accounts-performance branch 2 times, most recently from d2b87ce to 7e19673 Compare August 13, 2024 22:31
@owencraston owencraston force-pushed the improve-accounts-performance branch from 88235d3 to dfcd369 Compare August 14, 2024 15:08
@metamaskbot
Copy link
Collaborator

Builds ready [dfcd369]
Page Load Metrics (374 ± 343 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint691611062211
domContentLoaded115529147
load542284374715343
domInteractive115529147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 157 Bytes (0.00%)
  • common: 79 Bytes (0.00%)

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 69.99%. Comparing base (bef5b8f) to head (110a229).
Report is 8 commits behind head on develop.

Files Patch % Lines
...multichain/account-list-menu/account-list-menu.tsx 62.50% 3 Missing ⚠️
...ultichain/pages/send/components/account-picker.tsx 66.67% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #26379      +/-   ##
===========================================
+ Coverage    69.97%   69.99%   +0.01%     
===========================================
  Files         1422     1422              
  Lines        49938    49929       -9     
  Branches     13861    13859       -2     
===========================================
+ Hits         34943    34944       +1     
+ Misses       14995    14985      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@owencraston owencraston changed the title fix: Improve accounts performance fix: Improve AccountListMenu/Item performance Aug 14, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [110a229]
Page Load Metrics (255 ± 269 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint642631124823
domContentLoaded10130282613
load432095255561269
domInteractive10130282713
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 157 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@owencraston owencraston added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Aug 14, 2024
@owencraston owencraston marked this pull request as ready for review August 14, 2024 19:19
@owencraston owencraston requested a review from a team as a code owner August 14, 2024 19:19
Copy link
Contributor

@k-g-j k-g-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that increasing the use of memoization and callbacks is good practice. I found the app to be efficient and not have any lagging when working with 10+ accounts.

Screen.Recording.2024-08-15.at.10.27.50.AM.mov

@owencraston owencraston merged commit df95e54 into develop Aug 15, 2024
119 checks passed
@owencraston owencraston deleted the improve-accounts-performance branch August 15, 2024 16:36
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Aug 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2024
@metamaskbot metamaskbot added the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Aug 15, 2024
@gauthierpetetin gauthierpetetin added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Sep 11, 2024
@gauthierpetetin gauthierpetetin removed the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-accounts
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants