Conversation
Summary: Android exposes the React instance's `CallInvoker` through `ReactContext.getJSCallInvokerHolder()`. iOS has no equivalent: `RCTInstance` creates the same invoker but only hands it to its TurboModules. This adds `-[RCTHost jsCallInvoker]`, backed by a new `RCTInstance.jsCallInvoker` that keeps that invoker. Unlike `RuntimeExecutor`, a `CallInvoker` lets native code schedule work on the JS thread with a priority. - Set once during instance init, so it can be read from any thread. - Holding the invoker past a reload, or past the host's lifetime, is safe: it only references the instance's scheduler weakly, so work sent after the instance is gone is dropped. - Null before `start`. Every reload creates a new instance with a new invoker, so callers read it again after `hostDidStart:`. - The C++/Objective-C API snapshots are updated for the two new declarations. Changelog: [iOS][Added] - Add `-[RCTHost jsCallInvoker]` to access the React instance's `CallInvoker` Reviewed By: zeyap Differential Revision: D122169845
|
@potomak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D122169845. |
|
This pull request has been merged in 8f58866. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
Android exposes the React instance's
CallInvokerthroughReactContext.getJSCallInvokerHolder(). iOS has no equivalent:RCTInstancecreates the same invoker but only hands it to its TurboModules.This adds
-[RCTHost jsCallInvoker], backed by a newRCTInstance.jsCallInvokerthat keeps that invoker. UnlikeRuntimeExecutor, aCallInvokerlets native code schedule work on the JS thread with a priority.start. Every reload creates a new instance with a new invoker, so callers read it again afterhostDidStart:.Changelog:
[iOS][Added] - Add
-[RCTHost jsCallInvoker]to access the React instance'sCallInvokerReviewed By: zeyap
Differential Revision: D122169845