-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Make PlatformConstants use main queue setup (#50111) #50141
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
Open
RSNara
wants to merge
4
commits into
facebook:main
Choose a base branch
from
RSNara:export-D71480047
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…#49957) Summary: Pull Request resolved: facebook#49957 ## Changes This diff introduces the api for "main queue modules" into turbo modules. This will occur occurs before any rendering. ## Rationale Rendering can now include main -> js sync calls. If we allow js -> main sync calls during rendering, react native can deadlock. With this diff, we can move the js -> main sync calls to before any rendering happens. ## APIs **Buck API:** Plugin: ``` react_module_plugin_providers( name = "AccessibilityManager", native_class_func = "RCTAccessibilityManagerCls", unstable_requires_main_queue_setup = True, ) ``` **OSS API:** [codegenConfig](https://reactnative.dev/docs/the-new-architecture/using-codegen) in package.json: ``` "codegenConfig": { "name": "<SpecName>", "type": "<types>", "jsSrcsDir": "<source_dir>", "android": { "javaPackageName": "<java.package.name>" }, "ios": { "modules": { "AccessibilityManager": { "className": "RCTAccessibilityManager", "unstableRequiresMainQueueSetup": true } } } }, ``` Changelog: [iOS][Added] Introduce unstableRequiresMainQueueSetup api to modules Differential Revision: D70413478 Reviewed By: cipolleschi
…#50040) Summary: Pull Request resolved: facebook#50040 This diff implements main queue module setup. Sometimes, people need to capture uikit things, and use them from javascript. In those cases, people can write main queue modules. These modules will be eagerly initialized on the main queue, during react native init. ## On Necessity **Sync** dispatches to the main thread from the js thread can deadlock react native. And **async** dispatches to the main thread from the js thread sometimes might not be enough: it could lead to flickery rendering. So, we need to allow people to capture ui thread things, before any js executes. ## Caveat This api is dangerous and discouraged. All react native surfaces will pay the cost of one surface introducing a main queue module. It could also slow down common/critical interactions in your app, if you're not careful. We will introduce performance logging for this infrastructure. So that we can monitor and file tasks, when main queue module init starts taking "too long." Changelog: [General][Breaking]: Introduce beforeload callback arg into ReactInstance::loadScript Differential Revision: D71084243 Reviewed By: mdvacca
Summary: We will use main queue setup of native modules to solve this problem instead. Changelog: [Internal] Differential Revision: D71341038 Reviewed By: mdvacca
This pull request was exported from Phabricator. Differential Revision: D71480047 |
Summary: Pull Request resolved: facebook#50141 Pull Request resolved: facebook#50111 ## Rationale Rendering can now include main -> js sync calls. If we allow js -> main sync calls during rendering, react native can deadlock. So, this diff moves the js -> main sync calls to "main queue module setup", which occurs before rendering. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D71480047
This pull request was exported from Phabricator. Differential Revision: D71480047 |
f1ebeda
to
d7c8729
Compare
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
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Rationale
Rendering can now include main -> js sync calls.
If we allow js -> main sync calls during rendering, react native can deadlock.
So, this diff moves the js -> main sync calls to "main queue module setup", which occurs before rendering.
Changelog: [Internal]
Differential Revision: D71480047