Skip to content

Conversation

nikki93
Copy link
Contributor

@nikki93 nikki93 commented Oct 15, 2016

Motivation

I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.

(@lexs you mentioned to tag you in this pull request)

Test plan

Modify the JavaScriptCore context through the JSContextRef returned (eg. add an object at global scope) and verify that it exists in JavaScript.

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @adamjernst and @cjhopman to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Oct 15, 2016
@dannycochran
Copy link
Contributor

dannycochran commented Oct 15, 2016

@nikki93 I believe this will be extremely useful for a project I'm working on. Could this be extended to also allow access for creating a separate JSCore context from JS-land? I'm currently using a WebView context to evaluate user generated code but would prefer access to a context without having to write a bridge into a native module.

@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 Oct 15, 2016
@ide
Copy link
Contributor

ide commented Oct 15, 2016

@dannycochran there's an experimental WebWorker API on RN which allows for that, but this PR is substantially different. It exposes a JSContext pointer to native code and doesn't create a new JSContext with a new RN environment (this is what WebWorkers do) or interact with JavaScript at all. I recommend you write a native module that addresses your use cases because they sound rather different than the ones this PR addresses.

@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 Oct 15, 2016
@lexs
Copy link
Contributor

lexs commented Oct 26, 2016

@nikki93 I'm fine with this (sorry for taking some time to get back to you). Are you happy to have it merged? @lacker Any reservations?

@nikki93
Copy link
Contributor Author

nikki93 commented Oct 26, 2016

@lexs Oh great! Yeah I'm ready for a merge!

@lexs
Copy link
Contributor

lexs commented Oct 26, 2016

@nikki93 Github reports a conflict in React/Executors/RCTJSCExecutor.mm. Fix that up and I'll land it.

@nikki93
Copy link
Contributor Author

nikki93 commented Oct 26, 2016

@lexs Fixed!

@facebook-github-bot
Copy link
Contributor

@lexs has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

ide pushed a commit to expo/react-native that referenced this pull request Oct 27, 2016
Summary:
**Motivation**

I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.

(lexs you mentioned to tag you in this pull request)

**Test plan**

Modify the JavaScriptCore context through the `JSContextRef` returned (eg. add an object at global scope) and verify that it exists in JavaScript.
Closes facebook#10399

Differential Revision: D4080945

Pulled By: lexs

fbshipit-source-id: 6659b7a01e09fd84475adde183c1d3aca2d4cf09
@ide ide deleted the jscontext-access branch November 23, 2016 19:07
ide pushed a commit to expo/react-native that referenced this pull request Nov 23, 2016
Summary:
**Motivation**

I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.

(lexs you mentioned to tag you in this pull request)

**Test plan**

Modify the JavaScriptCore context through the `JSContextRef` returned (eg. add an object at global scope) and verify that it exists in JavaScript.
Closes facebook#10399

Differential Revision: D4080945

Pulled By: lexs

fbshipit-source-id: 6659b7a01e09fd84475adde183c1d3aca2d4cf09
ide pushed a commit to expo/react-native that referenced this pull request Nov 30, 2016
Summary:
**Motivation**

I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.

(lexs you mentioned to tag you in this pull request)

**Test plan**

Modify the JavaScriptCore context through the `JSContextRef` returned (eg. add an object at global scope) and verify that it exists in JavaScript.
Closes facebook#10399

Differential Revision: D4080945

Pulled By: lexs

fbshipit-source-id: 6659b7a01e09fd84475adde183c1d3aca2d4cf09
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
Summary:
**Motivation**

I'm working on a project that uses React Native and needs to add direct synchronous bindings to native stuff through the JavaScriptCore C API. This is because it's performance-sensitive and would benefit from the quickest JS->C path. It does this using cross-platform C++ code that works on both iOS and Android. Most of the infrastructure for getting access to the JSC context is already in React Native actually, just had to add a few more things.

(lexs you mentioned to tag you in this pull request)

**Test plan**

Modify the JavaScriptCore context through the `JSContextRef` returned (eg. add an object at global scope) and verify that it exists in JavaScript.
Closes facebook#10399

Differential Revision: D4080945

Pulled By: lexs

fbshipit-source-id: 6659b7a01e09fd84475adde183c1d3aca2d4cf09
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants