Skip to content

fix: fix side panel open tracking for multiple instances#40305

Merged
davidmurdoch merged 2 commits intomainfrom
fix/sidepanel-open-counter
Feb 25, 2026
Merged

fix: fix side panel open tracking for multiple instances#40305
davidmurdoch merged 2 commits intomainfrom
fix/sidepanel-open-counter

Conversation

@davidmurdoch
Copy link
Copy Markdown
Contributor

@davidmurdoch davidmurdoch commented Feb 20, 2026

Description

Chrome can have multiple MetaMask side panel instances open at once (for example, across multiple browser windows).
background.js was tracking side panel state with a single sidePanelIsOpen boolean, which assumes only one instance exists.

With a boolean, closing one side panel could incorrectly mark all side panels as closed.
That can cause premature environment cleanup and incorrect open-state checks while another side panel is still active.

Open in GitHub Codespaces

Changelog

CHANGELOG entry: fixes syncing failure caused by the sidepanel being opened in multiple browser windows, and then one of the sidepanels being closed, causing syncing to stop.

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.

Note

Low Risk
Small, localized logic change to UI instance bookkeeping in background.js with no auth, key-management, or data persistence changes; main risk is miscounting causing UI-open detection or cleanup to behave incorrectly.

Overview
Fixes sidepanel open-state tracking in background.js by replacing the single sidePanelIsOpen flag with an openSidePanelCount counter to correctly handle multiple simultaneous sidepanel instances.

Open/close logic and related checks now key off the counter, including isClientOpen status, trackAppOpened gating, triggerUi popup suppression, and environment cleanup so onEnvironmentTypeClosed(ENVIRONMENT_TYPE_SIDEPANEL) only runs when the last sidepanel instance disconnects (avoiding premature polling/cleanup).

Written by Cursor Bugbot for commit 2871366. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Copy Markdown
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.

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 20, 2026

Builds ready [d5055d6]
⚡ Performance Benchmarks (1459 ± 108 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account29016303304
total29016303304
Confirm Txconfirm_tx60651160756080
total60651160756080
Bridge User Actionsbridge_load_page27538288339
bridge_load_asset_picker16428181207
bridge_search_token7064706711
total11172311371142
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14591269190610815081639
load12231029170710012661390
domContentLoaded1216102616969812511383
domInteractive2916103202587
firstPaint184711294196207365
backgroundConnect21119128013215235
firstReactRender20124752130
initialActions106113
loadScripts101984114999810481187
setupStore1372851624
numNetworkReqs312290202584
Chrome Browserify Startup Power User HomeuiStartup16551347207713017241882
load1099984155212210991416
domContentLoaded1085975154611710861379
domInteractive3118140193148
firstPaint1636846580217294
backgroundConnect27424536721280310
firstReactRender23144872637
initialActions109113
loadScripts88778913281158841178
setupStore1676391934
numNetworkReqs57361502356124
Chrome Webpack Startup Standard HomeuiStartup86869612261059321045
load746618106196809887
domContentLoaded740613105596804880
domInteractive2916113212481
firstPaint1256535465163268
backgroundConnect25194662836
firstReactRender18124062032
initialActions107112
loadScripts737611105395802878
setupStore1163541217
numNetworkReqs312298202587
Chrome Webpack Startup Power User HomeuiStartup1205844219418512761550
load70862312781106951000
domContentLoaded6996181265109686994
domInteractive36172413631121
firstPaint1246343580114286
backgroundConnect17012844253170291
firstReactRender22173332529
initialActions102011
loadScripts6976161255107683984
setupStore1254361217
numNetworkReqs1083727052138224
Firefox Browserify Startup Standard HomeuiStartup15841382231915516071927
load13431160205613813781618
domContentLoaded13411157204913813721618
domInteractive73332974887177
firstPaint------
backgroundConnect58282282858109
firstReactRender13112011315
initialActions102012
loadScripts13141135203012913471522
setupStore168173211431
numNetworkReqs312199212595
Firefox Browserify Startup Power User HomeuiStartup26331936373238827303377
load15521218221928117162111
domContentLoaded15511218221928117162110
domInteractive11133760106111352
firstPaint------
backgroundConnect259104912227242832
firstReactRender17145961721
initialActions103122
loadScripts15141203215326816712051
setupStore1417766206115638
numNetworkReqs59291513377129
Firefox Webpack Startup Standard HomeuiStartup19441542343041519313194
load16291256299336316292899
domContentLoaded16281256299336316292899
domInteractive147351554253137343
firstPaint------
backgroundConnect9028152915581218
firstReactRender17132931724
initialActions103122
loadScripts16001242296336016032876
setupStore267244352175
numNetworkReqs311988172775
Firefox Webpack Startup Power User HomeuiStartup26811920370644527763594
load15531278233928016482287
domContentLoaded15531278233928016472287
domInteractive1043163499102221
firstPaint------
backgroundConnect2881051287237288878
firstReactRender22167692329
initialActions103122
loadScripts15051259228824316091925
setupStore1497816208142621
numNetworkReqs55171323379128
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192220221
srpButtonToSrpForm9429696
confirmSrpToPwForm2102222
pwFormToMetricsScreen1601616
metricsToWalletReadyScreen1711718
doneButtonToHomeScreen114929614421521
openAccountMenuToAccountListLoaded72521172647264
total88194688568856
Onboarding New WalletcreateWalletToSocialScreen2181218220
srpButtonToPwForm1031104104
createPwToRecoveryScreen8088
skipBackupToMetricsScreen3723839
agreeButtonToOnboardingSuccess1611616
doneButtonToAssetList54456591610
total93251972988
Asset DetailsassetClickToPriceChart3743844
total3743844
Solana Asset DetailsassetClickToPriceChart4964759
total4964759
Import Srp HomeloginToHomeScreen208916422612275
openAccountMenuAfterLogin4574758
homeAfterImportWithNewWallet249318626132751
total45138445634604
Send TransactionsopenSendPageFromHome1811820
selectTokenToSendFormLoaded2012122
reviewTransactionToConfirmationPage8536855863
total8915890899
SwapopenSwapPageFromHome11612127130
fetchAndDisplaySwapQuotes562186063666375
total575084064796496
🌐 Dapp Page Load Benchmarks

Current Commit: d5055d6 | Date: 2/20/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±40ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 717ms (±61ms) 🟢 | historical mean value: 726ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 89ms (±126ms) 🟢 | historical mean value: 80ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 40ms 1.02s 1.36s 1.07s 1.36s
domContentLoaded 717ms 61ms 687ms 1.28s 739ms 1.28s
firstPaint 89ms 126ms 60ms 1.34s 88ms 1.34s
firstContentfulPaint 89ms 126ms 60ms 1.34s 88ms 1.34s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 122 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@davidmurdoch davidmurdoch marked this pull request as ready for review February 20, 2026 21:15
@davidmurdoch davidmurdoch moved this to Needs dev review in PR review queue Feb 20, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 23, 2026

Builds ready [2871366]
⚡ Performance Benchmarks (1361 ± 106 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2602261262
total2602261262
Confirm Txconfirm_tx6025460256032
total6025460256032
Bridge User Actionsbridge_load_page23337256290
bridge_load_asset_picker1999206209
bridge_search_token71920732742
total11637112281236
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup13611134177710613881560
load116396915139811901353
domContentLoaded115694414829611801322
domInteractive2817136232392
firstPaint151651170124202262
backgroundConnect20118726614203227
firstReactRender18134841925
initialActions104113
loadScripts9717611291979981132
setupStore1264061420
numNetworkReqs312291192285
Chrome Browserify Startup Power User HomeuiStartup3285139110572179740255747
load12071025167312312321526
domContentLoaded11901017165111712131518
domInteractive34191542730113
firstPaint215831268163264386
backgroundConnect12782608658144418293247
firstReactRender2516153142536
initialActions105113
loadScripts990829142011310021317
setupStore1464661625
numNetworkReqs85251532399133
Chrome Webpack Startup Standard HomeuiStartup8617051266998911027
load739621103289785888
domContentLoaded734616102389780883
domInteractive2915152232482
firstPaint1225976895128280
backgroundConnect27195483144
firstReactRender18124362031
initialActions106112
loadScripts731614101487778878
setupStore1264251318
numNetworkReqs312296202585
Chrome Webpack Startup Power User HomeuiStartup1273892292331713341836
load7366331435125731961
domContentLoaded7266261420125719953
domInteractive42172394233123
firstPaint1687362194202364
backgroundConnect18211481084173308
firstReactRender22164942428
initialActions102011
loadScripts7236241412124716950
setupStore1253961418
numNetworkReqs1215024042149209
Firefox Browserify Startup Standard HomeuiStartup17001448252519817242099
load14331227217016514791703
domContentLoaded14321227216516514771703
domInteractive833431452113151
firstPaint------
backgroundConnect5729128186087
firstReactRender14112721416
initialActions103112
loadScripts14051197213415914521668
setupStore2371863616124
numNetworkReqs321995202791
Firefox Browserify Startup Power User HomeuiStartup27922146489037830073355
load16031360368126216441923
domContentLoaded16021360368026216381923
domInteractive15854616118167417
firstPaint------
backgroundConnect3951041409303458994
firstReactRender19146681922
initialActions202122
loadScripts15571336362825315821884
setupStore14715764162192460
numNetworkReqs82351863692168
Firefox Webpack Startup Standard HomeuiStartup17771452341533217692108
load14721288302023314961600
domContentLoaded14721288302023314961600
domInteractive962630945130149
firstPaint------
backgroundConnect8131156115474174
firstReactRender16134241621
initialActions103122
loadScripts14471264299323114671570
setupStore227182311657
numNetworkReqs302094162769
Firefox Webpack Startup Power User HomeuiStartup27912159425534929103463
load15571318281424316151963
domContentLoaded15571318281424316151963
domInteractive175521464187176517
firstPaint------
backgroundConnect49612112623187571047
firstReactRender20155552227
initialActions203122
loadScripts15121294277723015671873
setupStore12117784138130433
numNetworkReqs85312333793164
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2171219219
srpButtonToSrpForm9129394
confirmSrpToPwForm2102122
pwFormToMetricsScreen1501515
metricsToWalletReadyScreen1501616
doneButtonToHomeScreen117815112061414
openAccountMenuToAccountListLoaded694247372307618
total837753990069009
Onboarding New WalletcreateWalletToSocialScreen2200220220
srpButtonToPwForm1111112112
createPwToRecoveryScreen901010
skipBackupToMetricsScreen3713738
agreeButtonToOnboardingSuccess1711818
doneButtonToAssetList105033513231449
total144033117211825
Asset DetailsassetClickToPriceChart3944344
total3944344
Solana Asset DetailsassetClickToPriceChart5375663
total5375663
Import Srp HomeloginToHomeScreen22506822992301
openAccountMenuAfterLogin4974960
homeAfterImportWithNewWallet282012028972994
total51309152275244
Send TransactionsopenSendPageFromHome33124344
selectTokenToSendFormLoaded2022023
reviewTransactionToConfirmationPage86722880903
total92213929941
SwapopenSwapPageFromHome1184118123
fetchAndDisplaySwapQuotes46517247314736
total47737548534868
🌐 Dapp Page Load Benchmarks

Current Commit: 2871366 | Date: 2/23/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±44ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 720ms (±41ms) 🟢 | historical mean value: 735ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±10ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 44ms 995ms 1.32s 1.08s 1.32s
domContentLoaded 720ms 41ms 687ms 997ms 756ms 997ms
firstPaint 76ms 10ms 60ms 156ms 84ms 156ms
firstContentfulPaint 76ms 10ms 60ms 156ms 84ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 122 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Feb 25, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main with commit f97078d Feb 25, 2026
177 checks passed
@davidmurdoch davidmurdoch deleted the fix/sidepanel-open-counter branch February 25, 2026 18:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2026
@metamaskbot metamaskbot added the release-13.21.0 Issue or pull request that will be included in release 13.21.0 label Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.21.0 Issue or pull request that will be included in release 13.21.0 size-S team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants