fix: oversubscription perps top movers#33150
Conversation
PR template — items to address before "Ready for review"Blocking — these items fail the workflow until fixed:
Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These changes directly affect:
The changes are functional refactors (not purely cosmetic) that could affect subscription lifecycle, rendering behavior, and data display in the Perps movers section. Risk is medium as the logic changes are contained to the Trending/Perps area but involve WebSocket subscription management which could have subtle bugs. Performance Test Selection: |
|
⚡ Performance Test Results
❌ 1 test failed · 2 tests · 1 device 📱 Devices tested (1)Android: Google Pixel 8 Pro (v14.0) ❌ Failed Tests (1)@mm-perps-engineering-team
✅ Passed Tests (1)
Branch: |



Description
Problem
The Now-tab perps movers strip subscribed to live prices for all ~329 markets and, on every ~3s push, rebuilt/re-sorted the full set and re-rendered — just to show the top 12 pills. Since Explore tabs never unmount, this kept running even on other tabs or after leaving Explore.
Why we keep the full-market subscription
Subscribing to only the 12 displayed symbols would break ranking: a market outside the top 12 can move into it, and we'd miss that price change. Correct live re-ordering requires watching every market.
The middle ground
The WebSocket already pushes all markets regardless of subscription — the real cost was the unconditional
setStateand new object identities per tick. The newusePerpsLiveMovershook keeps watching all markets at the ref level (no render per tick) and only commits state when the displayed top-12 actually changes (via asymbol:formattedPercentfingerprint), reusing prior item references so unchanged pills skip re-render. Idle ticks are effectively free.On top of that, the subscription now pauses entirely when not visible: an
ExploreActiveTabContexttellsPerpsBlockwhether the Now tab is active, combined withuseIsFocused()for leaving Explore. The same focus gating is applied to the What's Happening detail view's perps price hook. Disabling freezes the last-known data rather than clearing it, so nothing blanks out and it refreshes immediately on resume.Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist