chore(runway): cherry-pick fix(perps): remove loading delay from tutorial screen#21144
Merged
Merged
Conversation
…rial screen (#20918) ## **Description** Perps tutorial was taking >5 seconds to load due to being wrapped in `PerpsConnectionProvider`, which blocks rendering until WebSocket connection completes. **Solution:** Moved Tutorial to app-level navigation (outside provider) while keeping all connected screens inside. Connection now initializes in background during tutorial, eliminating the loading delay. ## **Changelog** CHANGELOG entry: Fixed Perps tutorial taking over 5 seconds to load ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1840 ## **Manual testing steps** ```gherkin Feature: Perps Tutorial Loading Performance Scenario: First-time user navigates to tutorial Given user is a first-time Perps user When user taps "Trade" button from wallet actions Then tutorial displays instantly without "Connecting to perps" screen And WebSocket connection initializes in background Scenario: Tutorial to Markets navigation Given user is viewing tutorial When user completes or skips tutorial Then user navigates to Markets view And Markets loads with active WebSocket connection Scenario: Deeplink to tutorial for first-time user Given user is a first-time Perps user When user opens perps deeplink Then tutorial displays instantly ``` ## **Screenshots/Recordings** ### **Before** - Tutorial showed "Connecting to perps" loading screen for 5+ seconds ### **After** - Tutorial displays instantly - Connection establishes in background during tutorial (no loader ever displayed since now connected when reaching marketlist screen) https://github.com/user-attachments/assets/78c2f507-e9bc-4ee7-a51b-62b3955474c2 ## **Pre-merge author checklist** - [x] 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). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] 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. ## **Technical Details** **Files changed:** - `MainNavigator.js`: Added Tutorial as sibling to PERPS.ROOT - `routes/index.tsx`: Removed Tutorial from PerpsScreenStack - `PerpsTutorialCarousel.tsx`: Added background connection initialization - Navigation updates: `handlePerpsUrl.ts`, `WalletActions.tsx`, `TradeWalletActions.tsx`, `PerpsGTMModal.tsx`, `WaysToEarn.tsx`, `PerpsTabView.tsx` **Navigation patterns:** - Tutorial: Direct `navigate(Routes.PERPS.TUTORIAL)` (app level) - Markets/other: Nested `navigate(Routes.PERPS.ROOT, { screen: Routes.PERPS.MARKETS })` (inside provider) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Moves Perps tutorial to app-level navigation and initializes the perps connection in the background; updates all navigation calls and related tests. > > - **Navigation**: > - Move `Routes.PERPS.TUTORIAL` out of `PerpsScreenStack` into `MainNavigator` and remove it from `UI/Perps/routes`. > - Update callers to navigate directly to `Routes.PERPS.TUTORIAL` (first-time users) and keep nested `Routes.PERPS.ROOT` for markets/others: > - `PerpsTabView`, `WalletActions`, `TradeWalletActions`, `Rewards/WaysToEarn`, `PerpsGTMModal`, `handlePerpsUrl`. > - **Tutorial**: > - `PerpsTutorialCarousel`: start background connection via `PerpsConnectionManager.connect()` with debug logging; minor view cleanup. > - Export `PerpsTutorialCarousel` from `UI/Perps/index` for app-level use. > - **Tests**: > - Adjust expectations to direct `navigate(Routes.PERPS.TUTORIAL)` across updated specs (PerpsTabView, GTM modal, Rewards WaysToEarn, WalletActions, deeplink handler). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6aade3b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Nicholas Smith <nick.smith@consensys.net>
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. |
Matt561
approved these changes
Oct 14, 2025
|
Collaborator
|
No release label on PR. Adding release label release-7.57.0 on PR, as PR was cherry-picked in branch 7.57.0. |
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
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
Perps tutorial was taking >5 seconds to load due to being wrapped in
PerpsConnectionProvider, which blocks rendering until WebSocketconnection completes.
Solution: Moved Tutorial to app-level navigation (outside provider)
while keeping all connected screens inside. Connection now initializes
in background during tutorial, eliminating the loading delay.
Changelog
CHANGELOG entry: Fixed Perps tutorial taking over 5 seconds to load
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1840
Manual testing steps
Screenshots/Recordings
Before
After
displayed since now connected when reaching marketlist screen)
Screen.Recording.2025-10-08.at.1.28.05.PM.mov
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Technical Details
Files changed:
MainNavigator.js: Added Tutorial as sibling to PERPS.ROOTroutes/index.tsx: Removed Tutorial from PerpsScreenStackPerpsTutorialCarousel.tsx: Added background connectioninitialization
handlePerpsUrl.ts,WalletActions.tsx,TradeWalletActions.tsx,PerpsGTMModal.tsx,WaysToEarn.tsx,PerpsTabView.tsxNavigation patterns:
navigate(Routes.PERPS.TUTORIAL)(app level)navigate(Routes.PERPS.ROOT, { screen: Routes.PERPS.MARKETS })(inside provider)Note
Moves Perps tutorial to app-level route, initializes connection in the background, and updates navigation/deeplinks to target the tutorial directly.
Routes.PERPS.TUTORIALout ofPerpsScreenStackto app-levelMainNavigator; remove tutorial screen fromUI/Perps/routes.navigate(Routes.PERPS.TUTORIAL)for first-time users; keep markets undernavigate(Routes.PERPS.ROOT, { screen: Routes.PERPS.MARKETS }).PerpsTutorialCarouselfromUI/Perps/index.PerpsTutorialCarousel: start background connection viaPerpsConnectionManager.connect()and log viaDevLogger; minor layout fixes (remove extra fragment, correct keys).PerpsTabView,WalletActions,TradeWalletActions,WaysToEarn, andPerpsGTMModalto targetRoutes.PERPS.TUTORIALdirectly (with params where needed).Routes.PERPS.TUTORIAL; maintain markets/tabs/asset routing for returning users.Written by Cursor Bugbot for commit 1235514. This will update automatically on new commits. Configure here.
Co-authored-by: Nicholas Smith nick.smith@consensys.net 3d3f00e