-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
chore: Batch bg state updates in Engine service (#15189) #15416
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
base: main
Are you sure you want to change the base?
Conversation
<!-- 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? --> ## **Related issues** Fixes: ## **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 Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/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.
CLA Signature Action: Thank you for your submission, we really appreciate it. We ask that you all read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:
By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to this repository. 1 out of 2 committers have signed the CLA. |
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15416 +/- ##
==========================================
- Coverage 68.92% 68.89% -0.03%
==========================================
Files 2394 2394
Lines 51403 51432 +29
Branches 7720 7727 +7
==========================================
+ Hits 35430 35435 +5
- Misses 13702 13726 +24
Partials 2271 2271 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
Description
Changes are from Stas from Margelo from the original PR here - #15189
Some information describing the changes #15189 (comment)
unstable_batchedUpdates
- state updates triggered outside of React event handlers - such as within a setTimeout callback (debounce uses setTimeout under the hood) - are not automatically batched, so each dispatch would normally trigger its own rerender, so usage of unstable_batchedUpdates ensures that multiple redux actions flush result in a single render passsetTimeout
vsdebounce
- it was already mentioned in perf: Debounce and group state updates being flushed to Redux #14927 (comment) that if events keep coming in faster than the delay (constant background updates), a debounced flush may never occur, and that results in no UI updates. The setTimeout approach ensured a flush at least once per interval. Additionally, the setTimeout approach avoids pulling in an external dependency.also this pr introduces fewer changes, and the Batcher class might be reused in other places to batch updates
Related issues
Fixes: #15028 #15560
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