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

Pass jsi::Runtime reference into CallInvoker::invoke* callbacks #43375

Closed
wants to merge 1 commit into from

Conversation

rshest
Copy link
Contributor

@rshest rshest commented Mar 7, 2024

Summary:

Changelog:

[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct jsi::Runtime object as an argument to the CallInvoker::invoke* callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the jsi::Runtime in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Differential Revision: D54643171

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…acks (facebook#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…acks (facebook#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

Differential Revision: D54643171
rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

Differential Revision: D54643171
rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

Differential Revision: D54643171
rshest added a commit to rshest/react-native that referenced this pull request Mar 7, 2024
…book#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

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

rshest added a commit to rshest/react-native that referenced this pull request Mar 8, 2024
…acks (facebook#43375)

Summary:

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

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

This pull request has been merged in 76ce789.

philIip added a commit to philIip/react-native that referenced this pull request May 2, 2024
Summary:
Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 2, 2024
Summary:
Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Differential Revision: D56866817
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
Summary:
Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
Summary:

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
Summary:

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
…44378)

Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
philIip added a commit to philIip/react-native that referenced this pull request May 3, 2024
Summary:

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994
facebook-github-bot pushed a commit that referenced this pull request May 3, 2024
Summary:
Pull Request resolved: #44378

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after #43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994

fbshipit-source-id: 5c3585356d016a50645eda3af2d3bbe00298b4e4
philIip added a commit to philIip/react-native that referenced this pull request May 4, 2024
Summary:

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
philIip added a commit to philIip/react-native that referenced this pull request May 4, 2024
Summary:

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
philIip added a commit to philIip/react-native that referenced this pull request May 4, 2024
Summary:

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
facebook-github-bot pushed a commit that referenced this pull request May 4, 2024
Summary:
Pull Request resolved: #44381

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after #43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817

fbshipit-source-id: 4096847c52559d9a49feb072a0385da6b64392d4
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request May 6, 2024
Summary:
Pull Request resolved: facebook#44378

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994

fbshipit-source-id: 5c3585356d016a50645eda3af2d3bbe00298b4e4
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request May 6, 2024
Summary:
Pull Request resolved: facebook#44381

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817

fbshipit-source-id: 4096847c52559d9a49feb072a0385da6b64392d4
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
Summary:
Pull Request resolved: facebook#44378

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994

fbshipit-source-id: 5c3585356d016a50645eda3af2d3bbe00298b4e4
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
Summary:
Pull Request resolved: facebook#44381

Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817

fbshipit-source-id: 4096847c52559d9a49feb072a0385da6b64392d4
@kraenhansen
Copy link
Contributor

kraenhansen commented Aug 21, 2024

@rshest I see that care was made in this PR to provide signatures for backward compatibility, but these were only added for overload that doesn't take a SchedulerPriority as first argument.

We depend on the overload that does take a SchedulerPriority as first argument:

virtual void invokeAsync(
SchedulerPriority /*priority*/,
CallFunc&& func) noexcept {
// When call with priority is not implemented, fall back to a regular async
// execution
invokeAsync(std::move(func));
}

This caused realm-js#6845 and realm-js#6846. I wanted to flag this here first, in case you want to do a quick follow-up PR. I can also create an issue to track this separately.

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