Skip to content

Conversation

@darkwing
Copy link
Contributor

@darkwing darkwing commented Jul 1, 2025

Description

Open in GitHub Codespaces

Polling by background controllers should be disabled when the Extension UI is closed to minimize network traffic and resource usage/battery drain.

However, the logic for preventing polling calls was never implemented for the recently introduced DeFiPositionsController, resulting in regular fetch calls to http://defiadapters.api.cx.metamask.io/ being sent out while the UI is closed. The associated read/writes to IndexedDB may contribute to a memory leak issue that has been identified as a release blocker.

This commit resolves the above issue, and also updates relevant types to include the controller.

Related issues

Manual testing steps

  1. Go to this page... 2.

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.

Description

Open in GitHub Codespaces

Related issues

Fixes:

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.

#33921)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/33921?quickstart=1)

Polling by background controllers should be disabled when the Extension
UI is closed to minimize network traffic and resource usage/battery
drain.

However, the logic for preventing polling calls was never implemented
for the recently introduced `DeFiPositionsController`, resulting in
regular fetch calls to `http://defiadapters.api.cx.metamask.io/` being
sent out while the UI is closed. The associated read/writes to
`IndexedDB` may contribute to a memory leak issue that has been
identified as a release blocker.

This commit resolves the above issue, and also updates relevant types to
include the controller.

## **Related issues**

- Contributes to fixing
#33719
- Contributes to fixing
#33466

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.
@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 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 metamaskbot added the team-core-extension-ux Core Extension UX team label Jul 1, 2025
cursor[bot]

This comment was marked as outdated.

@HowardBraham
Copy link
Contributor

Oops, already merged in #34010

@HowardBraham HowardBraham deleted the Version-v12.22.0-cp-defi-polling branch July 1, 2025 17:28
@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [05edfc8]
UI Startup Metrics (1189 ± 61 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1189106113686112311299
load101891011615710641102
domContentLoaded101190511385610591092
domInteractive18136391642
firstPaint671128114540710481099
backgroundConnect84263815
firstReactRender23165362440
getState1563482230
initialActions001001
loadScripts80670292955855885
setupStore95254919
WebpackHomeuiStartup23291733280723224662726
load17341303215619518692094
domContentLoaded17271298215219318642082
domInteractive181369131558
firstPaint1696558779185327
backgroundConnect261070113150
firstReactRender25992439117381415
getState185118172146
initialActions318147
loadScripts17241297215019218542070
setupStore3373235925189
FirefoxBrowserifyHomeuiStartup13851207190712114731632
load1208107014128712751366
domContentLoaded1208107014118712741365
domInteractive1173447065130289
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2714120192781
firstReactRender25215452531
getState144182211038
initialActions001001
loadScripts1186101913878612531342
setupStore12419026950
WebpackHomeuiStartup16241403251219917192047
load13881202190915214771774
domContentLoaded13881202190915214761774
domInteractive97335196392272
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3015244372648
firstReactRender42325244448
getState156208251132
initialActions002111
loadScripts13671179188615114571747
setupStore1159712929
Benchmark value 42 exceeds gate value 41 for chrome browserify home p95 domInteractive
Benchmark value 19 exceeds gate value 17 for chrome browserify home p95 setupStore
Benchmark value 2329 exceeds gate value 2192 for chrome webpack home mean uiStartup
Benchmark value 1735 exceeds gate value 1711 for chrome webpack home mean load
Benchmark value 1728 exceeds gate value 1704 for chrome webpack home mean domContentLoaded
Benchmark value 260 exceeds gate value 235 for chrome webpack home mean firstReactRender
Benchmark value 1725 exceeds gate value 1699 for chrome webpack home mean loadScripts
Benchmark value 34 exceeds gate value 32 for chrome webpack home mean setupStore
Benchmark value 2727 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Benchmark value 2094 exceeds gate value 2030 for chrome webpack home p95 load
Benchmark value 2082 exceeds gate value 2005 for chrome webpack home p95 domContentLoaded
Benchmark value 59 exceeds gate value 57 for chrome webpack home p95 domInteractive
Benchmark value 415 exceeds gate value 370 for chrome webpack home p95 firstReactRender
Benchmark value 2071 exceeds gate value 1970 for chrome webpack home p95 loadScripts
Benchmark value 189 exceeds gate value 65 for chrome webpack home p95 setupStore
Benchmark value 118 exceeds gate value 110 for firefox browserify home mean domInteractive
Benchmark value 27 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 14 exceeds gate value 11 for firefox browserify home mean getState
Benchmark value 13 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 289 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 81 exceeds gate value 70 for firefox browserify home p95 backgroundConnect
Benchmark value 38 exceeds gate value 24 for firefox browserify home p95 getState
Benchmark value 50 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 1624 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1389 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1388 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 31 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 42 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 16 exceeds gate value 15 for firefox webpack home mean getState
Benchmark value 1368 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 2047 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1774 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1774 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 272 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 1747 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Benchmark value 29 exceeds gate value 28 for firefox webpack home p95 setupStore
Sum of mean exceeds: 299ms | Sum of p95 exceeds: 1405ms
Sum of all benchmark exceeds: 1704ms

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team-core-extension-ux Core Extension UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants