Skip to content

Expose the JS CallInvoker on RCTHost - #58778

Closed
potomak wants to merge 1 commit into
react:mainfrom
potomak:export-D122169845
Closed

potomak wants to merge 1 commit into
react:mainfrom
potomak:export-D122169845

Conversation

@potomak

@potomak potomak commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

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

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
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 30, 2026
@meta-codesync

meta-codesync Bot commented Sep 30, 2026

Copy link
Copy Markdown

@potomak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D122169845.

@meta-codesync meta-codesync Bot closed this in 8f58866 Sep 30, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Sep 30, 2026
@meta-codesync

meta-codesync Bot commented Sep 30, 2026

Copy link
Copy Markdown

This pull request has been merged in 8f58866.

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. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant