-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix: fix network selector edge cases #35841
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/accounts-engineers (4 files, +203 -4)
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [5845824]
UI Startup Metrics (1229 ± 59 ms)
Benchmark value 28 exceeds gate value 23 for chrome browserify home mean firstReactRender Benchmark value 17 exceeds gate value 15 for chrome browserify home mean getState Benchmark value 7 exceeds gate value 1 for chrome browserify home mean initialActions Benchmark value 264 exceeds gate value 18 for chrome browserify home p95 backgroundConnect Benchmark value 39 exceeds gate value 33 for chrome browserify home p95 getState Benchmark value 19 exceeds gate value 1.2 for chrome browserify home p95 initialActions Benchmark value 25 exceeds gate value 17 for chrome browserify home p95 setupStore Benchmark value 35 exceeds gate value 29 for chrome webpack home mean getState Benchmark value 274 exceeds gate value 195 for chrome webpack home p95 getState Benchmark value 15 exceeds gate value 7 for chrome webpack home p95 initialActions Benchmark value 1450 exceeds gate value 1405 for firefox browserify home mean uiStartup Benchmark value 1249 exceeds gate value 1245 for firefox browserify home mean load Benchmark value 1248 exceeds gate value 1239 for firefox browserify home mean domContentLoaded Benchmark value 35 exceeds gate value 25 for firefox browserify home mean backgroundConnect Benchmark value 29 exceeds gate value 25 for firefox browserify home mean firstReactRender Benchmark value 4 exceeds gate value 1 for firefox browserify home mean initialActions Benchmark value 11 exceeds gate value 9 for firefox browserify home mean setupStore Benchmark value 1700 exceeds gate value 1660 for firefox browserify home p95 uiStartup Benchmark value 222 exceeds gate value 195 for firefox browserify home p95 domInteractive Benchmark value 42 exceeds gate value 24 for firefox browserify home p95 getState Benchmark value 10 exceeds gate value 2 for firefox browserify home p95 initialActions Benchmark value 32 exceeds gate value 27 for firefox browserify home p95 setupStore Benchmark value 1667 exceeds gate value 1615 for firefox webpack home mean uiStartup Benchmark value 1422 exceeds gate value 1380 for firefox webpack home mean load Benchmark value 1421 exceeds gate value 1380 for firefox webpack home mean domContentLoaded Benchmark value 112 exceeds gate value 100 for firefox webpack home mean domInteractive Benchmark value 33 exceeds gate value 26 for firefox webpack home mean backgroundConnect Benchmark value 46 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 5 exceeds gate value 1 for firefox webpack home mean initialActions Benchmark value 1398 exceeds gate value 1360 for firefox webpack home mean loadScripts Benchmark value 1981 exceeds gate value 1935 for firefox webpack home p95 uiStartup Benchmark value 297 exceeds gate value 156 for firefox webpack home p95 domInteractive Benchmark value 53 exceeds gate value 50 for firefox webpack home p95 firstReactRender Benchmark value 8 exceeds gate value 2 for firefox webpack home p95 initialActions Benchmark value 1632 exceeds gate value 1630 for firefox webpack home p95 loadScripts Sum of mean exceeds: 541ms | Sum of p95 exceeds: 660.8ms Sum of all benchmark exceeds: 1201.8ms Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [7427c0d]
UI Startup Metrics (1245 ± 66 ms)
Benchmark value 1083 exceeds gate value 1070 for chrome browserify home mean load Benchmark value 1075 exceeds gate value 1061 for chrome browserify home mean domContentLoaded Benchmark value 247 exceeds gate value 10 for chrome browserify home mean backgroundConnect Benchmark value 24 exceeds gate value 23 for chrome browserify home mean firstReactRender Benchmark value 6 exceeds gate value 1 for chrome browserify home mean initialActions Benchmark value 836 exceeds gate value 830 for chrome browserify home mean loadScripts Benchmark value 43 exceeds gate value 41 for chrome browserify home p95 domInteractive Benchmark value 1183 exceeds gate value 1180 for chrome browserify home p95 firstPaint Benchmark value 260 exceeds gate value 18 for chrome browserify home p95 backgroundConnect Benchmark value 12 exceeds gate value 1.2 for chrome browserify home p95 initialActions Benchmark value 2220 exceeds gate value 2192 for chrome webpack home mean uiStartup Benchmark value 1760 exceeds gate value 1711 for chrome webpack home mean load Benchmark value 1751 exceeds gate value 1704 for chrome webpack home mean domContentLoaded Benchmark value 25 exceeds gate value 21 for chrome webpack home mean domInteractive Benchmark value 39 exceeds gate value 29 for chrome webpack home mean getState Benchmark value 13 exceeds gate value 7 for chrome webpack home mean initialActions Benchmark value 1746 exceeds gate value 1699 for chrome webpack home mean loadScripts Benchmark value 2728 exceeds gate value 2454 for chrome webpack home p95 uiStartup Benchmark value 2108 exceeds gate value 2030 for chrome webpack home p95 load Benchmark value 2091 exceeds gate value 2005 for chrome webpack home p95 domContentLoaded Benchmark value 115 exceeds gate value 57 for chrome webpack home p95 domInteractive Benchmark value 274 exceeds gate value 195 for chrome webpack home p95 getState Benchmark value 17 exceeds gate value 7 for chrome webpack home p95 initialActions Benchmark value 2077 exceeds gate value 1970 for chrome webpack home p95 loadScripts Benchmark value 1423 exceeds gate value 1405 for firefox browserify home mean uiStartup Benchmark value 33 exceeds gate value 25 for firefox browserify home mean backgroundConnect Benchmark value 28 exceeds gate value 25 for firefox browserify home mean firstReactRender Benchmark value 6 exceeds gate value 1 for firefox browserify home mean initialActions Benchmark value 13 exceeds gate value 9 for firefox browserify home mean setupStore Benchmark value 1665 exceeds gate value 1660 for firefox browserify home p95 uiStartup Benchmark value 246 exceeds gate value 195 for firefox browserify home p95 domInteractive Benchmark value 31 exceeds gate value 2 for firefox browserify home p95 initialActions Benchmark value 33 exceeds gate value 27 for firefox browserify home p95 setupStore Benchmark value 102 exceeds gate value 100 for firefox webpack home mean domInteractive Benchmark value 32 exceeds gate value 26 for firefox webpack home mean backgroundConnect Benchmark value 43 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 3 exceeds gate value 1 for firefox webpack home mean initialActions Benchmark value 276 exceeds gate value 156 for firefox webpack home p95 domInteractive Benchmark value 52 exceeds gate value 50 for firefox webpack home p95 firstReactRender Benchmark value 5 exceeds gate value 2 for firefox webpack home p95 initialActions Sum of mean exceeds: 532ms | Sum of p95 exceeds: 1165.8ms Sum of all benchmark exceeds: 1697.8ms Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
||
const btcAccountGroup = useSelector((state) => | ||
getInternalAccountBySelectedAccountGroupAndCaip(state, BtcScope.Mainnet), | ||
); |
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.
I just don't like the fact that this now needs to live inside UI component for rendering the chain-agnostic account list (we call multichain account list).
Can this live somewhere else? Inside some service, or a related controller? Can you take this data from somewhere else and just dispatch your action that you need from our setSelectedMultichainAccount
action?
Here we do the selection:
metamask-extension/ui/store/actions.ts
Line 2219 in d2fe50a
]); |
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.
To elaborate more on why I'm asking you this.
So, the multichain account list and multichain account page was devised to be abstract enough, to work only with the Account Tree which represents our chain-agnostic (multichain) architecture, and on the way while building it, we wanted to respect it and keep it chain-agnostic completely, which means no internal accounts or similar specific chain related stuff is required. This led us to having abstracted multichain account list, easy to maintain and more performant without having to deal with internal accounts or additional processes.
What is done here is because of the relation between the account selection and networks. Why this cannot be implemented somewhere outside of this UI component? This sounds like something should listen for a change and take some action, maybe some service or controller can handle this?
This is not only adding more complexity inside our UI component, but it is also putting a lot more redundant pressure on the account list (processes that are not needed all the time). So, every time somebody opens the account list, this will be pulling internal accounts and processing some logic that might not be used by the user at all. It just loads somebody's machine for nothing most of the time.
Can you please consider having another approach for this? 🙏
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.
@david0xd I agree with you, this logic should be at the accountsTreeController
or accountsController
level. On every account switch, we should filter the network state (MultichainNetworkController
, NetworkController
, NetworkEnablementController
) to ensure the selected network matches the chains (EVM / Sol / BTC) available in the account group.
Since we don’t currently do this, we end up with issues like the one. For example, try selecting an account that doesn’t include Solana in its group. If you download the state logs and inspect multichainNetworkConfigurationsByChainId
, you’ll see the Solana network still present when it shouldn’t be. That’s one of the reasons we’re hitting this edge case.
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.
Maybe @ccharly have an idea about it if you think this can be solved on the account tree controller or similar.
Description
When switching account groups, the previously selected network might not exist in the target group (e.g., switching from an EVM-only group to a Solana-only group, or vice-versa). This caused users to land on an unavailable network and occasionally led to empty states or confusing UI.
This PR introduces a safe fallback: if the previously selected network is not part of the new account group, we automatically switch to a “popular” network available in that group. This yields a smoother experience and guarantees a usable default after every account switch.
Changelog
CHANGELOG entry: Fixed a bug where switching accounts could leave users on an unavailable network; the app now falls back to a popular network available in the new account group.
Related issues
Fixes: #
Manual testing steps
Screenshots/Recordings
Before
After
Screen.Recording.2025-09-11.at.15.06.07.mov
Pre-merge author checklist
Pre-merge reviewer checklist