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

introduce native api to access RuntimeExecutor #42758

Closed
wants to merge 1 commit into from

Conversation

philIip
Copy link
Contributor

@philIip philIip commented Jan 31, 2024

Summary:
Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:

  • Wrapper objects for RuntimeExecutor access. These are RCTRuntimeExecution and RCTRuntimeExecutionWrapper. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
  • The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188

@facebook-github-bot facebook-github-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 Jan 31, 2024
@facebook-github-bot
Copy link
Contributor

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

/**
Swift friendly wrapper of RCTRuntimeExecution.
*/
@interface RCTRuntimeExecutionWrapper : NSObject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the wrapper class? It seems to be just wrapping RCTRuntimeExecution without the C++ stuff. I think hiding the C++ part with #ifdef __cplusplus in RCTRuntimeExecution makes more sense and doesn't need to introduce another class.

Copy link
Contributor Author

@philIip philIip Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main reason is that i didn't know how to correctly use that flag for swift interop so i just went with something i knew would work, lol

i also think an additional benefit of the wrapper class is that it allows you to use RCTRuntimeExecution without having to pull in the ReactCommon dependency, so ExpoBridgeModule doesn't have to bring in any new deps. RCTRuntimeExecutionWrapper has no dep on RCTRuntimeExecution which is nice when we just need to pass it around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok @tsapeta i got rid of the wrapper class!

if it's a swift module, it should only pull in the forward declarations from RCTRuntimeExecutionModule protocol, then pass it down to an obj-c++ file. then that file can import RCTRuntimeExecutorProvider.h, so there should be no need for compiler flag either!

}];
RCTRuntimeExecutionWrapper *runtimeExecutionWrapper =
[[RCTRuntimeExecutionWrapper alloc] initWithRuntimeExecution:runtimeExecution];
[(id)module setValue:runtimeExecutionWrapper forKey:@"runtimeExeuctionWrapper"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Suggested change
[(id)module setValue:runtimeExecutionWrapper forKey:@"runtimeExeuctionWrapper"];
[(id)module setValue:runtimeExecutionWrapper forKey:@"runtimeExecutionWrapper"];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i blame KVO

philIip added a commit to philIip/react-native that referenced this pull request Jan 31, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

@analysis-bot
Copy link

analysis-bot commented Jan 31, 2024

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 17,233,416 -5
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 20,600,227 +6
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: e4342f5
Branch: main

philIip added a commit to philIip/react-native that referenced this pull request Jan 31, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Jan 31, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 1, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 1, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 1, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 1, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 1, 2024
Summary:

Changelog: [Added][iOS] introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- Wrapper objects for RuntimeExecutor access. These are `RCTRuntimeExecution` and `RCTRuntimeExecutionWrapper`. RCTRuntimeExecutionWrapper is a C++ free wrapper of RCTRuntimeExecution to be reliably used in Swift modules.
- The new API on RCTBridgeModule, following a similar pattern to other decoration APIs, and integration with our module infrastructure.

Differential Revision: D53256188
philIip added a commit to philIip/react-native that referenced this pull request Feb 5, 2024
Summary:

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 5, 2024
Summary:

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 5, 2024
Summary:

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 5, 2024
Summary:

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 5, 2024
Summary:

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188
Summary:

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

philIip added a commit to philIip/react-native that referenced this pull request Feb 6, 2024
Summary:
Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](facebook#42758).

From [PR#42758](facebook#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, i created an async api that will guarantee the runtime executor will be ready.

Differential Revision: D53461821
philIip added a commit to philIip/react-native that referenced this pull request Feb 6, 2024
Summary:

Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](facebook#42758).

From [PR#42758](facebook#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, i created an async api that will guarantee the runtime executor will be ready.

Differential Revision: D53461821
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 6, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 343a0d3.

philIip added a commit to philIip/react-native that referenced this pull request Feb 7, 2024
Summary:

Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](facebook#42758).

From [PR#42758](facebook#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, i created an async api that will guarantee the runtime executor will be ready.

Differential Revision: D53461821
philIip added a commit to philIip/react-native that referenced this pull request Feb 7, 2024
Summary:

Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](facebook#42758).

From [PR#42758](facebook#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, this can still return null. however, the callsite should be cognizant of when this will happen. in the case of expomodules, the runtime should be ready when the module is init, unless it is a eager initialized module

Differential Revision: D53461821
philIip added a commit to philIip/react-native that referenced this pull request Feb 8, 2024
Summary:

Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](facebook#42758).

From [PR#42758](facebook#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, this can still return null. however, the callsite should be cognizant of when this will happen. in the case of expomodules, the runtime should be ready when the module is init, unless it is a eager initialized module

Differential Revision: D53461821
philIip added a commit to philIip/react-native that referenced this pull request Feb 8, 2024
Summary:

Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](facebook#42758).

From [PR#42758](facebook#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, this can still return null. however, the callsite should be cognizant of when this will happen. in the case of expomodules, the runtime should be ready when the module is init, unless it is a eager initialized module

Differential Revision: D53461821
facebook-github-bot pushed a commit that referenced this pull request Feb 9, 2024
Summary:
Pull Request resolved: #42882

Changelog: [Android][Added] - introduce native api to access RuntimeExecutor

This is the android equivalent of [PR#42758](#42758).

From [PR#42758](#42758)

> The goal of this API is to provide a safe way to access the jsi::runtime in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

> However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). because react context can be non-null before react instance is ready, this can still return null. however, the callsite should be cognizant of when this will happen. in the case of expomodules, the runtime should be ready when the module is init, unless it is a eager initialized module

Reviewed By: RSNara

Differential Revision: D53461821

fbshipit-source-id: 69555d0593a59f8655e4dcd2f0ef1f78f4cfff7d
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.

4 participants