-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
RFC: Bridgeless: Introduce unstableRequiresMainQueueSetup in modules #49957
Open
RSNara
wants to merge
4
commits into
facebook:main
Choose a base branch
from
RSNara:export-D70413478
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 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
Summary: This will just make sure that we don't unintentionally break this script. Changelog: [Internal] Differential Revision: D70919549
…9905) Summary: Pull Request resolved: facebook#49905 This diff breaks down generate-artifacts-executor into smaller files. Changelog: [Internal] Differential Revision: D70795042 Reviewed By: alanleedev
This pull request was exported from Phabricator. Differential Revision: D70413478 |
…nents Summary: This diff introduces annotations into the ios codegen config! ## Before In the new architecture, people can declare module/component codegen config in [package.json](https://reactnative.dev/docs/the-new-architecture/using-codegen#configuring-codegen) This config contains the following maps: - modulesConformingToProtocol - modulesProvider - componentProvider ``` "codegenConfig": { "name": "HelloWorldSampleModule", "type": "all", "jsSrcsDir": "specs", "android": { "javaPackageName": "com.helloworld" }, "ios": { "modulesConformingToProtocol": { "RCTImageURLLoader": [ "RCTHelloWorldImageURLLoader" ], "RCTURLRequestHandler": [ "RCTHelloWorldURLRequestHandler" ], "RCTImageDataDecoder": [ "RCTHelloWorldImageDataDecoder" ] }, "modulesProvider": { "HelloWorldImageURLLoader": "RCTHelloWorldImageURLLoader", "HelloWorldURLRequestHandler": "RCTHelloWorldURLRequestHandler", "HelloWorldImageDataDecoder": "RCTHelloWorldImageDataDecoder" }, "componentProvider": { "FooComponent": "RCTFooComponentClass" } } ``` ## After This information is a little bit easier to understand if we group it by module/component (into **annotations**): (that's what this diff does!) ``` "codegenConfig": { "name": "HelloWorldSampleModule", "type": "all", "jsSrcsDir": "specs", "android": { "javaPackageName": "com.helloworld" }, "ios": { "modules": { "HelloWorldImageURLLoader": { "conformsToProtocols": ["RCTImageURLLoader"], "className": "RCTHelloWorldImageURLLoader" }, "HelloWorldURLRequestHandler": { "conformsToProtocols": ["RCTURLRequestHandler"], "className": "RCTHelloWorldURLRequestHandler" }, "HelloWorldImageDataDecoder": { "conformsToProtocols": ["RCTImageDataDecoder"], "className": "RCTHelloWorldImageDataDecoder" } }, "components": { "FooComponent": { "className": "RCTFooComponent" } }, } ``` ## Migration The old way is still supported (for now). We will deprecate it soon, and eventually remove it from react native! Changelog: [iOS][Added] - Codegen: Introduce module/component annotations inside package.json Differential Revision: D70822061
Summary: ## Context Native modules can implement this method: ``` - (BOOL)requiresMainQueueSetup { return YES; } ``` When this method returns true: - **The bridge** eagerly initializes the module on the main queue, **during** react native init. - But, **TurboModules** just lazily load the module when needed, synchronously executing the module setup on the main thread. ## Problem The turbomodule behaviour is hazardous: 1. If javascript loads a main queue module, the js thread blocks on the main thread. 2. And if the main thread blocks on javascript thread (via fling), react native could deadlock. ## Solution We need this "eagerly execute some code on the ui thread" functionality in React Native, in some way shape or form. **Proposal:** This diff re-introduces the old functionality into turbo modules: **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 } } } }, ``` ## Todos - introduce warnings when some or all main queue modules take too long to load, - think through deprecation strategy for objc "requiresMainQueueSetup" on turbomodules Differential Revision: D70413478
This pull request was exported from Phabricator. Differential Revision: D70413478 |
a33e5f2
to
f7fe2e7
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:
Context
Native modules can implement this method:
When this method returns true:
Problem
The turbomodule behaviour is hazardous:
Solution
We need this "eagerly execute some code on the ui thread" functionality in React Native, in some way shape or form.
Proposal: This diff re-introduces the old functionality into turbo modules:
Buck API:
Plugin:
OSS API:
codegenConfig in package.json:
Todos
Differential Revision: D70413478