Skip to content

Conversation

@MajorLift
Copy link
Contributor

@MajorLift MajorLift commented Nov 27, 2025

Motivation

Dependency arrays containing complex expressions e.g. JSON.stringify is an anti-pattern and explicitly forbidden by React rules of hooks.

useEqualityCheck provides change detection logic, but it triggers an extra re-render due to its being implemented with useState. For the purposes of stabilizing hook dependency references, this extra render is often unnecessary.

  • We need a dedicated construct to encapsulate change detection and reference stabilization for composite data structures.
  • Opportunities to optimize stringify usage, polling logic.
  • Multiple race conditions need fixing.

Description

useSyncEqualityCheck

Optimizations:

  • Unlike useEqualityCheck, runs without triggering extra re-renders.
  • Replaces JSON.stringify with fast-json-stable-stringify (consistent with @metamask/polling-controller).
  • Stringify overhead reduced (only calls JSON.parse to handle mutation)
Input When Cost
No change Most renders O(k) stringify only
Immutable update (new reference) Idiomatic React O(k) stringify + O(1)
In-place mutation Edge case O(k) stringify + O(k) parse

Example: Stringify overhead reduction

Scenario Before After
10 inputs, 10 polls 110+ calls/effect 0 (memoized)
50 inputs, 50 polls 2,550+ calls/effect 0 (memoized)

usePolling

Fixes:

Fix Problem Solution
Stale call prevention Rapid input changes caused orphaned polling tokens callIdRef tracks effect generations, stops stale promises
Unmount safety Component unmount during async left orphans isMounted check before storing token
Cleanup on disable enabled=false didn't stop active polls Explicit cleanup call when disabled
Effect reduction Effect ran on every render useSyncEqualityCheck provides stable refs

useMultiPolling

Optimizations:

inputKeyMap -> Time complexity: Quadratic -> Linear

(N = existing polls, M = inputs, k = serialized size)

Operation Before After
Start new polls O(M × k) O(M)
Stop removed polls O(N × M × k) O(N)

Fixes (Race Conditions):

Fix Problem Solution
De-duplicate concurrent polls Effect re-runs while promises are pending Prevented by pendingPolls Set
Stale call prevention Orphaned tokens due to unmount or input removed before promise resolves Explicit cleanup calls
Retry rejection after failure Input permanently stuck in pending state finally clears pending, making inputs available for retries

Open in GitHub Codespaces

Changelog

CHANGELOG entry: Optimized network polling requests for tokens, rates, currencies, gas fees etc.

Related issues

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

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

Improves polling reliability and performance via reference-stable inputs and race-safe behavior.

  • New useSyncEqualityCheck (uses fast-json-stable-stringify) to stabilize JSON-serializable deps without extra renders
  • Refactors usePolling to cleanly stop stale tokens, handle unmount/disabled states, and prevent orphaned polls
  • Rewrites useMultiPolling with inputKeyMap and pendingPolls to de-dupe starts, stop removed inputs, and resolve races; linear-time diffs
  • Adds comprehensive tests for both hooks; removes old JS test in favor of TS versions
  • Adds fast-json-stable-stringify dependency; updates LavaMoat policies and yarn.lock accordingly

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

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

@metamaskbot metamaskbot added the team-extension-platform Extension Platform team label Nov 27, 2025
@MajorLift MajorLift changed the title feat: Define useSyncEqualityCheck and use in polling hooks refactor: Define useSyncEqualityCheck and use in polling hooks Nov 27, 2025
@github-project-automation github-project-automation bot moved this to Needs dev review in PR review queue Nov 27, 2025
@MajorLift MajorLift force-pushed the jongsun/perf/react/251127-useSyncEqualityCheck branch 2 times, most recently from be2dc85 to bb0ee4b Compare November 27, 2025 07:54
@MajorLift MajorLift removed the status in PR review queue Nov 27, 2025
@MajorLift MajorLift added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Nov 27, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [bb0ee4b]
UI Startup Metrics (1328 ± 116 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13281074158911614071531
load107188313069711341244
domContentLoaded106587912979611251237
domInteractive2816163232483
firstPaint53083126241410321186
backgroundConnect22619933219232269
firstReactRender392396134463
getState71172353481142
initialActions106114
loadScripts8466811086959091026
setupStore1455671623
numNetworkReqs41291463332141
BrowserifyPower User HomeuiStartup20661727297223922292547
load1010884143212110121311
domContentLoaded997880141212110001299
domInteractive34161532735111
firstPaint53311914503999511304
backgroundConnect24520159685229515
firstReactRender6041125156395
getState220131716127209659
initialActions104113
loadScripts79268211931207971095
setupStore19116272230
numNetworkReqs103652855398268
WebpackStandard HomeuiStartup87273114161138921090
load64657188375678825
domContentLoaded64156787775673819
domInteractive2816114222393
firstPaint242103807172225677
backgroundConnect10583101021
firstReactRender3722114183986
getState51161803062102
initialActions109112
loadScripts63856586673671809
setupStore1444471534
numNetworkReqs41291473431143
WebpackPower User HomeuiStartup17731382293930720542326
load7066171375111710966
domContentLoaded6946081365111695960
domInteractive39201623040115
firstPaint3641081396246626798
backgroundConnect79771017821602
firstReactRender7047108127696
getState21215374692205279
initialActions104112
loadScripts6916061355110692951
setupStore221083132353
numNetworkReqs1576840265186291
FirefoxBrowserifyStandard HomeuiStartup14721198192017216071813
load1129984150311412211376
domContentLoaded1129979150311412211376
domInteractive68324004589114
firstPaint------
backgroundConnect732625651100189
firstReactRender302087133461
getState2410205202241
initialActions206123
loadScripts1092964143410211591295
setupStore249103162259
numNetworkReqs40281282634117
BrowserifyPower User HomeuiStartup26772114517345028213406
load12221064259623412241570
domContentLoaded12221064259623412231569
domInteractive13150516103124433
firstPaint------
backgroundConnect161421403187159490
firstReactRender6041119166298
getState30477973215418780
initialActions2145423
loadScripts11811027246620011951505
setupStore1886881197267667
numNetworkReqs102643156480244
WebpackStandard HomeuiStartup16211355235417517251976
load12771102168212013401492
domContentLoaded12771102168212013401492
domInteractive58271543384130
firstPaint------
backgroundConnect62181593169136
firstReactRender31216593547
getState3093114521153
initialActions206123
loadScripts12501084165611413161453
setupStore2710158252789
numNetworkReqs41281322738122
WebpackPower User HomeuiStartup29952165835882431064591
load15241200662663015002701
domContentLoaded15231200662663014992701
domInteractive139311023179107457
firstPaint------
backgroundConnect138321048166147282
firstReactRender65442142566115
getState259721090228290792
initialActions318227
loadScripts14701159660760114662512
setupStore1457672169169596
numNetworkReqs101622525978243
📊 Page Load Benchmark Results

Current Commit: bb0ee4b | Date: 11/27/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±40ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 718ms (±38ms) 🟢 | historical mean value: 723ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±12ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 40ms 1.00s 1.34s 1.05s 1.34s
domContentLoaded 718ms 38ms 696ms 1.02s 737ms 1.02s
firstPaint 75ms 12ms 56ms 180ms 84ms 180ms
firstContentfulPaint 75ms 12ms 56ms 180ms 84ms 180ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.38 KiB (0.02%)
  • common: 20 Bytes (0%)

@MajorLift MajorLift marked this pull request as ready for review November 27, 2025 09:01
@MajorLift MajorLift moved this to Needs dev review in PR review queue Nov 27, 2025
@MajorLift MajorLift changed the title refactor: Define useSyncEqualityCheck and use in polling hooks fix: Define and use useSyncEqualityCheck to fix polling hooks Nov 27, 2025
@MajorLift MajorLift force-pushed the jongsun/perf/react/251127-useSyncEqualityCheck branch from bb0ee4b to f577186 Compare November 27, 2025 09:27
@metamaskbot
Copy link
Collaborator

Builds ready [e7f895d]
UI Startup Metrics (1274 ± 125 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12741058168312513211551
load1028861128910610731264
domContentLoaded1022856128310510661250
domInteractive2616102192283
firstPaint57291129541810101227
backgroundConnect21319325312219239
firstReactRender3622114143860
getState65161503087122
initialActions104113
loadScripts81465510591018591032
setupStore1475181536
numNetworkReqs41281463330141
BrowserifyPower User HomeuiStartup20541622267525623272543
load1015888146512610381370
domContentLoaded1001882145712610141361
domInteractive34171572434102
firstPaint6519414684069801294
backgroundConnect251202788116227615
firstReactRender5939115146394
getState18613965555197245
initialActions104113
loadScripts79668212331248061144
setupStore20116492241
numNetworkReqs1126628059113273
WebpackStandard HomeuiStartup1149893163915312281492
load79165012441128451042
domContentLoaded78364312321118391034
domInteractive41191673734154
firstPaint3591371027234452826
backgroundConnect208181261775
firstReactRender58282143957157
getState911725547122169
initialActions105113
loadScripts78064012181098361021
setupStore258124212665
numNetworkReqs41281383233136
WebpackPower User HomeuiStartup16621307227525218752127
load688598105490697947
domContentLoaded677592104890690931
domInteractive38171953634149
firstPaint293100947200275717
backgroundConnect881058416726550
firstReactRender6446107117087
getState18111574779176225
initialActions103112
loadScripts675590103888688922
setupStore211064112447
numNetworkReqs101652985597277
FirefoxBrowserifyStandard HomeuiStartup14621206195916215611793
load1122971141210811961337
domContentLoaded1122971141110911951337
domInteractive65312233986135
firstPaint------
backgroundConnect72342485087209
firstReactRender27195672946
getState2611167202752
initialActions205122
loadScripts1092946137310011511285
setupStore2891492624101
numNetworkReqs40281242734121
BrowserifyPower User HomeuiStartup25941964410235927183265
load11831028156213411971518
domContentLoaded11821027156113411971517
domInteractive12836537103120435
firstPaint------
backgroundConnect14043957114142380
firstReactRender6039148176392
getState27158883197346718
initialActions3035528
loadScripts1145997153712911541488
setupStore20211916218257710
numNetworkReqs101623086278244
WebpackStandard HomeuiStartup17091452240120317802155
load13301157169311913771590
domContentLoaded13301156169311913761589
domInteractive67291983586131
firstPaint------
backgroundConnect71222754883183
firstReactRender3421101113953
getState319273363071
initialActions213123
loadScripts12981133162910613471527
setupStore29101422627101
numNetworkReqs41281282836123
WebpackPower User HomeuiStartup30642389519158932024667
load15061235307536715572821
domContentLoaded15061234307536715572821
domInteractive137321001164110470
firstPaint------
backgroundConnect155271320172167240
firstReactRender7246272287299
getState27481961208290742
initialActions3131334
loadScripts14421207278128515171807
setupStore14211727176137645
numNetworkReqs101623086277242
📊 Page Load Benchmark Results

Current Commit: e7f895d | Date: 11/27/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1000ms (±41ms) 🟢 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 691ms (±38ms) 🟢 | historical mean value: 723ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±11ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1000ms 41ms 973ms 1.27s 1.04s 1.27s
domContentLoaded 691ms 38ms 670ms 945ms 715ms 945ms
firstPaint 77ms 11ms 64ms 172ms 88ms 172ms
firstContentfulPaint 77ms 11ms 64ms 172ms 88ms 172ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.38 KiB (0.02%)
  • common: 20 Bytes (0%)

@MajorLift MajorLift marked this pull request as draft November 27, 2025 17:40
@MajorLift MajorLift removed the status in PR review queue Nov 27, 2025
@MajorLift MajorLift changed the title fix: Define and use useSyncEqualityCheck to fix polling hooks fix: Define useSyncEqualityCheck to fix polling hooks Nov 27, 2025
@MajorLift MajorLift force-pushed the jongsun/perf/react/251127-useSyncEqualityCheck branch from ae28b07 to 702c081 Compare November 28, 2025 02:09
@MajorLift
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

metamaskbot commented Nov 28, 2025

✨ Files requiring CODEOWNER review ✨

📜 @MetaMask/policy-reviewers (7 files, +32 -32)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +6 -6
      • 📁 experimental/
        • 📄 policy.json +6 -6
      • 📁 flask/
        • 📄 policy.json +6 -6
      • 📁 main/
        • 📄 policy.json +6 -6
    • 📁 build-system/
      • 📄 policy.json +1 -1
    • 📁 webpack/
      • 📁 mv2/
        • 📄 policy.json +6 -6
      • 📁 mv3/
        • 📄 policy.json +1 -1

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.

@metamaskbot
Copy link
Collaborator

Builds ready [c7904b5]
UI Startup Metrics (1301 ± 112 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13011013164211213801476
load109286813279911681253
domContentLoaded108586513169811611246
domInteractive3115184302494
firstPaint55890138243510971222
backgroundConnect23319728716242262
firstReactRender3420142163659
getState3717134184262
initialActions103113
loadScripts8596711096969201020
setupStore1272541423
numNetworkReqs1257720571
BrowserifyPower User HomeuiStartup20061690309323420572496
load100188817191329971280
domContentLoaded98887916971329901272
domInteractive34171742832113
firstPaint5059817253789311213
backgroundConnect266197558107243528
firstReactRender5739126136288
getState18714067172193236
initialActions104112
loadScripts78368014631307821070
setupStore19104982241
numNetworkReqs101652875394259
WebpackStandard HomeuiStartup814689103277842988
load63156084871661796
domContentLoaded62655584271651791
domInteractive2614109212190
firstPaint20299682116195597
backgroundConnect1052751325
firstReactRender27194463138
getState281474123555
initialActions105111
loadScripts62455383369649782
setupStore1163041320
numNetworkReqs1257720572
WebpackPower User HomeuiStartup16431259232925519202096
load6715851069100670930
domContentLoaded6615791063101658924
domInteractive36171592934116
firstPaint28588919195301731
backgroundConnect75760815919547
firstReactRender6144100106682
getState17213865851177203
initialActions102012
loadScripts658577105399655915
setupStore1875292146
numNetworkReqs1556839674188337
FirefoxBrowserifyStandard HomeuiStartup12791062181813013411551
load106191914119311181226
domContentLoaded106091914109311181225
domInteractive51291302469100
firstPaint------
backgroundConnect41221462442115
firstReactRender23185062336
getState147215261023
initialActions103122
loadScripts103490513628510851170
setupStore1255081332
numNetworkReqs1157115653
BrowserifyPower User HomeuiStartup25121941437248526153905
load1160968240024111371463
domContentLoaded1160967240024111351463
domInteractive12236922128110429
firstPaint------
backgroundConnect10528957108106318
firstReactRender58381482158105
getState23263858186256669
initialActions41588225
loadScripts1116951237220110921432
setupStore1576749187168678
numNetworkReqs100553006179241
WebpackStandard HomeuiStartup14841281228813615731702
load1222106515599112791410
domContentLoaded1221106515599112781409
domInteractive59272593884124
firstPaint------
backgroundConnect47182153153109
firstReactRender26207562734
getState137147161231
initialActions103122
loadScripts1196105014948612561353
setupStore13693141151
numNetworkReqs1156315758
WebpackPower User HomeuiStartup29842171507068729894816
load14961208308041014712693
domContentLoaded14961207308041014712692
domInteractive11530967127106414
firstPaint------
backgroundConnect154331181196146535
firstReactRender70452052771132
getState339611490294580897
initialActions2030323
loadScripts14311115287534714392483
setupStore1187768143130474
numNetworkReqs98603235977241
📊 Page Load Benchmark Results

Current Commit: c7904b5 | Date: 11/28/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±53ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 726ms (±51ms) 🟢 | historical mean value: 726ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±9ms) 🟢 | historical mean value: 79ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 53ms 1.01s 1.33s 1.08s 1.33s
domContentLoaded 726ms 51ms 696ms 1.01s 765ms 1.01s
firstPaint 77ms 9ms 60ms 148ms 84ms 148ms
firstContentfulPaint 77ms 9ms 60ms 148ms 84ms 148ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.71 KiB (0.04%)
  • ui: -56.19 KiB (-0.72%)
  • common: 1.15 KiB (0.01%)

@MajorLift MajorLift force-pushed the jongsun/perf/react/251127-useSyncEqualityCheck branch from 65055ba to c26e7e3 Compare November 28, 2025 12:34
@MajorLift
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

Builds ready [0ba59c7]
UI Startup Metrics (1269 ± 126 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12691035153112613641487
load1061868131010811121271
domContentLoaded1055866130510711061265
domInteractive2715166242387
firstPaint60482131243410721247
backgroundConnect21719629013224244
firstReactRender311971103547
getState3917201254779
initialActions109113
loadScripts84466311001048931043
setupStore1466271627
numNetworkReqs1257420572
BrowserifyPower User HomeuiStartup21121713282226423202682
load1018878161513710141401
domContentLoaded100387316081379911391
domInteractive35171412634129
firstPaint5309815483979541382
backgroundConnect253202791106233550
firstReactRender62421101669100
getState20112974691207259
initialActions103112
loadScripts79467313951347811189
setupStore24686122849
numNetworkReqs1586739872188369
WebpackStandard HomeuiStartup8367191166828631023
load64757697881657832
domContentLoaded64257397280654826
domInteractive2716144232289
firstPaint24283982186222672
backgroundConnect1063451318
firstReactRender29204663341
getState271579113447
initialActions103112
loadScripts63957196979651817
setupStore1263951320
numNetworkReqs1257720573
WebpackPower User HomeuiStartup15961261253827518572103
load6655811170105661911
domContentLoaded6555741166106651905
domInteractive34171843130121
firstPaint26899981189249660
backgroundConnect75768417017563
firstReactRender59458486572
getState17812868374180213
initialActions103112
loadScripts6525721156104649897
setupStore18750102144
numNetworkReqs1596542682195402
FirefoxBrowserifyStandard HomeuiStartup12751083224315713581495
load1061931194012111281205
domContentLoaded1061931194012111281204
domInteractive54301322674108
firstPaint------
backgroundConnect43202203340135
firstReactRender23183752335
getState146251251126
initialActions103112
loadScripts1034914191311410831151
setupStore13693141133
numNetworkReqs1256817662
BrowserifyPower User HomeuiStartup27241978480065728324335
load12091005282130612021655
domContentLoaded12081005282130612011655
domInteractive1113348997105393
firstPaint------
backgroundConnect140291718217117359
firstReactRender64371882566117
getState344751051266536920
initialActions3060727
loadScripts1172978262528011631623
setupStore1236691149144526
numNetworkReqs99553156279242
WebpackStandard HomeuiStartup15341297203415916361815
load12651103166311013171449
domContentLoaded12651103166311013171449
domInteractive60261783682139
firstPaint------
backgroundConnect51191413061120
firstReactRender27204653038
getState167133221248
initialActions102122
loadScripts12381067164210212871401
setupStore176140221474
numNetworkReqs1256917765
WebpackPower User HomeuiStartup29842137498172030894610
load15021173291546215952773
domContentLoaded15011172291546215952772
domInteractive11928970133102428
firstPaint------
backgroundConnect155261284221127499
firstReactRender65431802366120
getState324841185266510859
initialActions217123
loadScripts14171150270735415622523
setupStore111574116786566
numNetworkReqs1005424355119239
📊 Page Load Benchmark Results

Current Commit: 0ba59c7 | Date: 11/28/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±37ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 720ms (±35ms) 🟢 | historical mean value: 728ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±11ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 37ms 1.01s 1.32s 1.06s 1.32s
domContentLoaded 720ms 35ms 698ms 987ms 734ms 987ms
firstPaint 77ms 11ms 60ms 168ms 88ms 168ms
firstContentfulPaint 77ms 11ms 60ms 168ms 88ms 168ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.3 KiB (0.02%)
  • common: 36 Bytes (0%)

@MajorLift MajorLift changed the title fix: Optimize use{,Multi}Polling by defining useSyncEqualityCheck feat(perf): Optimize use{,Multi}Polling by defining useSyncEqualityCheck Dec 11, 2025
Gudahtt
Gudahtt previously approved these changes Dec 12, 2025
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

One nit comment left, but otherwise LGTM!

ZXing0517

This comment was marked as spam.

@metamaskbot
Copy link
Collaborator

Builds ready [cd2559b]
UI Startup Metrics (1301 ± 108 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13011036178810813701434
load107387614979811381198
domContentLoaded106686714929811321191
domInteractive251698172376
firstPaint53889125441610571179
backgroundConnect21520028612217238
firstReactRender503396155880
getState4016105164473
initialActions106112
loadScripts859672125996921974
setupStore1346471423
numNetworkReqs181176181170
BrowserifyPower User HomeuiStartup18831509251519119482292
load1044881149812310991261
domContentLoaded1033873146212010891250
domInteractive3017148232793
firstPaint56310015054219951264
backgroundConnect24219665186233526
firstReactRender49399575060
getState20414171194206296
initialActions103112
loadScripts82367612581188691036
setupStore191054112839
numNetworkReqs73522082578135
WebpackStandard HomeuiStartup8606961290929121015
load66058196675724790
domContentLoaded65457795875719785
domInteractive2616101192282
firstPaint22878963171220667
backgroundConnect2661413035107
firstReactRender61362994154139
getState3515147234465
initialActions104112
loadScripts65157594874716777
setupStore1163961224
numNetworkReqs181179171167
WebpackPower User HomeuiStartup14221097209720615371845
load720604114495753907
domContentLoaded713594113795747897
domInteractive32171432726109
firstPaint287101907208280714
backgroundConnect1157670182134612
firstReactRender51437055363
getState18614474683180252
initialActions103112
loadScripts710592112794745893
setupStore16653101439
numNetworkReqs73531462278130
FirefoxBrowserifyStandard HomeuiStartup13701092213317314531656
load1071918187713211141257
domContentLoaded1070918187713211131256
domInteractive72318388786135
firstPaint------
backgroundConnect54203775451175
firstReactRender40327094064
getState136125151125
initialActions103122
loadScripts1043902181511810921220
setupStore155149191146
numNetworkReqs19981191376
BrowserifyPower User HomeuiStartup26191717383557330533614
load1611973264851020692499
domContentLoaded1611973264751020692499
domInteractive183321001286112979
firstPaint------
backgroundConnect177271170215201910
firstReactRender5736145156190
getState1386727939162210
initialActions41408333
loadScripts1527957262847119332379
setupStore494106114934102
numNetworkReqs75531502187114
WebpackStandard HomeuiStartup15991307218916917181905
load13071116165511613711560
domContentLoaded13071116165411613701559
domInteractive75282293897132
firstPaint------
backgroundConnect692116541107140
firstReactRender43337174557
getState207162281578
initialActions103122
loadScripts12721098163010613241505
setupStore155102151449
numNetworkReqs19980201477
WebpackPower User HomeuiStartup27911767381755632073575
load18751149273150123632683
domContentLoaded18751148273050123622683
domInteractive18130101429192976
firstPaint------
backgroundConnect163251057206188952
firstReactRender5841124106469
getState144711043104175251
initialActions217125
loadScripts18041133270346622422553
setupStore3853285450139
numNetworkReqs73481432283117
📊 Page Load Benchmark Results

Current Commit: cd2559b | Date: 12/12/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±61ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 725ms (±60ms) 🟢 | historical mean value: 730ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 75ms (±10ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 61ms 1.01s 1.31s 1.26s 1.31s
domContentLoaded 725ms 60ms 697ms 990ms 931ms 990ms
firstPaint 75ms 10ms 60ms 156ms 88ms 156ms
firstContentfulPaint 75ms 10ms 60ms 156ms 88ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.47 KiB (0.02%)
  • common: 36 Bytes (0%)

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@metamaskbot
Copy link
Collaborator

Builds ready [3551aaa]
UI Startup Metrics (1299 ± 98 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1299106715729813571468
load107487113349311301239
domContentLoaded106786613249311241220
domInteractive2815125212381
firstPaint606103133142810641197
backgroundConnect21619132414220233
firstReactRender4735151174881
getState3918133154363
initialActions104112
loadScripts8596801111929151013
setupStore1242941222
numNetworkReqs171175171169
BrowserifyPower User HomeuiStartup18791571237915719552171
load1045889136111011281264
domContentLoaded1034882132410811181249
domInteractive3017153242694
firstPaint5229613424019701209
backgroundConnect256193759109237586
firstReactRender50398895178
getState18914472761200233
initialActions106112
loadScripts82567611171069091045
setupStore1665291437
numNetworkReqs66561311564114
WebpackStandard HomeuiStartup8657021061859291022
load67658885977741811
domContentLoaded67058484877736805
domInteractive261794192385
firstPaint26276863197240752
backgroundConnect216145242465
firstReactRender58361953452142
getState3216150184259
initialActions103112
loadScripts66658184676733802
setupStore1264071333
numNetworkReqs181183181169
WebpackPower User HomeuiStartup14201089205619115041786
load715595109690746884
domContentLoaded709588108990741877
domInteractive33172103226115
firstPaint266103866178256697
backgroundConnect1047631158138571
firstReactRender51426855360
getState18214574461185240
initialActions103112
loadScripts706585108089739869
setupStore1664491538
numNetworkReqs67541371963122
FirefoxBrowserifyStandard HomeuiStartup13681075183717814731711
load1068889137411311581271
domContentLoaded1067888137411311581270
domInteractive63301663485123
firstPaint------
backgroundConnect56212054073151
firstReactRender39318193962
getState165230281163
initialActions103112
loadScripts1036870133910210951244
setupStore196421461155
numNetworkReqs191087191473
BrowserifyPower User HomeuiStartup25901626358357531193398
load16371000257550821162363
domContentLoaded16371000257550821162363
domInteractive15333102124891956
firstPaint------
backgroundConnect142271154136195343
firstReactRender59371922063101
getState1316829844159230
initialActions4158829
loadScripts1562984237248020212320
setupStore3952715544194
numNetworkReqs72541352377129
WebpackStandard HomeuiStartup16351346213817917651952
load13191130163210513901525
domContentLoaded13181130163110513891525
domInteractive822923043107144
firstPaint------
backgroundConnect65182214191146
firstReactRender4434100104859
getState206248331560
initialActions103122
loadScripts1285110916099613491466
setupStore2361963317100
numNetworkReqs20981191476
WebpackPower User HomeuiStartup26751754384854531323560
load18491186308650423372617
domContentLoaded18491185308650423372617
domInteractive2773015253823001027
firstPaint------
backgroundConnect14229961166201385
firstReactRender5741103106271
getState1376627249172242
initialActions3043426
loadScripts17961169306348322642559
setupStore3453825931128
numNetworkReqs72531392378128
📊 Page Load Benchmark Results

Current Commit: 3551aaa | Date: 12/15/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±72ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 728ms (±69ms) 🟢 | historical mean value: 731ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 74ms (±11ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 72ms 1.00s 1.32s 1.25s 1.32s
domContentLoaded 728ms 69ms 696ms 1.01s 929ms 1.01s
firstPaint 74ms 11ms 56ms 164ms 84ms 164ms
firstContentfulPaint 74ms 11ms 56ms 164ms 84ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 3.56 KiB (0.07%)
  • ui: 3.76 KiB (0.05%)
  • common: 1.21 KiB (0.01%)

@MajorLift MajorLift moved this from Review in progress to Has approvals, needs CODEOWNER in PR review queue Dec 18, 2025
@MajorLift MajorLift requested review from a team December 18, 2025 17:21
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 7, 2026

Builds ready [460939c]
UI Startup Metrics (1293 ± 111 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12931049168811113461493
load1086880143310311411255
domContentLoaded1080872142510211351246
domInteractive261594202390
firstPaint156661248128194308
backgroundConnect21620128211218238
firstReactRender1593351726
getState3718109164370
initialActions102112
loadScripts87266712061029291036
setupStore1384151325
numNetworkReqs171178171168
BrowserifyPower User HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
numNetworkReqs------
WebpackStandard HomeuiStartup805644108294873978
load65257288677711808
domContentLoaded64756888077707802
domInteractive241589182080
firstPaint1005830546112194
backgroundConnect245130273290
firstReactRender15103941623
getState301667133955
initialActions103112
loadScripts64456687876704799
setupStore1264571226
numNetworkReqs181181171168
WebpackPower User HomeuiStartup1170939181914512441503
load72660694186804901
domContentLoaded71959893586795895
domInteractive31171332627104
firstPaint1286440368180251
backgroundConnect58859811455461
firstReactRender16132011718
getState14712466754148179
initialActions103111
loadScripts71659692785792886
setupStore1485971336
numNetworkReqs65531281862124
FirefoxBrowserifyStandard HomeuiStartup13781114201816914721726
load109993613539611751268
domContentLoaded109993613539611751267
domInteractive73351953691150
firstPaint------
backgroundConnect62203215190163
firstReactRender1294141219
getState136147161226
initialActions102122
loadScripts105992012527911101223
setupStore165167251156
numNetworkReqs20988191779
BrowserifyPower User HomeuiStartup25821445376261430833326
load1784995287160523292587
domContentLoaded1783995287160523282587
domInteractive953499711881304
firstPaint------
backgroundConnect44523122444610101177
firstReactRender221266112653
getState116541223118124161
initialActions213123
loadScripts1448981269248420672356
setupStore395108711424127
numNetworkReqs75521552891144
WebpackStandard HomeuiStartup15951302235318717231946
load13281126173112714191570
domContentLoaded13271126173112714191570
domInteractive852823241119150
firstPaint------
backgroundConnect60202604576146
firstReactRender15115661525
getState176153231454
initialActions1017222
loadScripts12901082161911113711526
setupStore175160221356
numNetworkReqs20988191476
WebpackPower User HomeuiStartup25791571392855930423347
load19391101344654424122706
domContentLoaded19391101344154424122705
domInteractive8129105312561358
firstPaint------
backgroundConnect2602612413103241089
firstReactRender19126482128
getState1016021633121163
initialActions203123
loadScripts17521088343248921982525
setupStore30410731081872
numNetworkReqs74521573078149
📊 Page Load Benchmark Results

Current Commit: 460939c | Date: 1/7/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±71ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±68ms) 🟢 | historical mean value: 725ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±10ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 71ms 1.00s 1.32s 1.27s 1.32s
domContentLoaded 732ms 68ms 695ms 989ms 950ms 989ms
firstPaint 76ms 10ms 60ms 156ms 84ms 156ms
firstContentfulPaint 76ms 10ms 60ms 156ms 84ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.55 KiB (0.02%)
  • common: 36 Bytes (0%)

@github-project-automation github-project-automation bot moved this from Has approvals, needs CODEOWNER to Review finalised - Ready to be merged in PR review queue Jan 7, 2026
@MajorLift MajorLift added this pull request to the merge queue Jan 7, 2026
Merged via the queue into main with commit 0d87c97 Jan 7, 2026
175 of 176 checks passed
@MajorLift MajorLift deleted the jongsun/perf/react/251127-useSyncEqualityCheck branch January 7, 2026 18:38
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
@metamaskbot metamaskbot added the release-13.14.0 Issue or pull request that will be included in release 13.14.0 label Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants