software-mansion / react-native-reanimated

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

Allow reading & updating reanimated shared values from other workout threads #5642

Open hannojg opened 9 months ago

hannojg commented 9 months ago

Description

When trying to update a REA shared value from another workout thread, such as from react-native-worklets-core, you're getting errors, that you aren't allowed to read or update values:

Reading from `_value` directly is only possible on the UI runtime.

CleanShot 2024-02-06 at 10 33 04@2x

Steps to reproduce

  1. Setup a new react native app
  2. Install react-native-reanimated and react-native-worklets-core
  3. Setup their babel plugins
  4. In App.tsx create a new REA useSharedValue
  5. Try to update that value from a workless-core "worklet" function, such as created by Worklets.createRunInContextFn or useWorklet

Snack or a link to a repository

https://github.com/hannojg/REAandWorkletsInteropRepro

Reanimated version

3.6.2

React Native version

0.73.4

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

marcshilling commented 9 months ago

Any workarounds for this?