-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: virtualize the Tokens list #37589
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
base: main
Are you sure you want to change the base?
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (1 files, +3 -2)
🧩 @MetaMask/extension-devs (5 files, +90 -0)
💎 @MetaMask/metamask-assets (4 files, +39 -33)
📜 @MetaMask/policy-reviewers (5 files, +90 -0)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🔗 @MetaMask/supply-chain (5 files, +90 -0)
|
f5c7470 to
73c5dec
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
|
||
| return ( | ||
| <div className="main-container main-container--has-shadow"> | ||
| <ScrollContainer className="main-container main-container--has-shadow"> |
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.
- Share a
refof the scrolling container
| // TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31860 | ||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| function TokenList({ onTokenClick, safeChains }: TokenListProps) { | ||
| const scrollContainerRef = useScrollContainer(); |
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.
- Get the scrolling container
| return ( | ||
| <> | ||
| {sortedFilteredTokens.map((token: TokenWithFiatAmount) => { | ||
| <div |
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.
- The list container
|
|
||
| return ( | ||
| <TokenCell | ||
| <div |
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.
- The virtualized elements
7cdf6aa to
62c5367
Compare
|
@MetaMask/supply-chain @tanstack/react-virtual is used here for the virtual scrolling in the Tokens list. Reviewed the policy changes and these are needed for scroll tracking and smooth scrolling. |
Builds ready [62c5367]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
bd42c83 to
67ae764
Compare
Builds ready [67ae764]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
c826997 to
446b78c
Compare
|
@metamaskbot update-policies |
Builds ready [7db0573]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff |
|
@metamaskbot update-policies |
Builds ready [1bde564]
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
No policy changes |
a730f63 to
a6a13fe
Compare
Builds ready [f81e585]
UI Startup Metrics (1200 ± 94 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [c994326]
UI Startup Metrics (1216 ± 89 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [c9dfa11]
UI Startup Metrics (1224 ± 95 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [c6411c3]
UI Startup Metrics (1162 ± 101 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [3bbae99]
UI Startup Metrics (1223 ± 88 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
The Tokens tab has a significant delay before the page becomes interactive after clicking the tab. Every token was being rendered simultaneously, each calling multiple Redux selectors and several computations.
This PR implements virtualization using @tanstack/react-virtual to only render tokens that are visible in the viewport. In the video below this reduces render time from 924ms to 35ms (26x improvement).
Changelog
CHANGELOG entry: feat: virtualize the Tokens list
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
Virtual.BEFORE.mov
After
Virtual.AFTER.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Virtualizes the Tokens list using @tanstack/react-virtual with a shared scroll container, updates asset cell/layout, and adjusts LavaMoat policies/globals.
useVirtualizerfrom@tanstack/react-virtualinui/components/app/assets/token-list/token-list.tsxto render only visible items and position them viatranslateY.ScrollContaineranduseScrollContainercontext inui/contexts/scroll-container.tsx; wraps main container inui/pages/home/home.component.jsto provide the scroll element.ASSET_CELL_HEIGHTinui/components/app/assets/constants.tsand applies it ingeneric-asset-cell-layout.tsx.asset-title.tsxby removing tooltip/explicit block display; keeps ellipsis viaText.@tanstack/react-virtualtopackage.json.ResizeObserver,setTimeout,clearTimeoutin build/plugin configs.@tanstack/react-virtualand@tanstack/virtual-corewith needed globals (document,scrollY,requestAnimationFrame,console.info/warn).Written by Cursor Bugbot for commit 3bbae99. This will update automatically on new commits. Configure here.