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

Make sure the Native RuntimeScheduler is initialized on Old Arch #37517

Closed
wants to merge 1 commit into from

Conversation

cortinico
Copy link
Contributor

Summary:
Fixes #35778

We got reports of regressions on useEffect starting from 0.69+ when on Hermes.

The issue seems to be caused by a bump of the scheduler package from 0.20 to 0.21.
In scheduler@0.21, the method setImmediate gets called if available
(see facebook/react#20834). This causes React Native to use Microtasks
which ends up in changing the semantic of useEffect.

The solution is to use the Native RuntimeScheduler properly.
On Paper specifically, we never initialized it as it's effectively initialized by the
TurboModuleManagerDelegate. Here I trigger the initialization of it on Paper as well.

Changelog:
[Android] [Fixed] - Make sure the Native RuntimeScheduler is initialized on Old Arch

Reviewed By: sammy-SC

Differential Revision: D46024807

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels May 22, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46024807

@analysis-bot
Copy link

analysis-bot commented May 22, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,733,442 +71
android hermes armeabi-v7a 8,044,623 +68
android hermes x86 9,223,550 +71
android hermes x86_64 9,075,522 +62
android jsc arm64-v8a 9,298,197 +19
android jsc armeabi-v7a 8,486,931 +17
android jsc x86 9,359,358 +11
android jsc x86_64 9,615,446 +20

Base commit: c396bc7
Branch: main

cortinico added a commit to cortinico/react-native that referenced this pull request May 22, 2023
…ebook#37517)

Summary:
Pull Request resolved: facebook#37517

Fixes facebook#35778

We got reports of regressions on `useEffect` starting from 0.69+ when on Hermes.

The issue seems to be caused by a bump of the `scheduler` package from 0.20 to 0.21.
In scheduler@0.21, the method `setImmediate` gets called if available
(see facebook/react#20834). This causes React Native to use Microtasks
which ends up in changing the semantic of useEffect.

The solution is to use the Native RuntimeScheduler properly.
On Paper specifically, we never initialized it as it's effectively initialized by the
TurboModuleManagerDelegate. Here I trigger the initialization of it on Paper as well.

Changelog:
[Android] [Fixed] - Make sure the Native RuntimeScheduler is initialized on Old Arch

Reviewed By: sammy-SC

Differential Revision: D46024807

fbshipit-source-id: da117769aaa60d1048e6ec50503c74eed6a0df3e
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46024807

…ebook#37517)

Summary:
Pull Request resolved: facebook#37517

Fixes facebook#35778

We got reports of regressions on `useEffect` starting from 0.69+ when on Hermes.

The issue seems to be caused by a bump of the `scheduler` package from 0.20 to 0.21.
In scheduler@0.21, the method `setImmediate` gets called if available
(see facebook/react#20834). This causes React Native to use Microtasks
which ends up in changing the semantic of useEffect.

The solution is to use the Native RuntimeScheduler properly.
On Paper specifically, we never initialized it as it's effectively initialized by the
TurboModuleManagerDelegate. Here I trigger the initialization of it on Paper as well.

Changelog:
[Android] [Fixed] - Make sure the Native RuntimeScheduler is initialized on Old Arch

Reviewed By: sammy-SC

Differential Revision: D46024807

fbshipit-source-id: 133d6de5d42f00718092601efc8b7862eda646c9
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46024807

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 22, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 133ccdc.

kelset pushed a commit that referenced this pull request May 25, 2023
)

Summary:
Pull Request resolved: #37517

Fixes #35778

We got reports of regressions on `useEffect` starting from 0.69+ when on Hermes.

The issue seems to be caused by a bump of the `scheduler` package from 0.20 to 0.21.
In scheduler@0.21, the method `setImmediate` gets called if available
(see facebook/react#20834). This causes React Native to use Microtasks
which ends up in changing the semantic of useEffect.

The solution is to use the Native RuntimeScheduler properly.
On Paper specifically, we never initialized it as it's effectively initialized by the
TurboModuleManagerDelegate. Here I trigger the initialization of it on Paper as well.

Changelog:
[Android] [Fixed] - Make sure the Native RuntimeScheduler is initialized on Old Arch

Reviewed By: sammy-SC

Differential Revision: D46024807

fbshipit-source-id: d72cd774df58410467644cddeaaf37e3c227b505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Since React Native 0.69, useEffects appear to be flushed synchronously even in React legacy mode
3 participants