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: cp-7.42.0Tokens screen performance degradation #13907

Conversation

gambinish
Copy link
Contributor

@gambinish gambinish commented Mar 6, 2025

Description

Over the past couple of versions, we've seen a continued regression to Android performance. This was particularly noticeable when navigating quickly throughout the app, specifically on Samsung and Xaomi devices. We also noticed issues where the TokenList would freeze and become unresponsive.

After troubleshooting with the mobile team and QA, I think we can narrow this down to (at least) two things:

  1. Tokens screen over-rendering
  2. React context mounting/unmounting unnecessarily

The following two changes are being introduced in this PR:

Memoizing selectors on Tokens screen to optimize rendering with createDeepEqualSelector

  • This helps to memoize data from state, to avoid React from de-referencing and causing unnecessary re-renders. useSelector only creates a shallow copy, which may often lead to undesirable behavior.

Moving AssetsPollingProvider lower down in the component hierarchy

  • This polling provider initializes polling loops in core, for controllers that extend StaticIntervalPollingController (this includes the EVM assets controllers). The idea behind these polling loops is to only start them for components that need the data polled (ie be UI based)
  • But currently, this context provider wraps our main nav component. This means that on each navigation, it would unmount/remount the context and re-initialize polling loops unnecessarily.

While this is a good start, I think that we should continue to expand/refine these changes to optimize performance further in future versions.

Related issues

Partially fixes: #13850

Manual testing steps

  1. Launch the android app with an imported wallet with assets (tokens, NFTs)
  2. Add BSC to your network list. Notice the sluggish behavior
  3. Now filter by popular networks. Notice how interacting with the wallet is more sluggish
  4. Try adding a token like “PEPE” while on BSC. Notice the slugish behavior

Screenshots/Recordings

Before

https://www.loom.com/share/b5c33532e7354a48ba481814dd5fa01c?sid=dd25d6af-5239-4fe4-b113-dc0ebb6e25b7

After

https://www.loom.com/share/2fb837e3607a4e9dba1239555d6b488a?sid=cf8d437d-9ab2-4272-862e-19e5b6eb17df

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

github-actions bot commented Mar 6, 2025

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.

@gambinish gambinish added the DO-NOT-MERGE Pull requests that should not be merged label Mar 7, 2025
@gambinish gambinish changed the base branch from mmassets-13850_token-list-performance-degredation to main March 7, 2025 02:03
@gambinish gambinish changed the title fix: Move AssetPollingProvider fix: TokenList performance degredation Mar 7, 2025
@gambinish gambinish changed the title fix: TokenList performance degredation fix: TokenList performance degredation Mar 7, 2025
@gambinish gambinish added Run Smoke E2E Triggers smoke e2e on Bitrise and removed DO-NOT-MERGE Pull requests that should not be merged labels Mar 7, 2025
Copy link
Contributor

github-actions bot commented Mar 7, 2025

https://bitrise.io/ Bitrise

🔄🔄🔄 pr_smoke_e2e_pipeline started on Bitrise...🔄🔄🔄

Commit hash: a27d934
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/21d8368d-cfa8-4dca-9f41-b00fae7872f8

Note

  • This comment will auto-update when build completes
  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

…ing-provider' of github.com:MetaMask/metamask-mobile into mmassets-13850_token-list-performance-degredation--polling-provider
@gambinish gambinish removed the Run Smoke E2E Triggers smoke e2e on Bitrise label Mar 7, 2025
salimtb
salimtb previously approved these changes Mar 7, 2025
@MarioAslau MarioAslau changed the title fix: Tokens screen performance degradation fix: cp-7.42.0Tokens screen performance degradation Mar 7, 2025
@gambinish gambinish dismissed stale reviews from Prithpal-Sooriya and salimtb via 81294cc March 7, 2025 16:19
@gambinish gambinish added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 7, 2025
Copy link
Contributor

github-actions bot commented Mar 7, 2025

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 9eb8385
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/8bc36f43-d724-43de-af7d-cbd0f7420b2f

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@gambinish gambinish added this pull request to the merge queue Mar 7, 2025
Merged via the queue into main with commit 5996a4a Mar 7, 2025
43 checks passed
@gambinish gambinish deleted the mmassets-13850_token-list-performance-degredation--polling-provider branch March 7, 2025 18:48
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2025
@metamaskbot metamaskbot added the release-7.43.0 Issue or pull request that will be included in release 7.43.0 label Mar 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.43.0 Issue or pull request that will be included in release 7.43.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-assets
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Bug]: [Android Specific] App's performance has degraded
5 participants