react-native-vision-camera
react-native-vision-camera copied to clipboard
✨ Support the v8 version of react-native-reanimated
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:
https://github.com/mrousavy/react-native-vision-camera/blob/2cf8087ad663fafeb645280978ed55240f290284/android/build.gradle#L227
Also, these files won't exist for those running react-native-v8:
https://github.com/mrousavy/react-native-vision-camera/blob/2cf8087ad663fafeb645280978ed55240f290284/android/build.gradle#L220
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
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar feature requests in this repository and found none.
Related comment: https://github.com/mrousavy/react-native-vision-camera/pull/412#issuecomment-939523230
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..
reanimated didn't officially support v8 now. in the meantime i just forked and build v8 aar by myself.
and here is how i check which aar to use: https://github.com/Kudo/react-native-reanimated/commit/4b069950c4b75b836350b1803485819939ce632b#diff-d260c332176b5c72008900aef1116a89a873451c7388a808c8d2d58be0865d38R64-R65
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 inbuild.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 :(
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.
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.
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?
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.
Nice job on the workaround @jzxchiang1 !
https://github.com/software-mansion/react-native-reanimated/releases/tag/3.0.0-rc.1 reanimated now has a v8 compatiable version
Bump!
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?
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
@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?