Skip to content
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

Swaps performance improvements, logic fixes #6050

Merged
merged 24 commits into from
Aug 30, 2024

Conversation

christianbaroni
Copy link
Member

@christianbaroni christianbaroni commented Aug 27, 2024

Fixes APP-1766

What changed (plus any additional context for devs)

  • Improves performance throughout swaps (see commit history for details)
  • Main improvements:
    • Optimizes useAnimatedReaction updates — previously there were lots of unnecessary updates due to no dependency array being passed (now passing an empty array in most cases, which limits reactions to changes in the prepare function values)
    • Migrates the token lists from FlashList to FlatList, which seems overall more performant
    • Cleans up the swap confirm button logic to reduce jank

Screen recordings / screenshots

What to test

Without a dependency array, useAnimatedReaction reacts to changes in any value used throughout the useAnimatedReaction, whereas an empty dependency array limits reactions to changes in values used in the prepare function.
The row containing the switch already gets hidden when Flashbots is disabled
This is an alternative to runOnUI that allows bypassing reanimated's internal update batching and the accompanying possibility of a delay before code gets executed on the UI thread
It's already set to undefined any time the gas fee is recalculated in SyncGasStateToSharedValues
FlatList seems to be more performant overall, and far fewer instances of blank list cells
Some unnecessary updates were getting through with the current !== previous check
Certain escape characters like "\" previously triggered a crash if entered into the input asset search
Copy link

linear bot commented Aug 28, 2024

This reverts commit 436e792.

# Conflicts:
#	src/__swaps__/screens/Swap/components/TokenList/TokenToBuyList.tsx
@brunobar79 brunobar79 requested review from benisgold and removed request for greg-schrammel August 28, 2024 17:20
@jinchung jinchung removed their request for review August 28, 2024 17:21
Copy link
Contributor

@walmat walmat left a comment

Choose a reason for hiding this comment

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

tested android and ios no regressions and seems to be the same or maybe slightly faster on both. Good work! Couple questions mostly for clarity.

@christianbaroni christianbaroni merged commit 12abd5e into develop Aug 30, 2024
5 checks passed
@christianbaroni christianbaroni deleted the @christian/swaps-improvements branch August 30, 2024 18:30
Copy link

sentry-io bot commented Sep 8, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ React ErrorBoundary TypeError: Cannot convert undefined value to object anonymous(src/__swaps__/screens/Swap/hooks/useS... View Issue
  • ‼️ React ErrorBoundary TypeError: Cannot convert undefined value to object anonymous(src/__swaps__/screens/Swap/hooks/useS... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants