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

[HOLD for payment 2024-06-13] [LOW] [Performance] Improve AppNavigator Performance #42744

Closed
mountiny opened this issue May 29, 2024 · 15 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@mountiny
Copy link
Contributor

mountiny commented May 29, 2024

Coming from here. @rezkiy37

Problem

There is a core component of the app - AppNavigator. Basically, it renders AuthScreens or PublicScreens based on a prop - authenticated. Currently, the component takes around 250ms to render. Also, it re-renders several times.

  1. The component uses require to import children. I have a concern regarding this approach. Because require is a function in Node.js for importing modules. It’s synchronous and will halt execution until the module is loaded. It’s not typically used in the front-end code of a React application, as it doesn’t support code splitting or lazy loading. require might be used in certain scenarios, such as server-side rendering or when working with Node.js back-end code.
  2. The component re-render several times, because the parent component re-renders. However, the property is not changed. Also, PublicScreens re-renders 3 times.

Solution

I propose to decrease the render duration and avoid redundant re-renders.

  1. React.lazy is a function that lets you render a dynamic import as a regular component. It makes it easy to code split a React application and lazily load components as they are needed, which can significantly improve the load time of your application. The idea is still the same as with require, but it takes much less time around 17ms for AppNavigator and Suspense together. The time 1. savings is great. Also it is a common practice for React apps.
    Wrap the component in React.memo to get a memoized version of that component. And, as a result, AppNavigator renders once and does not re-render anymore until the user logins/logouts (authenticated changed). PublicScreens renders once as well.

There is a commit here. I am attaching screenshots with the legacy (the 1st) and updated (the 2nd) versions.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ec3bf0fc8d2fa2f1
  • Upwork Job ID: 1795785815695171584
  • Last Price Increase: 2024-05-29
Issue OwnerCurrent Issue Owner: @alexpensify
@mountiny mountiny added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 29, 2024
Copy link

melvin-bot bot commented May 29, 2024

Triggered auto assignment to @alexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@rezkiy37
Copy link
Contributor

Hi, I’m Michael (Mykhailo) from Callstack and I would like to work on this issue.

@Julesssss
Copy link
Contributor

Hey @rezkiy37, great work so far

@Julesssss Julesssss added the External Added to denote the issue can be worked on by a contributor label May 29, 2024
Copy link

melvin-bot bot commented May 29, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01ec3bf0fc8d2fa2f1

@melvin-bot melvin-bot bot changed the title [LOW] [Performance] Improve AppNavigator Performance [$250] [LOW] [Performance] Improve AppNavigator Performance May 29, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 29, 2024
Copy link

melvin-bot bot commented May 29, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @c3024 (External)

@Julesssss Julesssss changed the title [$250] [LOW] [Performance] Improve AppNavigator Performance [LOW] [Performance] Improve AppNavigator Performance May 29, 2024
@rezkiy37
Copy link
Contributor

Measuring on IOS and Android Production-Release builds.

@melvin-bot melvin-bot bot added the Overdue label May 31, 2024
@c3024
Copy link
Contributor

c3024 commented Jun 1, 2024

Working on it. Not overdue.

@melvin-bot melvin-bot bot removed the Overdue label Jun 1, 2024
@Julesssss
Copy link
Contributor

PR is in draft, I'll generate testable builds soon

@melvin-bot melvin-bot bot added Overdue Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Overdue labels Jun 3, 2024
@mountiny mountiny self-assigned this Jun 3, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 6, 2024
@melvin-bot melvin-bot bot changed the title [LOW] [Performance] Improve AppNavigator Performance [HOLD for payment 2024-06-13] [LOW] [Performance] Improve AppNavigator Performance Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.79-11 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-06-13. 🎊

For reference, here are some details about the assignees on this issue:

  • @rezkiy37 does not require payment (Contractor)
  • @c3024 requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jun 6, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@c3024] The PR that introduced the bug has been identified. Link to the PR:
  • [@c3024] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@c3024] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@c3024] Determine if we should create a regression test for this bug.
  • [@c3024] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@alexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 12, 2024
@alexpensify
Copy link
Contributor

To prepare for the payment date, @c3024 please accept the invite here: https://www.upwork.com/jobs/~01ec3bf0fc8d2fa2f1. Tomorrow, I'll complete the payment process in Upwork. Thanks!

@c3024
Copy link
Contributor

c3024 commented Jun 13, 2024

@alexpensify Thanks, accepted the invite.

Copy link

melvin-bot bot commented Jun 13, 2024

Payment Summary

Upwork Job

  • Contributor: @rezkiy37 is from an agency-contributor and not due payment
  • ROLE: @c3024 paid $(AMOUNT) via Upwork (LINK)

BugZero Checklist (@alexpensify)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1795785815695171584/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@alexpensify
Copy link
Contributor

Payouts due: 2024-06-13

  • Contributor: $250 @rezkiy37 - is from an agency-contributor and not due payment
  • Contributor+: $250 @c3024 - Paid via Upwork!

Upwork job is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Development

No branches or pull requests

5 participants