-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
π bugSomething isn't workingSomething isn't working
Description
What's happening?
Hey guys! I need to update a shared value from JS to the worklet code running on the useFrameProcessor function but it never updates the code on the worklet side but only on the JS side. How can I properly update the shared value to keep it in sync? I've tried using the useSharedValue from react-native-worklets-core but sometimes crashes somehow and i is also slower. Sorry guys I'm getting too confused working with worklets.
Note: If I add on the useFrameProcessor deep a reactive value like useState it works and I'm able to read the updated value. Just wondering, is it a faster way?
Appreciate any help!
Reproduceable Code
import { useSharedValue } from "react-native-reanimated";
const [update, setUpdate] = useState(false);
const groupOfLinesShared = useSharedValue<number[][] | null>(null);
useEffect(() => {
const process = async () => {
groupOfLinesShared.value = [...groupOfLinesShared.value || [], [2]];
setUpdate(a => !a);
};
process();
setInterval(() => {
process();
}, 3000);
}, []);
const frameProcessor = useFrameProcessor(
async (frame) => {
"worklet";
console.log('[WORKLET] groupOfLinesShared.value', groupOfLinesShared.value);
// Here I pretend to get the updated groupOfLinesShared value but the only way is to update the deep of this processor.
// If I remove the `update` it won't refresh.
}, [update]);
return (
<View style={StyleSheet.absoluteFill}>
<Camera
style={StyleSheet.absoluteFill}
video
device={device}
ref={camera}
// isActive={isCameraActive}
isActive
frameProcessor={frameProcessor}
format={compatibleFormat}
zoom={params.zoom || 1}
fps={FPS_VALUE}
outputOrientation="device"
/>
</View>Relevant log output
LOG [WORKLET] groupOfLinesShared.value nullCamera Device
{
"neutralZoom": 1,
"supportsRawCapture": false,
"formats": [],
"supportsLowLightBoost": false,
"hardwareLevel": "full",
"minExposure": -8,
"position": "back",
"hasFlash": true,
"minZoom": 1,
"physicalDevices": [
"wide-angle-camera"
],
"id": "com.apple.avfoundation.avcapturedevice.built-in_video:0",
"hasTorch": true,
"maxExposure": 8,
"sensorOrientation": "portrait",
"minFocusDistance": 20,
"maxZoom": 123.75,
"isMultiCam": false,
"supportsFocus": true,
"name": "Back Camera"
}Device
Iphone 15 Pro
VisionCamera Version
4.7.2
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information
- I am using Expo
- I have enabled Frame Processors (react-native-worklets-core)
- I have read the Troubleshooting Guide
- I agree to follow this project's Code of Conduct
- I searched for similar issues in this repository and found none.
Metadata
Metadata
Assignees
Labels
π bugSomething isn't workingSomething isn't working