Kudo / react-native-v8

Opt-in V8 runtime for React Native Android
MIT License
921 stars 69 forks source link

Support react native reanimated 2 #64

Open tamacroft opened 3 years ago

tamacroft commented 3 years ago

is this lib support react native reanimated 2 which is required to use hermes in their documentation?

Kudo commented 3 years ago

reanimated2 creates a Hermes runtime in there code, the only way to support V8 should be patch reanimated2 and build from source unfortunately.

hanhailong commented 3 years ago

@Kudo When I switched the engine to V8,there was an error in reanimated2,this means that just switching engine code is not enough

piaskowyk commented 3 years ago

Hey @Kudo I have tried to add support for V8 runtime in Reanimated, but I found an issue. When I call a function with callWithThis() this doesn't set jsThis property. This happens exactly in this line: https://github.com/software-mansion/react-native-reanimated/blob/%40piaskowyk/flipper/Common/cpp/SharedItems/MutableValue.cpp#L46 This code works on Hermes and JSC without problems. Maybe you know a quick answer or suggest why? If not I can try to debug it and provide more information.

mkilburn60 commented 2 years ago

@piaskowyk now that callWithThis is fixed is there a possibility to get Reanimated working with V8?

Kudo commented 2 years ago

before reanimated support building from source, i had forked reanimated and add v8 support in https://github.com/Kudo/react-native-reanimated/commit/4b069950c4b75b836350b1803485819939ce632b

to those you would like to try react-native-v8 + reanimated, here is a one step how: yarn add react-native-reanimated@npm:react-native-reanimated-v8@2.2.2

egueiros commented 2 years ago

@Kudo I'm getting this error when trying to build for Android: Transform's input file does not exist: /Users/.../node_modules/react-native-reanimated/android/react-native-reanimated-66-v8.aar. (See https://issuetracker.google.com/issues/158753935)

What did I miss? Thank you!

egueiros commented 2 years ago

@Kudo I'm getting this error when trying to build for Android: Transform's input file does not exist: /Users/.../node_modules/react-native-reanimated/android/react-native-reanimated-66-v8.aar. (See https://issuetracker.google.com/issues/158753935)

What did I miss? Thank you!

Oh, I think it's because I'm using RN 0.66.1 🤦‍♂️ I see 64-v8.aar and 65-v8.aar.

samjayhk commented 2 years ago

@Kudo Could you help to add 0.66 support? Thanks!

gpbaculio commented 2 years ago

This simple animation crashes on Android Animated.View :(

 const goesDown = useSharedValue(false);

  const progress = useSharedValue(0);

  useEffect(() => {
    progress.value = withRepeat(
      withTiming(1, { duration: 1000 }, () => {
        goesDown.value = !goesDown.value;
      }),
      -1,
      true,
    );
  }, []);
  const smallCircle = useAnimatedStyle(() => {
    // const width =  Pixel(24)
    // const top = Pixel(1)
    'worklet';
    const scale = interpolate(progress.value, [0, 1], [0, 1]);
    return {
      transform: [{ scale }],
      height: 30,
      width: 30,
      backgroundColor: 'red',
      borderColor: 'green',
      borderRadius: 15,
      borderWidth: 1,
      alignSelf: 'center',
      position: 'relative',
      top: 10,
    };
  });
Kudo commented 2 years ago

@gpbaculio could you help to try the new approach for v8 + reanimated? it's not merged from reanimated but you can still preview by installing the node package from github. i use the new approach with your example code, it works for me 🤔

gpbaculio commented 2 years ago

@Kudo seems the new approach works on the sample, but trying to add it on my current project does not. I get this error:

was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/glendonphilippbaculio/Desktop/marketplace-app/node_modules/react-native-reanimated/lib/Animated.js. Indeed, none of these files exist

it works if i import like "react-native-reanimated/src/Animated"