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

✨ Support the v8 version of react-native-reanimated #499

Closed
2 tasks done
jzxchiang1 opened this issue Oct 10, 2021 · 14 comments · Fixed by #1466
Closed
2 tasks done

✨ Support the v8 version of react-native-reanimated #499

jzxchiang1 opened this issue Oct 10, 2021 · 14 comments · Fixed by #1466

Comments

@jzxchiang1
Copy link

What feature or enhancement are you suggesting?

Very soon, reanimated will support v8. (I've gotten it working on RN 64 with the help of Kudo, who is the maintainer of react-native-v8.)

I tried the v8 version of react-native-reanimated with vision-camera 2.9.0 on iOS and it worked fine.

However, on Android it threw an error on npm run android because vision-camera only expects Hermes or JSC:

def jsEngine = FOR_HERMES ? "hermes" : "jsc"

Also, these files won't exist for those running react-native-v8:

def jscAAR = fileTree("${rootDir}/../node_modules/jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile


One question I have is how you know whether to package the Hermes or JSC AAR at build time? Doesn't that depend on what the library user is using, which you don't know until runtime? That's why I'm confused how you can only choose to package one AAR in this PR instead of all of them.

Thanks!

What Platforms whould this feature/enhancement affect?

Android

Alternatives/Workarounds

Not sure how to get it working right now. All the ingredients for v8 support are there however.

Additional information

@jzxchiang1
Copy link
Author

Related comment: #412 (comment)

@mrousavy
Copy link
Owner

Hi! Thanks for the feature request, v8 is surely cool to support.

One question I have is how you know whether to package the Hermes or JSC AAR at build time?

Because that's how it works. RN has the enableHermes property in build.gradle to determine the engine at build time. Not sure how V8 solves this..

@Kudo
Copy link

Kudo commented Oct 11, 2021

@mrousavy mrousavy changed the title Support the v8 version of react-native-reanimated✨ ✨ Support the v8 version of react-native-reanimated Oct 11, 2021
@jzxchiang1
Copy link
Author

Hi! Thanks for the feature request, v8 is surely cool to support.

One question I have is how you know whether to package the Hermes or JSC AAR at build time?

Because that's how it works. RN has the enableHermes property in build.gradle to determine the engine at build time. Not sure how V8 solves this..

One question: is the vision-camera build.gradle run when the user runs npx react-native run-android or when the library maintainer (i.e. you) builds the NPM package to distribute?

In the meantime, is there a quick fix (possibly patched locally) for me to get @Kudo's v8 reanimated working with vision-camera 2.5.0+ on Android? It's so close but I don't quite understand everything yet :(

@mrousavy
Copy link
Owner

One question: is the vision-camera build.gradle run when the user runs npx react-native run-android or when the library maintainer (i.e. you) builds the NPM package to distribute?

build.gradle is evaluated when you run npx react-native run-android. I am not pre-building VisionCamera for distribution.

is there a quick fix (possibly patched locally) for me to get @Kudo's v8 reanimated working with vision-camera 2.5.0+ on Android?

No, Reanimated needs to add V8 support first.

@jzxchiang1
Copy link
Author

Thanks for the response. Interesting, so npx react-native run-android not only looks at android/app/build.gradle it also looks at all of the build.gradle files in node_modules/? That's really interesting, had no idea.

@jzxchiang1
Copy link
Author

I'm looking at this again, and I'm curious why the prepareJSC gradle task writes to this directory, but CMakeLists.txt never actually uses that to compile or link?

@jzxchiang1
Copy link
Author

OK I got it working with a local patch: https://gist.github.com/jzxchiang1/012af920bca8b335faab2d913fd6293d

So now I'm running:

  • react-native 0.64.2
  • react-native-reanimated 2.2.2 (patched version published by @Kudo at npm:react-native-reanimated-v8)
  • react-native-v8 0.64.2-patch.1
  • react-native-vision-camera 2.9.4

Note that iOS works without any changes (besides pod install).

This is a workaround until reanimated officially supports v8, which I hope they do since all the pieces are already there.

@mrousavy
Copy link
Owner

Nice job on the workaround @jzxchiang1 !

@sunnylqm
Copy link

https://github.com/software-mansion/react-native-reanimated/releases/tag/3.0.0-rc.1 reanimated now has a v8 compatiable version

@jzxchiang1
Copy link
Author

Bump!

@dipcore
Copy link

dipcore commented Sep 14, 2022

V8 Support has been added to react-native-reanimated with 2.10.0 release
v2.10.0 react-native-reanimated now officially supports v8 engine

Is that possible to add the v8 support to react-native-vision-camera too?

@mrousavy
Copy link
Owner

Shouldn't be too difficult, I just don't have a need for it and don't have the free time to work on this atm

@dipcore
Copy link

dipcore commented Sep 14, 2022

@mrousavy Thanks for answering!

In the description it says Added support for react-native-v8 (building from source only) means there is no .aar files provided with react-native-reanimated package.

In the line 282 (https://github.com/mrousavy/react-native-vision-camera/blob/main/android/build.gradle#L282) we use .aar to extractJNI So it seems for me its a bit more complicated...

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants