Closed xseignard closed 6 months ago
Hey @xseignard ,
Thanks a lot for the PR. I don't quite understand why simplex-noise.js would need annotations to be used with react-native-reanimated
. It seems quite backward that a framework would require arbitrary non standard annotations in every library it is used with.
Isn't it possible to just call simplex-noise.js from a function which is annotated? The docs seem sparse but
Worklet runtimes come with performance.now and console.* methods installed out-of-the-box. Other APIs are not available and need to be injected into the runtime or captured via worklet closure. Seems to allude to the fact that dependencies can be captured in a closure. I think that would be a better way to go about this.
I would prefer not to have non-standard annotations in the code that are only relevant for a very small subset of users.
Thanks for your answer. I perfectly understand your point of view.
Unfortunately you can only call workletized function within worklets.
I'll try to find another approach to leverage your great lib in react-native projects.
Thanks for your work!
Hey Xavier,
I'd hate to give up on this just yet. There must be some sensible way to get this to work. It's just a bit hard for me to experiment without a running react native setup.
Why
react-native-reanimated
is a popular library forreact-native
to create and drive animations.See https://docs.swmansion.com/react-native-reanimated/
react-native
is running on 2 threads:react-native
code executionTo be able to run
simplex-noise
on the UI thread withreact-native-reanimated
we need to workletize the functions.You can read more here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#worklet
How
Added
"worklet"
directive where needed.Test
Tested on mobile with
react-native@0.72.6
andreact-native-reanimated@3.6.2
Impacts
react-native
users not relying onreact-native-reanimated
react-native
users relying onreact-native-reanimated
can now usesimplex-noise
to create fancy animations running at stable 60fps 🥳Good to know
Will only work with
react-native-reanimated@3.6.2+