software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.66k stars 1.27k forks source link

Application crash when using transformOrigin in useAnimatedStyle #5895

Open gvsboy opened 3 months ago

gvsboy commented 3 months ago

Description

When using transformOrigin in useAnimatedStyle, the application crashes with the following error: ReanimatedError: Exception in HostFunction: <unknown>, js engine: reanimated

Simulator Screenshot - iPhone 12 - 2024-04-13 at 20 49 10

I see one related issue (#5726) but it is closed so I decided to open a new issue with more details.

Steps to reproduce

I've provided a Snack link so you can reproduce:

  1. Open the Snack link
  2. Click on iOS
  3. The application loads
  4. Hold down option and drag on the ball to simulate a pinch. The app should crash immediately.

Snack or a link to a repository

https://snack.expo.dev/@gvsboy/reanimated-crash-demo

Reanimated version

3.8.1

React Native version

0.73.6

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

iPhone 12

Acknowledgements

Yes

gmartpad commented 2 months ago

Any update?

szydlovsky commented 2 months ago

@gmartpad working on it 🫡

a-eid commented 2 months ago

We're having the same issue, not sure if it was working in previous versions of reanimated.

alexdukeb commented 1 month ago

Hello everyone,

I recently encountered the same app crash issue (using version ^3.11.0) and was attempting to set a string value for the transformOrigin property, similar to your approach.

Here's the code that resolved the issue for me:

const animatedStyle = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }], transformOrigin: [originX.value, originY.value, 0], }));

As you can see, the transformOrigin is set as an array containing the x and y values, along with a 0 for the depth (optional). You can also use strings for percentage values within the array.

Hope this helps!

szydlovsky commented 1 month ago

@alexdukeb this is great news, thank you for the workaround idea! Nevertheless, all the possible values of transformOrigin should be usable so it's not the end of the issue 😄