react-native-vision-camera
react-native-vision-camera copied to clipboard
🐛 In production, runAsync does not work inside a useSkiaFrameProcessor
What's happening?
Hello,
I found that, in production (with TestFlight for iOS or downloading the signed Android bundle), the code inside myWorklet
will never be called (it works at develop time):
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet'
frame.render();
runAsync(frame, () => {
'worklet'
// Do something with heavy ML frame processor plugin
myWorklet(frame);
})
}, [ myWorklet ]);
const myWorklet = Worklets.createRunOnJS((frame: Frame) => {
// Do something here...
}
Instead, using runAtTargetFps
it works:
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet'
frame.render();
runAtTargetFps(2, () => {
'worklet'
// Do something with heavy ML frame processor plugin
myWorklet(frame);
})
}, [ myWorklet ]);
const myWorklet = Worklets.createRunOnJS((frame: Frame) => {
// Do something here...
}
Here the package.json
"dependencies": {
"@shopify/react-native-skia": "1.3.10",
"expo": "~51.0.18",
"react": "18.2.0",
"react-native": "0.74.4",
"react-native-reanimated": "~3.14.0",
"react-native-vision-camera": "^4.5.1",
"react-native-worklets-core": "^1.3.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.14",
"typescript": "~5.3.3"
}
Reproduceable Code
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet'
frame.render();
runAsync(frame, () => {
'worklet'
// Do something with heavy ML frame processor plugin
myWorklet(frame);
})
}, [ myWorklet ]);
const myWorklet = Worklets.createRunOnJS((frame: Frame) => {
// Do something here...
}
Relevant log output
--------- beginning of main
2024-08-06 10:03:21.435 20304-20304 VisionCameraProxy com.giuseppe.ravida.appname D Finding view 1295...
2024-08-06 10:03:21.435 20304-20304 VisionCameraProxy com.giuseppe.ravida.appname D Found view 1295!
2024-08-06 10:03:21.448 20304-20304 VisionCameraProxy com.giuseppe.ravida.appname D Finding view 1295...
2024-08-06 10:03:21.448 20304-20304 VisionCameraProxy com.giuseppe.ravida.appname D Found view 1295!
2024-08-06 10:03:22.534 20304-20304 VisionCameraProxy com.giuseppe.ravida.appname D Finding view 1295...
2024-08-06 10:03:22.534 20304-20304 VisionCameraProxy com.giuseppe.ravida.appname D Found view 1295!
Camera Device
{
"formats": [],
"sensorOrientation": "landscape-left",
"hardwareLevel": "full",
"maxZoom": 8,
"minZoom": 1,
"maxExposure": 24,
"supportsLowLightBoost": false,
"neutralZoom": 1,
"physicalDevices": [
"wide-angle-camera"
],
"supportsFocus": true,
"supportsRawCapture": false,
"isMultiCam": false,
"minFocusDistance": 0,
"minExposure": -24,
"name": "0 (BACK) androidx.camera.camera2",
"hasFlash": true,
"hasTorch": true,
"position": "back",
"id": "0"
}
Device
iPhone 8 plus, iPhone 15 Pro Max, Redmi Note 7
VisionCamera Version
4.5.1
Can you reproduce this issue in the VisionCamera Example app?
No, I cannot reproduce the issue in the Example app
Additional information
- [X] I am using Expo
- [X] I have enabled Frame Processors (react-native-worklets-core)
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.