react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Using SharedValue.set() fails with 'Tried to synchronously call a non-worklet anonymous function on the UI thread.' when mixing with `with*` helpers

Open chrisnojima opened this issue 1 year ago • 1 comments

Description

I'm switching my code from using the old style opacity.value = withDelay... to opacity.set(withDelay... but this fails. Instead it only works if i use the callback form opacity.set(() => withDelay.... Unclear if this is by design but it was definitely confusing

Steps to reproduce

  1. Update to 3.16.0
  2. use .set with a withDelay (style) helper
  3. see a red box error

Snack or a link to a repository

sorry

Reanimated version

3.16.0

React Native version

0.75.4

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

Paper (Old Architecture)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

chrisnojima avatar Oct 18 '24 14:10 chrisnojima

I'm getting the same thing

techfoundrynz avatar Oct 25 '24 01:10 techfoundrynz

I'm also wondering if this is a bug. I created a minimal reproduction repo: https://github.com/g-siedlecki/ReanimatedRepro Running React Native 0.75.4 and Reanimated 3.16.1. Tested on both iOS and Android.

g-siedlecki avatar Nov 05 '24 08:11 g-siedlecki

This shouldn't happen. I'll investigate.

tjzel avatar Nov 05 '24 12:11 tjzel

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Nov 05 '24 12:11 github-actions[bot]

We're adding set(() => ...) everywhere to work around this, seems to repro very consistently. Not sure if there's a risk that something deeper is broken and migrating to set() is actually a bad idea?

gaearon avatar Nov 15 '24 20:11 gaearon

@chrisnojima @gaearon @g-siedlecki @contactsimonwilson We have just released 3.16.2 which has a fix for that.

tjzel avatar Nov 20 '24 14:11 tjzel