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-07-22] LOW: Enable Concurrent React Features #33531

Closed
roryabraham opened this issue Dec 23, 2023 · 71 comments
Closed

[HOLD for payment 2024-07-22] LOW: Enable Concurrent React Features #33531

roryabraham opened this issue Dec 23, 2023 · 71 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production NewFeature Something to build that is a new item. Reviewing Has a PR in review Weekly KSv2

Comments

@roryabraham
Copy link
Contributor

roryabraham commented Dec 23, 2023

Problem

There are a number of performance issues that we have long-term aspirations to solve via the React concurrency features introduced in React 18+. This was a big portion of the motivation to enable the new React Native architecture.

While we are still working on the New Arch on iOS and Android, we already have the ability to enable React concurrent mode on web. However, during the RNW 0.19 upgrade, it was found that some aspects of our codebase, particularly withOnyx, are not compatible with concurrent mode, so we turned it off.

Solution

Let's investigate what it will take to re-enable React Concurrent Mode and start working on that in parallel to the New Arch upgrade, which is well over a year in the making and should land hopefully by the end of January.

Issue OwnerCurrent Issue Owner: @muttmuure
@roryabraham roryabraham added Weekly KSv2 NewFeature Something to build that is a new item. labels Dec 23, 2023
@roryabraham roryabraham self-assigned this Dec 23, 2023
Copy link

melvin-bot bot commented Dec 23, 2023

@roryabraham roryabraham assigned muttmuure and unassigned anmurali Dec 23, 2023
@roryabraham
Copy link
Contributor Author

Reassigning to @muttmuure for tracking as part of the NewDot Performance project

@roryabraham
Copy link
Contributor Author

Put out a call for volunteers: https://expensify.slack.com/archives/C05LX9D6E07/p1703292300758289

@melvin-bot melvin-bot bot added the Overdue label Jan 1, 2024
@roryabraham
Copy link
Contributor Author

Still looking for a volunteer, but I assume the people I tagged in slack may be partially OOO. This will remain on HOLD for this week, so I'll bump next week if I haven't heard anything

@melvin-bot melvin-bot bot removed the Overdue label Jan 1, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 9, 2024
@roryabraham
Copy link
Contributor Author

On HOLD for New Arch

@melvin-bot melvin-bot bot removed the Overdue label Jan 10, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 18, 2024
@roryabraham
Copy link
Contributor Author

On HOLD for New Arch

@melvin-bot melvin-bot bot removed the Overdue label Jan 19, 2024
@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2024
@roryabraham
Copy link
Contributor Author

Still on HOLD

@melvin-bot melvin-bot bot removed the Overdue label Jan 29, 2024
@roryabraham
Copy link
Contributor Author

Though, we could try to get a volunteer to start looking into enabling this on web to get a headstart?

@roryabraham
Copy link
Contributor Author

@Szymon20000
Copy link
Contributor

Ready for assignment :)

@roryabraham roryabraham changed the title [HOLD] Enable React Concurrent Mode Enable React Concurrent Mode Jan 30, 2024
@roryabraham
Copy link
Contributor Author

For now, the only platform that's ready for this is web, so you can focus your efforts there to start (while we're working on New Arch)

@Szymon20000
Copy link
Contributor

Hello @roryabraham !
I spent around 3h today on investigating it and wanted to share my thoughts.
I would split the work here into 2 parts.
The first one is making sure onyx is ready for the concurrent rendering and the second one is that all of our components in the app don't have any side effects that could break concurrent rendering.

When it comes to onyx one I see 2 potential issues:

  • The first one is that we have optimistic reads from cache in withOnyx component. Because concurrent rendering can (and most likely will) split the rendering into multiple parts it's possible that some of the components will read newer state than the others. We probably will need to use useSyncExternalStore here (Maybe by wrapping withOnyx in functional component). We already have allowStaleData option so maybe reading inconsistent state is fine in this case.

  • Second one is of course sending updates to withOnyx components. What can happen now is that we will call setState on the first withOnyx listener but the rest will be batched later so again we ends up inconsistent state as some components already know the newer value. I remember that someone was already working on adding Jotai to onyx. Jotai already has support for react concurrent rendering and would solve that problem. What's the current state of it? If we don't plan to use Jotai in onyx we will need to use useSyncExternalStore hook.

For the second part (so making sure all components don't have any dangerous side effect) we can use StrictMode component from React (https://react.dev/reference/react/StrictMode#strictmode) and just traverse the whole app too everything works properly and we don't have any warning on the console. I already added that locally and the report screen stopped to work.

@roryabraham
Copy link
Contributor Author

The first one is that we have optimistic reads from cache in withOnyx component ... We probably will need to use useSyncExternalStore here

Fortunately we have an issue to implement a useOnyx hook and it's happening! The current proposal is to use the useSynxExternalStore hook 👍🏼

I remember that someone was already working on adding Jotai to onyx ... What's the current state of it? If we don't plan to use Jotai in onyx we will need to use useSyncExternalStore hook.

This is the first I've heard of adding Jotai to Onyx, but as I just mentioned we'll be setting up useSyncExternalStore soon. Maybe we'll have to update withOnyx to internally use useOnyx?

For the second part (so making sure all components don't have any dangerous side effect) we can use StrictMode component from React (https://react.dev/reference/react/StrictMode#strictmode) and just traverse the whole app too everything works properly and we don't have any warning on the console

👍🏼 to enabling strict mode on dev. Maybe with a config-level flag to easily enable/disable it so we can turn it off and on easily.

I already added that locally and the report screen stopped to work

Great 🙃

So it sounds like this is the best thing to investigate next? Or do you think you'll be blocked on Onyx needing to use useSyncExternalStore?

@melvin-bot melvin-bot bot added the Daily KSv2 label Jul 10, 2024
@roryabraham roryabraham changed the title [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] LOW: Enable Concurrent React Features [HOLD for payment 2024-07-17] LOW: Enable Concurrent React Features Jul 12, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 12, 2024
@rayane-djouah
Copy link
Contributor

No regression test is needed

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jul 15, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-07-17] LOW: Enable Concurrent React Features [HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] LOW: Enable Concurrent React Features Jul 15, 2024
@melvin-bot melvin-bot bot removed the Overdue label Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.6-8 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-07-22. 🎊

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

  • @Kicu does not require payment (Contractor)
  • @rayane-djouah requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jul 15, 2024

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

  • [@rayane-djouah] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@muttmuure] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

Copy link

melvin-bot bot commented Jul 22, 2024

Payment Summary

Upwork Job

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

BugZero Checklist (@muttmuure)

  • 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//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Jul 24, 2024
@roryabraham roryabraham changed the title [HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] LOW: Enable Concurrent React Features [HOLD for payment 2024-07-22] LOW: Enable Concurrent React Features Jul 24, 2024
@muttmuure
Copy link
Contributor

Created an issue here: https://www.upwork.com/jobs/~01cf7ff3f004364329

@melvin-bot melvin-bot bot removed the Overdue label Jul 25, 2024
@muttmuure
Copy link
Contributor

Upwork job got mangled

@muttmuure
Copy link
Contributor

$250 for @rayane-djouah

@rayane-djouah
Copy link
Contributor

@muttmuure - I accepted the invite

@muttmuure
Copy link
Contributor

Offer sent

@rayane-djouah
Copy link
Contributor

Offer accepted

@rayane-djouah
Copy link
Contributor

cc @muttmuure

@roryabraham roryabraham added Daily KSv2 and removed Weekly KSv2 labels Jul 25, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 29, 2024
@muttmuure
Copy link
Contributor

Paid

@melvin-bot melvin-bot bot removed the Overdue label Jul 29, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 19, 2024
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 NewFeature Something to build that is a new item. Reviewing Has a PR in review Weekly KSv2
Projects
Development

No branches or pull requests

9 participants