-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 : V3, useSharedValue is not working with V3 #1767
Comments
I think I've been able to fix this by using Per #1466,
|
However, this presents a problem if I want to use the shared state in an animation. Reanimated doesn't recognize when changes to the state occur, so they don't trigger animation update. |
Yea |
mmm, it still doesn't work when I pass it into |
the native modules for Android and iOS is perfectly connected, it shows the values. I'm just missing the last step for drawing the overlay 😢 after it's finish I will publish this vision-camera frame processor library |
Hey! So VisionCamera V3 uses react-native-worklets-core, and react-native-reanimated uses it's own Worklets implementation, so the What you can do (and what I would suggest you to do anyways regardless of this issue) is to draw the entire overlay using @Shopify/react-native-skia. This is much faster and flexible/powerful for drawing such overlays. Use the draw callback to draw, that should also work with |
Thank you @mrousavy ! Btw, is there a type-o in the offiical docs where it says: "(Optional) If you want to use Frame Processors, you need to install react-native-worklets-core 1.0.0 or higher." I think react-native-worklets-core only goes up to version 0.2.0.. I don't see 1.0.0 ? Separately, I am still seeing the crash inside jsi::String JSCRuntime::createStringFromUtf8 calling: JSStringCreateWithUTF8CString . Do you have any tips or hints on where I can look for that? I wonder if it's because I have 0.2.0 and not 1.0.0 of react-native-worklets-core (which is no longer available on npm)? |
@mrousavy I wonder if you could share a package.json from a working setup. Curious to see what version of react-native, react-native-worklets-core, and react-native-vision-camera are all working well together. |
Package.json; the one here in And yea, you're right the docs should say 0.2.0 instead of 1.0.0. I need a reproduceable example for that |
@mrousavy thank you. that example was super helpful. I managed to get it building and running. In the end I had to:
After that, I was good to go. Thank you so much for your help. |
Oh interesting! Could you maybe send a PR to react-native-worklets-core to fix the _closure issue? Thanks! cc @chrfalch I'll close this for now, let me know if this issue is still active and we can re-open it |
just fyi, in software-mansion/react-native-reanimated#4803 we renamed |
Ah shoot haha okay yea we'll rename as well then 😅 |
Thanks for the heads up Tomasz! |
Hi,
|
Will add compat for that soon! |
I tried above thing but seems not working UI is not updating or showing |
Verify first that updating your reanimated shared value from js works , then put a console log in the Worklets.createRunInJsF to verify it has been called
|
ys function has been calling but the UI is not updating unless a hard refresh means I have to update the state value to show the block. I'm using the latest version of vision-camera |
Same, it is not working for me. @umbertoghio what version vc, wc, and reanimated are you using? edit: nevermind, got it to work. Thanks for the fix! |
@jslok may you send some snippets to make it workable? and please mention relevant versions for reanimated and vision camera and worklet-core |
vc 3.6.16 Could not save an object in useSharedValue so I had to split it up into four different ones.
|
What's happening?
hi Marc, I'm currently working on developing a
vision-camera-pose-detection
project with MLKit. I initially wrote the native code for iOS, and it connected perfectly. However, I encountered a problem when attempting to draw the overlay for the skeleton based on the keypoints.In general, I used
useSharedValue
from Reanimated V3 to pass a value.when I use
useSharedValue
I receive an error message like this:Reading from '_value' directly is only possible on the UI runtime.
I have already wrapped my JS function into a worklet, but I still get an error.
If I pass the value into
setState
it works, but it doesn't behave as expected. there is a delay, as shown in this video. this is my friend who tested it6b4e8199-3251-4d37-ac53-9990b8cdc49a.mov
"react-native-vision-camera": "^3.0.0", "react-native-worklets-core": "^0.2.0", "react-native-reanimated": "^3.4.2"
Reproduceable Code
PoseDetection.ts
Main Code:
Relevant log output
Error: Reading from `_value` directly is only possible on the UI runtime, js engine: hermes
Camera Device
No response
Device
iPhone 11 ( 15.5 )
VisionCamera Version
3.0.0
Can you reproduce this issue in the VisionCamera Example app?
Additional information
The text was updated successfully, but these errors were encountered: