-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: Prevent DeFiPositionsController from polling while UI is closed (#33921)
#34011
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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? --> [](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.
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. |
Contributor
|
Oops, already merged in #34010 |
Collaborator
Builds ready [05edfc8]
UI Startup Metrics (1189 ± 61 ms)
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
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 tohttp://defiadapters.api.cx.metamask.io/being sent out while the UI is closed. The associated read/writes toIndexedDBmay 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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Standards.
Pre-merge reviewer checklist
Description
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist