react-native-reanimated
react-native-reanimated copied to clipboard
react-native-v8 compatibility with reanimated v2
Description
In #3132 v8 compatibility was landed for reanimated but it seems like this was only merged for v3 and not cherry-picked onto v2
Expected behavior
Expect compatibility with v8 in react-native-reanimated v2
Hey! 👋
It looks like you've omitted a few important sections from the issue template.
Please complete Snack or minimal code example, Package versions and Affected platforms sections.
because reanimated v2 shipped prebuilt aar and it doesn't make sense to include more aar for v8. maybe i can have a reanimated fork, is it feasible to you?
because reanimated v2 shipped prebuilt aar and it doesn't make sense to include more aar for v8. maybe i can have a reanimated fork, is it feasible to you?
Yeah that would be alright! Let me know if I can help maintain. My IDE isn't setup for C++ projects but I'd be happy to start dipping my feet in the water if it eases the burden.
Hey @Kudo we also need to migrate to Reanimated V2. Anything we can do to help expedite a fork or a PR for Reanimated V2 to support V8?
added v8 support for reanimated 2 here: https://github.com/kudo/react-native-reanimated/tree/v8/2.9.1
could install it through yarn add kudo/react-native-reanimated#v8/2.9.1
@Kudo Thanks for taking care of this issue! 🎉
Indeed, Reanimated v2 is distributed as AAR with pre-compiled binaries ~~and thus adding support for third JS VM would significantly increase package size.~~ (edit: the v8 support commit is intentionally building from source).
Instead, you can upgrade to Reanimated 3, which is fully-compatible with Reanimated 2 API (so you don't have to rewrite any single line of your code). Also, v3 supports Fabric, the new RN architecture. Apart from this, we've got rid of old and rusty Reanimated 1 (which also reduces package size). Finally, Reanimated 3 for Android is built from sources (like on iOS) and thus requires Android NDK installed. Check out this blog post from @kmagiera on SWM blog for more details.
PS. @Kudo I wonder whether it's possible to use Reanimated with V8 on iOS, have you tried it?
@tomekzaw for the prebuilt AAR in reanimated 2, the v8 support commit is intentionally building from source. it would not increase the npm package size much for you.
as far as i know, there're some developers still stick on reanimated v1. they could not upgrade v3 for this purpose. that's why i was helping to add v8 support on v2.
PS. @Kudo I wonder whether it's possible to use Reanimated with V8 on iOS, have you tried it?
i did once have it but no longer maintain. v8 on ios doesn't support JIT and WebAssembly. i don't think there're strength to run v8 on ios than jsc or hermes. besides, the v8 library should disable ios Bitcode to reduce size. developers should also disable bitcode for their apps.
Is there a migration guide to move from v1 to v2? I see recommendations in the blog post to do it but I don't see it documented what got deprecated and what replaces it.
@tomekzaw for the prebuilt AAR in reanimated 2, the v8 support commit is intentionally building from source. it would not increase the npm package size much for you.
Thanks @Kudo for your answer. I wasn't aware of the fact that it builds from sources too. Do you want to keep and maintain it as a fork or shall we backport this back to v2 as well? cc @piaskowyk
v8 on ios doesn't support JIT and WebAssembly. i don't think there're strength to run v8 on ios than jsc or hermes.
That's right. I've heard that V8 has great performance on arithmetic operations (i.e. calculating animations, crypto stuff, etc.) but most likely that's thanks to JIT which is not available on iOS. Besides, I'm not sure if Apple allows running JS VMs other than JSC (or Hermes) for App Store review.
Is there a migration guide to move from v1 to v2? I see recommendations in the blog post to do it but I don't see it documented what got deprecated and what replaces it.
@shamilovtim Reanimated 1 and 2 are two completely different APIs and I'm afraid that there is no simple migration guide other than "rewrite everything using worklets". I highly encourage you to check out this post as well as other articles on SWM blog with introduction to basics of Reanimated 2 as well as numerous examples.
@tomekzaw for the prebuilt AAR in reanimated 2, the v8 support commit is intentionally building from source. it would not increase the npm package size much for you.
Thanks @Kudo for your answer. I wasn't aware of the fact that it builds from sources too. Do you want to keep and maintain it as a fork or shall we backport this back to v2 as well? cc @piaskowyk
v8 on ios doesn't support JIT and WebAssembly. i don't think there're strength to run v8 on ios than jsc or hermes.
That's right. I've heard that V8 has great performance on arithmetic operations (i.e. calculating animations, crypto stuff, etc.) but most likely that's thanks to JIT which is not available on iOS. Besides, I'm not sure if Apple allows running JS VMs other than JSC (or Hermes) for App Store review.
Is there a migration guide to move from v1 to v2? I see recommendations in the blog post to do it but I don't see it documented what got deprecated and what replaces it.
@shamilovtim Reanimated 1 and 2 are two completely different APIs and I'm afraid that there is no simple migration guide other than "rewrite everything using worklets". I highly encourage you to check out this post as well as other articles on SWM blog with introduction to basics of Reanimated 2 as well as numerous examples.
Okay thanks! Am I correct in understanding that there's no way we can reason about this migration in a way where for example "replace useCode()
with useNewHook()
" and in all cases we should start by completely deleting the v1 animation and rewriting it from the ground up using the new docs? I assume the new approach doesn't use refs and part of this migration will be removal of the ref based approach?
@shamilovtim I think it all depends on the complexity of the animation; some parts of lengthy code using Reanimated 1 API (or even DSL) doing some mathematical operations and interpolations can be easily converted to worklets (from Reanimated 2 API) where you can express the calculations elegantly in pure JS. When it comes to refs, I'm not familiar enough with Reanimated 1 to answer this question, but most likely all you need to do is to pass the result of useAnimatedStyle
hook to style
prop in Animated.View
.
Thanks @Kudo for your answer. I wasn't aware of the fact that it builds from sources too. Do you want to keep and maintain it as a fork or shall we backport this back to v2 as well? cc @piaskowyk
ideally, i would like to backport to v2 if v2 is still going to maintain for a while.
That's right. I've heard that V8 has great performance on arithmetic operations (i.e. calculating animations, crypto stuff, etc.) but most likely that's thanks to JIT which is not available on iOS. Besides, I'm not sure if Apple allows running JS VMs other than JSC (or Hermes) for App Store review.
i think most review concern for running other JS VMs on iOS is Over-The-Air updates. if no OTA there, Apple should allows for other JS VMs.
I think this can be closed right? Do the docs need to be updated