Skip to content

fix: cp-12.17.3 fix repeated re-rendering of approve row in simulations section #32658

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

Merged
merged 10 commits into from
May 9, 2025

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented May 8, 2025

Description

Fix repeated re-rendering of approve row in simulations section

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/4836

Manual testing steps

  1. Go to https://jumper.exchange/
  2. Submit a swap
  3. Ensure that approve row does not repeatedly re-renders

Screenshots/Recordings

Screenshot 2025-05-08 at 11 06 58 AM

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.

@jpuri jpuri requested a review from a team as a code owner May 8, 2025 05:43
@jpuri jpuri added the team-confirmations Push issues to confirmations team label May 8, 2025
Copy link
Contributor

github-actions bot commented May 8, 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.

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

✅ @MetaMask/confirmations

  • ui/pages/confirmations/components/confirm/info/batch/batch-simulation-details/batch-simulation-details.tsx
  • ui/pages/confirmations/components/confirm/info/hooks/useBatchApproveBalanceChanges.ts

@metamaskbot
Copy link
Collaborator

Builds ready [2a46325]
UI Startup Metrics (1226 ± 65 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1226110014216512661358
load106797512125610911188
domContentLoaded106096512065610851182
domInteractive17142731725
firstPaint71284121842510781171
backgroundConnect74274716
firstReactRender20163942132
getState1453682029
initialActions001001
loadScripts81771994153839929
setupStore84202814
WebpackHomeuiStartup21791661252416322962369
load16781306202012217611839
domContentLoaded16721301201512117551831
domInteractive151152101347
firstPaint1616268271172262
backgroundConnect281084133554
firstReactRender18854364103292345
getState1454171628
initialActions326146
loadScripts16671296199212217521827
setupStore237219262439
FirefoxBrowserifyHomeuiStartup13461160172512113981579
load11981036152511012571422
domContentLoaded11971036152511012571422
domInteractive953618024104138
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2513371392139
firstReactRender24196082354
getState9419219813
initialActions001001
loadScripts11771023150810412321401
setupStore6434369
WebpackHomeuiStartup15661387200313916501887
load13441176174712514341606
domContentLoaded13441176174712514331605
domInteractive78331651984120
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2914297402465
firstReactRender35295043744
getState15532437932
initialActions102111
loadScripts13191160168411514181550
setupStore85264917
Benchmark value 1182 exceeds gate value 1180 for chrome browserify home p95 domContentLoaded
Benchmark value 29 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 65 exceeds gate value 49 for firefox webpack home p95 backgroundConnect
Sum of mean exceeds: 3ms | Sum of p95 exceeds: 18ms
Sum of all benchmark exceeds: 21ms

Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 114 Bytes (0%)
  • common: 0 Bytes (0%)

@metamaskbot
Copy link
Collaborator

Builds ready [e5862cf]
UI Startup Metrics (1233 ± 60 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1233109814126012731326
load107796712295611051177
domContentLoaded106996112245710991171
domInteractive17142831725
firstPaint71771123643410951177
backgroundConnect84284819
firstReactRender20164252132
getState1353171924
initialActions001001
loadScripts82571096456853933
setupStore85192813
WebpackHomeuiStartup22321848258516323562472
load17391388217514518181946
domContentLoaded17331384217014418121941
domInteractive15125381440
firstPaint1716638663184315
backgroundConnect321099194572
firstReactRender19756438113304351
getState214316411878
initialActions318247
loadScripts17271383216714518091935
setupStore19764112540
FirefoxBrowserifyHomeuiStartup13521184168210914201598
load12081040152710612831451
domContentLoaded12071040152710612831451
domInteractive1003719826117144
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect211491122039
firstReactRender24196182250
getState74182810
initialActions001001
loadScripts11891022150510412591388
setupStore6434568
WebpackHomeuiStartup15741365214115116441888
load13501162184213214421612
domContentLoaded13501162184213214411612
domInteractive77361341586105
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect23155482439
firstReactRender36304853946
getState12429429927
initialActions001011
loadScripts13301147182113214111587
setupStore10527026818
cc: @HowardBraham
Benchmark value 1077 exceeds gate value 1070 for chrome browserify home mean load
Benchmark value 1070 exceeds gate value 1061 for chrome browserify home mean domContentLoaded
Benchmark value 19 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 2233 exceeds gate value 2192 for chrome webpack home mean uiStartup
Benchmark value 1739 exceeds gate value 1711 for chrome webpack home mean load
Benchmark value 1733 exceeds gate value 1704 for chrome webpack home mean domContentLoaded
Benchmark value 1728 exceeds gate value 1699 for chrome webpack home mean loadScripts
Benchmark value 2472 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Sum of mean exceeds: 143ms | Sum of p95 exceeds: 19ms
Sum of all benchmark exceeds: 162ms

Bundle size diffs [🚀 Bundle size reduced!]
  • background: -170 Bytes (0%)
  • ui: 114 Bytes (0%)
  • common: 0 Bytes (0%)

@@ -66,7 +70,7 @@ function useBatchApproveSimulationBalanceChanges({
}) {
return useAsyncResult(
async () => buildSimulationTokenBalanceChanges({ nestedTransactions }),
[nestedTransactions],
[nestedTransactions?.length],
Copy link
Member

Choose a reason for hiding this comment

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

If we're using the full nestedTransactions in the callback, then we have no choice but to use it as a dependency also, as otherwise we won't re-query with the latest data?

For example, if it was entirely new, but the same length.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nestedTransactions are not likely to change thus even nestedTransactions?.length is ok to depend on and this does seem to fix re-rendering issue.

Copy link
Member

@matthewwalsh0 matthewwalsh0 May 8, 2025

Choose a reason for hiding this comment

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

Unfortunately we can't couple that decision here though as this component shouldn't know how often nestedTransactions will update, only that we do an async request based on the latest nested transaction data.

If this is the fix, that suggests the deeper issue is that the nestedTransactions reference is changing despite the data itself not changing.

So ideally we'd debug that or as a temporary fix only, use a "deep equal" dependency such as JSON.stringify(nestedTransactions).

Or if something actually is changing inside nestedTransactions, change the dependency to require only what is required and not the dynamic portion.

? () => handleEdit(change)
: undefined,
}));
const approveRow: StaticRow[] = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, should we call this approveRows now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR.

@metamaskbot
Copy link
Collaborator

Builds ready [248c93f]
UI Startup Metrics (1197 ± 63 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1197109313686312401305
load104894412056111001158
domContentLoaded104293912026210951150
domInteractive16133341626
firstPaint65678120042810581123
backgroundConnect74264719
firstReactRender18153331925
getState14682111830
initialActions001001
loadScripts80370295860853911
setupStore75132711
WebpackHomeuiStartup21851728250814822812383
load17071329213212717771902
domContentLoaded17001325212812617731889
domInteractive151161101346
firstPaint1696135665194303
backgroundConnect299210263359
firstReactRender16754370110296354
getState144157161631
initialActions316135
loadScripts16951324212712517711881
setupStore2562834321156
FirefoxBrowserifyHomeuiStartup13671174180510714201563
load1212101814809512751391
domContentLoaded1212101714809512741391
domInteractive1043619530120167
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect20146372133
firstReactRender25195992353
getState11421026811
initialActions006101
loadScripts1194100414649412541366
setupStore9419719619
WebpackHomeuiStartup16321379226217817052040
load13991199190115214851744
domContentLoaded13981199190115214851744
domInteractive82341542294129
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2716309302546
firstReactRender37296563949
getState145313321031
initialActions102111
loadScripts13741178187614414611688
setupStore85374911
cc: @HowardBraham
Benchmark value 19 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 156 exceeds gate value 65 for chrome webpack home p95 setupStore
Benchmark value 12 exceeds gate value 11 for firefox browserify home mean getState
Benchmark value 1633 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1399 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1399 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 28 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 1375 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 2040 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1744 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1744 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 1688 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Sum of mean exceeds: 74ms | Sum of p95 exceeds: 423ms
Sum of all benchmark exceeds: 497ms

Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 114 Bytes (0%)
  • common: 0 Bytes (0%)

@jpuri jpuri requested a review from matthewwalsh0 May 8, 2025 09:35
@metamaskbot
Copy link
Collaborator

Builds ready [7f05376]
UI Startup Metrics (1226 ± 74 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1226110014507412601397
load107196012886611041209
domContentLoaded106494212826710991199
domInteractive17134241725
firstPaint794133128940510781196
backgroundConnect84336825
firstReactRender20153942029
getState1457291830
initialActions001000
loadScripts822706101764849959
setupStore85253814
WebpackHomeuiStartup22441811259916423582439
load17401399218212818081901
domContentLoaded17321396217612817971895
domInteractive161160101350
firstPaint194641789177203361
backgroundConnect359268354160
firstReactRender18253357103279349
getState184313311841
initialActions317146
loadScripts17271395217413017951893
setupStore207181182435
FirefoxBrowserifyHomeuiStartup13391133214114214041623
load11971015187713512611449
domContentLoaded11961014187713512611449
domInteractive1044228234115174
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2413382381952
firstReactRender24195992254
getState9419119712
initialActions001001
loadScripts11751002166611912451405
setupStore64273613
WebpackHomeuiStartup14991355180410215431708
load1284115415689213261469
domContentLoaded1284115415689213261469
domInteractive81553012785117
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect22148092333
firstReactRender35294853945
getState105317929
initialActions102111
loadScripts1265113615389213051449
setupStore85455817
cc: @HowardBraham
Benchmark value 1072 exceeds gate value 1070 for chrome browserify home mean load
Benchmark value 1064 exceeds gate value 1061 for chrome browserify home mean domContentLoaded
Benchmark value 1398 exceeds gate value 1365 for chrome browserify home p95 uiStartup
Benchmark value 1209 exceeds gate value 1190 for chrome browserify home p95 load
Benchmark value 1199 exceeds gate value 1180 for chrome browserify home p95 domContentLoaded
Benchmark value 1196 exceeds gate value 1180 for chrome browserify home p95 firstPaint
Benchmark value 26 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 959 exceeds gate value 940 for chrome browserify home p95 loadScripts
Benchmark value 2244 exceeds gate value 2192 for chrome webpack home mean uiStartup
Benchmark value 1740 exceeds gate value 1711 for chrome webpack home mean load
Benchmark value 1733 exceeds gate value 1704 for chrome webpack home mean domContentLoaded
Benchmark value 1728 exceeds gate value 1699 for chrome webpack home mean loadScripts
Benchmark value 362 exceeds gate value 334 for chrome webpack home p95 firstPaint
Sum of mean exceeds: 144ms | Sum of p95 exceeds: 142ms
Sum of all benchmark exceeds: 286ms

Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 114 Bytes (0%)
  • common: 0 Bytes (0%)

@jpuri jpuri changed the title fix: cp-12.18.0 fix repeated re-rendering of approve row in simulations section fix: fix repeated re-rendering of approve row in simulations section May 8, 2025
@jpuri jpuri changed the title fix: fix repeated re-rendering of approve row in simulations section fix: cp-12.18.0 fix repeated re-rendering of approve row in simulations section May 8, 2025
@jpuri jpuri changed the title fix: cp-12.18.0 fix repeated re-rendering of approve row in simulations section fix: cp-12.17.3 fix repeated re-rendering of approve row in simulations section May 8, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [795a6b2]
UI Startup Metrics (1228 ± 60 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1228111114346012671320
load107097212335111011165
domContentLoaded106496012195110971156
domInteractive17142731725
firstPaint72982118242010821128
backgroundConnect84254822
firstReactRender21164452134
getState1664082132
initialActions006101
loadScripts81872996649854893
setupStore85172913
WebpackHomeuiStartup21721627255919323142446
load17071287216817318111982
domContentLoaded16981280216417018071957
domInteractive161152101346
firstPaint1607431748179260
backgroundConnect3993605138170
firstReactRender15553356105267344
getState174278351528
initialActions317135
loadScripts16941278216017018051944
setupStore246274462062
FirefoxBrowserifyHomeuiStartup13941187177711814371640
load12451064162711212991472
domContentLoaded12451064162711212991471
domInteractive1123930736135172
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect21136682038
firstReactRender24197182335
getState85374812
initialActions001001
loadScripts12261051160911312821456
setupStore74375614
WebpackHomeuiStartup16321415222216717081979
load13951227197915814801771
domContentLoaded13941226197915814801771
domInteractive84363364187121
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect23155862431
firstReactRender37315453947
getState13532832932
initialActions002111
loadScripts13741209196615914641747
setupStore11531531812
cc: @HowardBraham
Benchmark value 1071 exceeds gate value 1070 for chrome browserify home mean load
Benchmark value 1064 exceeds gate value 1061 for chrome browserify home mean domContentLoaded
Benchmark value 16 exceeds gate value 15 for chrome browserify home mean getState
Benchmark value 22 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 170 exceeds gate value 90 for chrome webpack home p95 backgroundConnect
Benchmark value 1245 exceeds gate value 1239 for firefox browserify home mean domContentLoaded
Benchmark value 112 exceeds gate value 110 for firefox browserify home mean domInteractive
Benchmark value 1633 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1395 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1395 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 1374 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 1979 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1771 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1771 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 1747 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Sum of mean exceeds: 75ms | Sum of p95 exceeds: 467ms
Sum of all benchmark exceeds: 542ms

Bundle size diffs
  • background: 0 Bytes (0%)
  • ui: 108 Bytes (0%)
  • common: 0 Bytes (0%)

@jpuri jpuri added this pull request to the merge queue May 9, 2025
Merged via the queue into main with commit 4b38599 May 9, 2025
173 checks passed
@jpuri jpuri deleted the approve_row_fix branch May 9, 2025 11:08
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.17.3 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants