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

perf: search transition smoother on slower devices #31354

Conversation

hurali97
Copy link
Contributor

@hurali97 hurali97 commented Nov 15, 2023

Details

When user navigates back from Search Sidebar there’s a noticeable delay and lag in closing the Search Sidebar. It mainly arises from withNavigationFocus HOC as it re-renders the BaseOptionSelector tree including OptionsList . Adding a memo to OptionsList doesn’t help as it’s parent gets re-rendered due to the withNavigationFocus HOC.
Also, we notice that due to isFocused state value in ActionItemView the ReportActionsList re-renders which also adds the overhead to the rendering cycle as it recreates the instances of recordTimeToMeasureItemLayout and loadOlderChats which are passed as props to ReportActionsList .

We can remove the withNavigationFocus HOC and add navigation listeners(focus, blur) in BaseOptionSelector and memoize OptionsList to not re-render when state is set in it’s parent. We can avoid recreating instances of recordTimeToMeasureItemLayout and loadOlderChats by wrapping them in useCallbacks and memoizing ReportActionsList .

Before on 6x CPU throttle:
recording-before.mov

profile-ranked-before

profiler-ranked-before

profile-timeline-before

profiler-ranked-after
After on 6x CPU throttle:
Screen.Recording.2023-11-16.at.12.43.10.PM.mov

profile-ranked-after

profiler-ranked-after

profile-timeline-after

profiler-timeline-after

Fixed Issues

$ #33596
PROPOSAL: https://expensify.slack.com/archives/C05LX9D6E07/p1699514971219659

Tests

Manual Test:

  • Click on Search Icon and Search Sidebar should appear quickly

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android-recording.mov
Android: mWeb Chrome
android-web-recording.mov
iOS: Native
ios-recording.mov
iOS: mWeb Safari
ios-web-recording.mov
MacOS: Chrome / Safari
web-recording.mov
MacOS: Desktop
desktop-recording.mov

@hurali97 hurali97 marked this pull request as ready for review November 16, 2023 07:45
@hurali97 hurali97 requested a review from a team as a code owner November 16, 2023 07:45
@melvin-bot melvin-bot bot removed the request for review from a team November 16, 2023 07:45
Copy link

melvin-bot bot commented Nov 16, 2023

@Gonals Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot requested a review from Gonals November 16, 2023 07:45
@situchan
Copy link
Contributor

I can help if requires C+ review

@Gonals
Copy link
Contributor

Gonals commented Nov 20, 2023

Seems like we have a number of conflicts here 😁

@situchan
Copy link
Contributor

I think @hurali97 is OOO this week. Maybe move this PR forward next week.

… perf/search-transition-smoother-on-slower-devices
@hurali97
Copy link
Contributor Author

@situchan conflicts resolved 👍

@Gonals
Copy link
Contributor

Gonals commented Nov 27, 2023

@situchan conflicts resolved 👍

I still see some

@hurali97
Copy link
Contributor Author

@situchan conflicts resolved 👍

I still see some

Yeah it might be that when I fixed the previous, some latest changes were merged outside my working hours. I will resolve those as well.

@hurali97
Copy link
Contributor Author

@Gonals conflicts resolved !!

@hurali97
Copy link
Contributor Author

@situchan Are you able to review the PR? 🙂

@situchan
Copy link
Contributor

yes reviewing today

… perf/search-transition-smoother-on-slower-devices
… perf/search-transition-smoother-on-slower-devices
@hurali97
Copy link
Contributor Author

hurali97 commented Dec 1, 2023

@situchan any updates on the review 🙂

@situchan
Copy link
Contributor

situchan commented Dec 1, 2023

reviewing now

src/pages/home/sidebar/SidebarLinks.js Outdated Show resolved Hide resolved
src/pages/SearchPage.js Outdated Show resolved Hide resolved
@hurali97
Copy link
Contributor Author

Coming from here. Waiting on to fix Reassure Tests.

In the mean time, I will keep resolving conflicts so that we don't have huge conflicts at the end, when Reassure tests are fixed and we are following up again on this PR. Thanks.

… perf/search-transition-smoother-on-slower-devices
@hurali97
Copy link
Contributor Author

hurali97 commented Jan 8, 2024

The reassure tests failure is expected as we have moved the following piece of code from being executed in constructor to execute once the transition animations are finished. Which results in a state update but providing a better user experience.

Screenshot 2024-01-08 at 4 12 27 PM

mountiny
mountiny previously approved these changes Jan 9, 2024
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Thanks! @Gonals Could you please review this one soon? thanks!

@@ -497,4 +497,4 @@ ReportActionsList.propTypes = propTypes;
ReportActionsList.defaultProps = defaultProps;
ReportActionsList.displayName = 'ReportActionsList';

export default compose(withWindowDimensions, withPersonalDetails(), withCurrentUserPersonalDetails)(ReportActionsList);
export default compose(withWindowDimensions, withPersonalDetails(), withCurrentUserPersonalDetails)(memo(ReportActionsList));
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this change related to the rest of the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This goes hand in hand with the following:

we notice that due to isFocused state value in ActionItemView the ReportActionsList re-renders which also adds the overhead to the rendering cycle as it recreates the instances of recordTimeToMeasureItemLayout and loadOlderChats which are passed as props to ReportActionsList

… perf/search-transition-smoother-on-slower-devices
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Thanks!

@Gonals Gonals merged commit 96a8617 into Expensify:main Jan 9, 2024
17 of 18 checks passed
@melvin-bot melvin-bot bot added the Emergency label Jan 9, 2024
Copy link

melvin-bot bot commented Jan 9, 2024

@Gonals looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@Gonals Gonals removed the Emergency label Jan 9, 2024
@Gonals
Copy link
Contributor

Gonals commented Jan 9, 2024

As discussed in the PR, Performance tests failing here are not an emergency

@OSBotify
Copy link
Contributor

OSBotify commented Jan 9, 2024

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.24-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

mountiny added a commit that referenced this pull request Jan 10, 2024
…n-smoother-on-slower-devices"

This reverts commit 96a8617, reversing
changes made to a144af4.
@flodnv flodnv mentioned this pull request Jan 10, 2024
6 tasks
mountiny added a commit that referenced this pull request Jan 10, 2024
[CP Staging] Revert "Merge pull request #31354 from hurali97/perf/search-transitio…
OSBotify pushed a commit that referenced this pull request Jan 10, 2024
[CP Staging] Revert "Merge pull request #31354 from hurali97/perf/search-transitio…

(cherry picked from commit 0ffca02)
@mountiny
Copy link
Contributor

This was reverted as bunch of regressions have been found not related to the search page

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.24-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Gonals in version: 1.4.24-4 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 cancelled 🔪
🕸 web 🕸 success ✅

@hurali97 hurali97 mentioned this pull request Jan 12, 2024
50 tasks
@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.4.24-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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

Successfully merging this pull request may close these issues.

6 participants