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

Enable array buffers in JSCRuntime.cpp #28961

Closed
wants to merge 3 commits into from

Conversation

ryantrem
Copy link
Contributor

@ryantrem ryantrem commented May 25, 2020

Summary

The JavaScriptCore implementation of JSI does not currently support array buffers. The comments in the code suggest the JSC version used by React Native does not work with array buffers, but this seems to be out of date since the current version of JSC used by React Native does indeed support array buffers. This change just enables array buffers in JSCRuntime.cpp.

NOTE: See react-native-community/discussions-and-proposals#91 (comment) for more background on this change.

Changelog

[General] [Added] - Support for array buffers in the JavaScriptCore implementation of JSI

Test Plan

To test these changes, I just made some temporary changes to RNTester to use JSI to inject a test function into the JS runtime that reads from and writes to an array buffer, and call that function from the JS of the RNTester app (see ryantrem@28152ce).

For the JS side of this, specifically look at https://github.com/ryantrem/react-native/blob/28152ce3f4ae0fa906557415d106399b3f072118/RNTester/js/RNTesterApp.android.js#L13-L18

For the native side of this, specifically look at https://github.com/ryantrem/react-native/blob/28152ce3f4ae0fa906557415d106399b3f072118/RNTester/android/app/src/main/cpp/JSITest.cpp#L22-L38

@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 May 25, 2020
@ryantrem
Copy link
Contributor Author

FYI @mhorowitz, @tmikov, @bghgary.

@react-native-bot react-native-bot added the Type: Enhancement A new feature or enhancement of an existing feature. label May 25, 2020
@analysis-bot
Copy link

analysis-bot commented May 25, 2020

Platform Engine Arch Size (bytes) Diff
ios - universal 10,738,000 16,304

Base commit: f438a6e

@analysis-bot
Copy link

analysis-bot commented May 25, 2020

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 6,780,258 15,628
android hermes armeabi-v7a 6,442,477 16,108
android hermes x86 7,165,449 16,074
android hermes x86_64 7,056,016 16,084
android jsc arm64-v8a 8,948,058 14,971
android jsc armeabi-v7a 8,602,657 15,439
android jsc x86 8,776,347 15,405
android jsc x86_64 9,352,558 15,417

Base commit: f438a6e

@ryantrem ryantrem changed the title Enable array buffers since the current JSC version used in react nati… Enable array buffers in JSCRuntime.cpp May 25, 2020
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@@ -276,6 +276,9 @@ class JSCRuntime : public jsi::Runtime {
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth noting, this existing define looks wrong to me. I believe _JSC_FAST_IS_ARRAY will never be defined on Android, so will always use the slow version. Presumably this should be fixed, though I didn't really want to overload this PR.

@ryantrem ryantrem requested a review from shergin May 27, 2020 03:25
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@ryantrem
Copy link
Contributor Author

From what I can tell, there is no way for me to see what the warning is that is causing the "Facebook Internal - Builds & Tests" check to fail, is that right? Assuming yes, can someone (@shergin?) provide some details if there is something more I need to address for this?

@ryantrem
Copy link
Contributor Author

Ping! @shergin, @mhorowitz, @tmikov - can anyone help here? I'd like to see this PR merged, but I don't know what the build warning is. I don't get any build warnings in either XCode or Android Studio when building locally.

@tmikov
Copy link

tmikov commented May 29, 2020

AFAICT, it is a clang-format warning on line 944. The line is too long and needs to be reformatted.

@ryantrem
Copy link
Contributor Author

ryantrem commented Jun 1, 2020

@shergin or @tmikov - thanks for your help so far on this PR. Can one of you re-"import" this PR after my latest change (which I believe should address the issue @tmikov mentioned above)?

@tmikov
Copy link

tmikov commented Jun 2, 2020

@ryantrem the original importer "owns" the diff internally, so ordinarily only they can re-import it. I will reach out to @shergin internally.

@ryantrem
Copy link
Contributor Author

ryantrem commented Jun 8, 2020

Hi again @tmikov and @shergin - sorry to nag, but since another week has passed I wanted to follow up on this and see if there has been any progress, or if you need anything else from me.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@tmikov
Copy link

tmikov commented Jun 8, 2020

@ryantrem sorry for the delay. We discussed it with @shergin and we will proceed to land it shortly.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ryantrem in 9c32140.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jun 9, 2020
grabbou pushed a commit that referenced this pull request Jul 14, 2020
Summary:
The JavaScriptCore implementation of JSI [does not currently support array buffers](https://github.com/facebook/react-native/blob/master/ReactCommon/jsi/JSCRuntime.cpp#L925-L943). The comments in the code suggest the JSC version used by React Native does not work with array buffers, but this seems to be out of date since the current version of JSC used by React Native does indeed support array buffers. This change just enables array buffers in JSCRuntime.cpp.

NOTE: See react-native-community/discussions-and-proposals#91 (comment) for more background on this change.

## Changelog

[General] [Added] - Support for array buffers in the JavaScriptCore implementation of JSI
Pull Request resolved: #28961

Test Plan:
To test these changes, I just made some temporary changes to RNTester to use JSI to inject a test function into the JS runtime that reads from and writes to an array buffer, and call that function from the JS of the RNTester app (see ryantrem@28152ce).

For the JS side of this, specifically look at https://github.com/ryantrem/react-native/blob/28152ce3f4ae0fa906557415d106399b3f072118/RNTester/js/RNTesterApp.android.js#L13-L18

For the native side of this, specifically look at https://github.com/ryantrem/react-native/blob/28152ce3f4ae0fa906557415d106399b3f072118/RNTester/android/app/src/main/cpp/JSITest.cpp#L22-L38

Reviewed By: shergin

Differential Revision: D21717995

Pulled By: tmikov

fbshipit-source-id: 5788479bb33c24d01aa80fa7f509e0ff9dcefea6
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. Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants