MetaMask / MetaMask/metamask-extension
[State Sync Redesign] Epic 1: Transport optimization
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
Optimize the background-to-UI state delivery transport: remove dead code, eliminate 200ms debounce, add frame-aligned batching. Introduces per-controller transport subscriptions as a new path alongside the existing memStore.subscribe(sendUpdate) (dual-write); Epic 2 later extends per-controller subscriptions to all consumers and removes memStore. No downstream migration (no selector, component, or test changes). Each issue is independently shippable.
Key Benefits
- UI latency 200ms to 17ms: microtask batching +
requestAnimationFramereplaces background debounce - Remove
publicConfigStore, dead EventEmitter events; repurposePatchStoreasPatchBuffer(keyed-patch accumulator for microtask batching) - Controller keys preserved in transport: enables Epics 2 and 3
ADR Option
A1 (transport optimization)
Phase
A1 (background cleanup)
Dependencies
None
Enables
- Epic 2 (background cleanup) — within A1
- Epic 3 (UI-controller subscriptions) — A2 phase, after A1 complete
Prior art
#29600 Phase 1 (controller-keyed hydration) is reusable.
Issues
- 1.1: Remove
publicConfigStore— #40034 - 1.2: Delete dead EventEmitter events — #40035
- 1.3: Per-controller transport subscriptions (dual-write), remove debounce, add
requestAnimationFramebatching, repurposePatchStoreasPatchBuffer— #40036 - 1.4: Send keyed initial state on
START_UI_SYNC— #40037 - 1.5: Add port disconnect detection for UI contexts — #40177
- 1.6: UI reconnect logic after port disconnect — #40178
Validation criteria
-
publicConfigStoreremoved, dapp connectivity unaffected (1.1) - Latency improvement measurable in React DevTools profiler (1.3)
- E2E tests pass with
requestAnimationFramebatching (1.3) - Controller keys visible in transport (debug logging) (1.3)
- Keyed initial state available on
startUISync(1.4) - Port disconnect detected and surfaced to user (1.5)
- Long-lived UI contexts reconnect and rehydrate after service worker restart (1.6)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the transport work described in subissue #40036 and the prior art in #29600; this epic does not name implementation files or tests. Confirm completion against the listed validation criteria: measurable latency improvement, passing E2E tests with requestAnimationFrame batching, and preserved controller keys in transport.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100