Skip to content

fix(perps): use native stack navigator to fix navigation jitter on navigation v6 cp-7.73.0 cp-7.74.0#28814

Merged
tommasini merged 22 commits into
mainfrom
fix/perps-home-transition
Apr 17, 2026
Merged

fix(perps): use native stack navigator to fix navigation jitter on navigation v6 cp-7.73.0 cp-7.74.0#28814
tommasini merged 22 commits into
mainfrom
fix/perps-home-transition

Conversation

@tommasini
Copy link
Copy Markdown
Contributor

@tommasini tommasini commented Apr 14, 2026


Description

React Navigation v6's JS-based @react-navigation/stack creates Reanimated shared values during render before the Fabric commit is finalized. Under the New Architecture (newArchEnabled=true, RN 0.76.9), this causes animations to fall back to the JS thread, producing a freeze-then-snap jitter when navigating into the Perps stack.

The fix replaces createStackNavigator with createNativeStackNavigator (from @react-navigation/native-stack@^6) for PerpsScreenStack. Native stack transitions run as pure UIKit (iOS) / Fragment (Android) animations with zero Reanimated/JS-thread involvement, eliminating the timing issue entirely.

Concretely:

  • Added @react-navigation/native-stack@^6 as a dependency (compatible with the existing react-native-screens@3.37.0)
  • Replaced createStackNavigatorcreateNativeStackNavigator for the inner Perps navigator in routes/index.tsx
  • Updated screen option syntax for the two transparent-modal screens: cardStylecontentStyle, animationEnabled: falseanimation: 'none', and replaced JS-stack-only header/headerLeft callbacks with headerShown/headerBackVisible
  • Updated the Perps ROOT entry in MainNavigator.js to use TransitionPresets.SlideFromRightIOS, replacing the hand-rolled cardStyleInterpolator that used Animated.Value.interpolate with layouts.screen.width (which can be 0 on first render under Fabric's async layout)

Changelog

CHANGELOG entry: Fixed jittery navigation transitions when opening Perps on devices running the New Architecture

Related issues

Fixes:

Manual testing steps

Feature: Perps navigation transition

  Scenario: User navigates to Perps from wallet home
    Given the user is on the Wallet home screen with the Perps tab visible
    And the device is running the New Architecture (newArchEnabled=true)

    When the user taps "New Trade" or any button that navigates to Perps
    Then the screen transitions immediately with a smooth slide-from-right animation
    And no freeze-then-snap jitter occurs during the transition
    And the Perps home screen content appears correctly after the transition

  Scenario: User navigates between Perps screens
    Given the user is on the Perps home screen

    When the user taps on a market to open market details
    Then the transition to the market details screen is smooth and immediate
    And navigating back to Perps home is also smooth

Screenshots/Recordings

Before

N/A

After

Screen.Recording.2026-04-17.at.03.06.54.mov
Screen.Recording.2026-04-17.at.03.10.02.mov

Pre-merge author checklist

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.

Made with Cursor


Note

Medium Risk
Changes navigation primitives and header behavior for the Perps flow, which can affect transitions, modal presentation, and confirmation screen UX if options are mis-mapped between stack implementations.

Overview
Fixes Perps navigation jitter under React Navigation v6 / RN New Architecture by switching the Perps inner navigator from JS @react-navigation/stack to @react-navigation/native-stack.

Updates Perps screen options to native-stack equivalents (contentStyle, animation: 'none', presentation: 'transparentModal') and adds a scoped NavigationContext override in PerpsConfirmScreen to prevent Confirm from re-enabling a header when showPerpsHeader is false. Also ensures the Perps root entry in MainNavigator explicitly disables the header.

Bumps mobile build numbers (versionCode / CURRENT_PROJECT_VERSION) and Bitrise VERSION_NUMBER to 4532, and adds the @react-navigation/native-stack dependency.

Reviewed by Cursor Bugbot for commit c92d05c. Bugbot is set up for automated code reviews on this repo. Configure here.

@tommasini tommasini self-assigned this Apr 14, 2026
@github-actions
Copy link
Copy Markdown
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.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 14, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​react-navigation/​native-stack@​6.11.010010075100100

View full report

@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Apr 14, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Apr 14, 2026
@tommasini tommasini changed the title fix(perps): use native stack navigator to fix navigation jitter on New Architecture fix(perps): use native stack navigator to fix navigation jitter on navigation v6 Apr 14, 2026
@tommasini tommasini marked this pull request as ready for review April 14, 2026 17:56
@tommasini tommasini requested a review from a team as a code owner April 14, 2026 17:56
Comment thread app/components/UI/Perps/routes/index.tsx
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 14, 2026
@tommasini tommasini changed the title fix(perps): use native stack navigator to fix navigation jitter on navigation v6 fix(perps): use native stack navigator to fix navigation jitter on navigation v6 cp-7.73.0 Apr 14, 2026
@tommasini tommasini added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Apr 14, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 14, 2026
@Cal-L Cal-L enabled auto-merge April 15, 2026 01:04
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Apr 15, 2026
Comment thread app/components/UI/Perps/Views/PerpsTPSLView/PerpsTPSLView.tsx Outdated
@github-actions github-actions Bot removed the size-S label Apr 15, 2026
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 16, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Apr 16, 2026
@metamaskbotv2 metamaskbotv2 Bot requested a review from a team as a code owner April 16, 2026 23:25
@tommasini tommasini marked this pull request as draft April 17, 2026 00:12
auto-merge was automatically disabled April 17, 2026 00:12

Pull request was converted to draft

@tommasini tommasini marked this pull request as ready for review April 17, 2026 02:09
@github-actions github-actions Bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk and removed size-S risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations, SmokeTrade
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The primary changes in this PR are:

  1. Perps navigation stack migration (app/components/UI/Perps/routes/index.tsx): The Perps feature was migrated from createStackNavigator (JS-based) to createNativeStackNavigator (native). This is a significant navigation architecture change that affects all Perps screens. Navigation option properties were updated (cardStyle→contentStyle, animationEnabled→animation, detachPreviousScreen removed, etc.). A NavigationContext override was added to intercept setOptions calls and prevent header animation issues in the confirmation flow.

  2. PayWithModal added to Perps stack (app/components/UI/Perps/routes/index.tsx): The PayWithModal (a confirmations component) is now registered as a screen within the Perps native stack. This is needed because transparent modal screens can't dispatch navigation actions to the parent App stack. This directly ties Perps navigation to the confirmations flow.

  3. MainNavigator change (app/components/Nav/Main/MainNavigator.js): Added headerShown: false to the Perps root screen options to prevent double headers with the new native stack.

  4. New dependency (package.json/yarn.lock): @react-navigation/native-stack added as a new package dependency.

  5. Version bumps (android/app/build.gradle, ios/MetaMask.xcodeproj/project.pbxproj, bitrise.yml): Routine version code bumps (4138→4532), no functional impact.

Tag selection rationale:

  • SmokePerps: Direct impact - entire Perps navigation stack refactored from JS to native stack. All Perps flows (add funds, positions, stop-loss, limit orders, tutorials) need validation.
  • SmokeWalletPlatform: Required per SmokePerps tag description (Perps is a section inside Trending tab). Also, the MainNavigator change could affect how Perps integrates with the main navigation.
  • SmokeConfirmations: Required per SmokePerps tag description (Add Funds deposits are on-chain transactions). Additionally, PayWithModal (a confirmations component) is now embedded in the Perps native stack with a NavigationContext override - this non-trivial pattern needs validation to ensure confirmations still work correctly within the Perps flow.
  • SmokeTrade: The TradeWalletActions menu is the primary entry point to Perps. Navigation changes at the Perps root level could affect how users navigate from Trade into Perps.

Performance Test Selection:
The migration from createStackNavigator (JS-based) to createNativeStackNavigator (native) for the Perps stack is a performance-relevant change. Native stack navigators generally have better performance characteristics, but the migration could affect screen transition timing, rendering performance, and the Perps add funds flow. @PerformancePreps covers perps market loading, position management, add funds flow, and order execution - all of which go through the refactored navigation stack.

View GitHub Actions results

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 89b2e6e. Configure here.

Comment thread app/components/UI/Perps/routes/index.tsx
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
6.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
10 value mismatches detected (expected — fixture represents an existing user).
View details

@chloeYue chloeYue changed the title fix(perps): use native stack navigator to fix navigation jitter on navigation v6 cp-7.73.0 fix(perps): use native stack navigator to fix navigation jitter on navigation v6 cp-7.73.0 cp-7.74.0 Apr 17, 2026
Copy link
Copy Markdown
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Apr 17, 2026
@tommasini tommasini added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit cf10d95 Apr 17, 2026
120 of 121 checks passed
@tommasini tommasini deleted the fix/perps-home-transition branch April 17, 2026 08:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.75.0 Issue or pull request that will be included in release 7.75.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants