react-native-vision-camera: đ frame-processor/unavailable: Frame Processors are not enabled
What were you trying to do?
Using this + the QR scanner library for QR detection.
Reproduceable Code
import { observer } from 'mobx-react-lite'
import * as React from 'react'
import 'react-native-reanimated'
import { StyleSheet, View } from 'react-native'
import { useCameraDevices, Camera } from 'react-native-vision-camera'
import { useScanBarcodes, BarcodeFormat } from 'vision-camera-qrcode-scanner'
import { Center, Flex, Heading, Text } from 'native-base'
import { useIsFocused } from '@react-navigation/core'
import Layout from '../../components/layouts/Layout'
export const ScanScreen: React.FC = observer(({ navigation }) => {
const [hasPermission, setHasPermission] = React.useState(false)
const devices = useCameraDevices()
const device = devices.back
const isFocused = useIsFocused()
const [frameProcessor, qrCodes] = useScanBarcodes([BarcodeFormat.ALL_FORMATS])
const [isActive, setIsActive] = React.useState(isFocused)
React.useEffect(() => {
; (async () => {
const status = await Camera.requestCameraPermission()
setHasPermission(status === 'authorized')
})()
}, [])
React.useEffect(() => {
if (qrCodes.length) {
console.log(qrCodes[0])
navigation.navigate('details', { id: qrCodes[0].displayValue })
}
}, [qrCodes.length])
return (
<Layout noScroll noPadding>
<View style={styles.overlayContent}>
<Center pb={16}>
{qrCodes.map((qrCode, idx) => (
<Text key={idx} style={styles.qrCodeTextURL}>
{qrCode.displayValue}
</Text>
))}
</Center>
</View>
{device != null && hasPermission && (
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={isFocused}
frameProcessor={isFocused ? frameProcessor : undefined}
frameProcessorFps={1}
/>
)}
</Layout>
)
})
What happened instead?
frame-processor/unavailable: Frame Processors are not enabled.
The app works perfectly after a completely clean start - and after code changes (or bundle refresh) I canât use the frameProcessors function at all.
Iâm just guessing here - I disabled the assertFrameProcessorsEnabled
call in node_modules/react-native-vision-camera/src/Camera.tsx
and I get the error:
Invariant Violation: Tried to register two views with the same name CameraView, js engine: hermes
So, I can only guess (a proper guess) that this library perhaps is not tearing down views correctly, so next run they are not initialised correctly?
Iâve managed to find a temporary fix (it stopped working after a while) by making the following change:
- {device != null && hasPermission && (
+ {device != null && hasPermission && isFocused && (
Relevant log output
No response
Device
OnePlus 7 Pro (Android 12)
VisionCamera Version
2.9.4
Additional information
- I am using Expo
- 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 52 (7 by maintainers)
Just close debugger mode on android
Finally, I resolved this by upgrading my emulator SDK version to 31.
I have finally solve this issue. For today the latest version of react-native-reanimated is â3.0.2â, this is not compatible with latest version of react-native-camera. Using version
"react-native-reanimated": "^2.10.0"
solved the issue for me after deleting yarn.lock file and thenyarn install
again.any solutions so far , am still facing this issue in both IOS and Android
this is my package.json looks like :
still breaking in IOS 17. error saying âframeProcesssor not enabledâ.
please help me to resolve this.
FYI : I have tried all the solutions provided by other folks
Please see if #691 fixes the issue for you guys đ
Iâm getting this same error running in debug on Android emulatorâŠ
@mrousavy im using ubuntu, just installing the package and did changes in android manifest and other files given in docs.
for Android It wonât work at all. To reproduce the issue just create one app and install the package. thatâs all, one will get this error.
Hm, okay thatâs a separate concurrency issue. will take a look soon
If anyone is still facing this issue after changing âreact-native-reanimatedâ version to 2.10.0, it is most likely because you are using a package like Firebase that requires use_frameworks! :linkage => :static. You need specify the build types for RNReanimated and Vision camera. Add the block below to your pod file and it should work.
pre_install do |installer| installer.pod_targets.each do |pod| if pod.name.eql?(âRNReanimatedâ) || pod.name.eql?(âVisionCameraâ) def pod.build_type Pod::BuildType.static_library end end end end
Facing the same issue, by when this PR will be merged?
Hi!
Iâve spent several hours working to resolve this issue with the react-native-vision-camera package đ·. Iâd like to share the potential solution Iâve found. Hereâs a step-by-step guide:
react-native-vision-camera: 2.15.2 react-native-reanimated: 2.17.0 vision-camera-code-scanner: 0.2.0 react-dom: ^18.2.0 react-native: 0.70.6
cd android && ./gradlew clean
yarn cache clean && yarn run android
rm -rf ios/build
Additional Cleanup: For a thorough cleanup, consider these steps:
đ§© Frame Processors are now enabled with these changes!
As a guiding note for future endeavors, for those starting new projects, I highly recommend using react-native-vision-camera version 3. This updated version offers enhanced features, better stability, and consistent support.
Furthermore, a special shoutout to mrousavy is essential. The development and enhancement of react-native-vision-camera have been monumental for the React Native community. Thank you, mrousavy, for your dedication and for arming developers with such invaluable tools.
Greetings!
After upgrade to âreact-nativeâ: â0.70.6â, the problem is still happeningâŠ
I canât get away from this âframe-processor/unavailable: Frame Processors are not enabledâ error.
While building, it seems to log that âframe processors are enabled!â
So Iâm not sure why it is throwing this error. I cannot use the âframeProcessorâ prop on Camera.
@mrousavy almost!
I no longer experience the original issue on reload, however navigating away from the screen that uses frame processors gives me
com.mrousavy.camera.ViewNotfoundError: [system/view-not-found] The given view (ID 12429) was not found in the view manager
I tried nuking node_modules & gradlew clean and no change.
Ah, this is a race condition in the C++ view finder part. (
findViewById
, called on JS Thread through JNI, so C++ -> JS -> C++)I have tried several times to fix this issue, but all of those times turned into long nights of debugging and after the morning light started to shine through my window I didnât want to spend more time on it. If you are interested in posting a bug bounty on the issue, let me know and me and my guys in my agency can look at this issue in greater detail to fix it once and for all.
@DeepikaSharma5 The solution that worked for me was.
Here is the sample code for better understanding
Not working code :-
<Container> {isFocused && <Camera ref={cameraRef} photo={true} isActive={true} device={device} style={StyleSheet.absoluteFill} video={true} audio={true} enableZoomGesture={true} />} </Container>
Working Code part :-
const isFocused = useIsFocused(); <Container> {isFocused && <Camera ref={cameraRef} photo={true} isActive={isFocused} device={device} style={StyleSheet.absoluteFill} video={true} audio={true} enableZoomGesture={true} />} </Container>
Not using Chrome debugger - doesnât work with [insert package that I forget now] so Iâve been using flipper when required, but this occurs if flipper is connected or not.
Disabling fast refresh did not fix the issue if it already occurs. Tried this too:
react-native run-android
) on deviceyarn install && yarn start --reset-cache
Exception in HostFunction: com.mrousavy.camera.ViewNotFoundError: [system/view-not-found] The given view (ID 2559) was not found in the view manager.
frame processors are not enabled
Hope this helps somewhat!
Are you sure that youâre not using some remote debugger such as Chrome? It makes me wonder that the JSI functions are missing. Or maybe you are using fast-refresh and that breaks?
Can you reproduce the error if you simply open the app on your phone, without any debugger attached, and navigate through screens without fast-refresh or hot-reload?
Still breaking on iOS 17. Please help!
@w4t3r-45 Thank you, I will try your solution.
âreact-nativeâ: â0.71.13â, âreact-native-reanimatedâ: â^3.5.4â, âreact-native-vision-cameraâ: â^2.16.1â,
It worked for me, and I didnât need to update reanimated, just add this line in the Podfile
I stopped debugging by chrome and instantly the error went away so it worked for me
Hey @emaxedon I am facing same issue on the development build on my device (One Plus 9r). Surprisingly its working on my emulator . How do i solve this problem? PS - I am relatively new to react-native
My camerascreen code - `import { Button, StyleSheet, Text, View ,TouchableOpacity} from âreact-nativeâ; import { StatusBar } from âexpo-status-barâ; import * as MediaLibrary from âexpo-media-libraryâ; import * as Permissions from âexpo-permissionsâ; import { useRef, useState, useEffect } from âreactâ; import styles from ââŠ/stylesâ; import { Ionicons } from â@expo/vector-iconsâ; import { useIsFocused } from â@react-navigation/nativeâ; import {useCameraDevices,Camera,CameraPermissionStatus,frameRateIncluded,useFrameProcessor} from âreact-native-vision-cameraâ; import { examplePlugin } from â./frame-Processors/ExamplePluginâ; import {useFrameCallback} from âreact-native-reanimatedâ;
export default function CameraScreen({ navigation }) { const [cameraDevice, setCameraDevice] = useState(âbackâ); const [recording, setRecording] = useState(false); const [flash, setFlash] = useState(âoffâ); const [cameraPermission, setCameraPermission] = useState<CameraPermissionStatus>(); const [microphonePermission, setMicrophonePermission] = useState<CameraPermissionStatus>()
const cameraRef = useRef<typeof Camera>(Camera) const isFocused = useIsFocused(); const devices = useCameraDevices();
var device = devices[cameraDevice];
const frameProcessor = useFrameProcessor((frame) => { âworkletâ; const values = examplePlugin(frame); console.log(
Return Values: ${JSON.stringify(values)}
); }, []);useEffect(() => { Camera.getCameraPermissionStatus().then(setCameraPermission); Camera.getMicrophonePermissionStatus().then(setMicrophonePermission); if (cameraPermission!=âauthorizedâ){ Camera.requestCameraPermission().then(setCameraPermission); } if (microphonePermission!=âauthorizedâ){ Camera.requestMicrophonePermission().then(setMicrophonePermission); } }, [setCameraPermission,setMicrophonePermission]);
console.log(
Re-rendering Navigator. Camera: ${cameraPermission} | Microphone: ${microphonePermission}
);if (!device) { return null; }
async function toggleCameraType(){ await setCameraDevice(cameraDevice => (cameraDevice==âbackâ?âfrontâ:âbackâ)) device = devices[cameraDevice]; }
function startRecording(){ try { if (cameraRef.current == null) throw new Error(âCamera ref is null!â);
} async function stopRecording (){ console.log(âRecording Stopped!â) await cameraRef.current?.stopRecording() } function manageFlash(){ if(!device.hasFlash){ alert(âCamera does not has flashâ); } console.log(flash) setFlash(flash => (flash===âonâ?flash=âoffâ:flash=âonâ)) }
return ( <View style={{flex:1}}> {/* {isFocused && hasPermission && ( */} <Camera ref = {cameraRef} photo={true} isActive={isFocused} device={device} whiteBalance=âautoâ type=âbackâ style={StyleSheet.absoluteFill} video ={true} audio ={true} enableZoomGesture={true} frameProcessor={device.supportsParallelVideoProcessing ? frameProcessor : undefined} frameProcessorFps={60}
); } `
Example plugin -
`/* global __example_plugin __example_plugin_swift */ import type { Frame } from âreact-native-vision-cameraâ;
declare let _WORKLET: true | undefined;
export function examplePluginSwift(frame: Frame): string[] { âworkletâ; if (!_WORKLET) throw new Error(âexamplePluginSwift must be called from a frame processor!â);
// @ts-expect-error because this function is dynamically injected by VisionCamera return __example_plugin_swift(frame, âhello!â, âparameter2â, true, 42, { test: 0, second: âtestâ }, [âanother testâ, 5]); }
export function examplePlugin(frame: Frame): string[] { âworkletâ; if (!_WORKLET) throw new Error(âexamplePlugin must be called from a frame processor!â);
// @ts-expect-error because this function is dynamically injected by VisionCamera return __example_plugin(frame, âhello!â, âparameter2â, true, 42, { test: 0, second: âtestâ }, [âanother testâ, 5]); }`
Bable.config.json -
module.exports = function(api) { api.cache(true); return { presets: ['babel-preset-expo'], plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__example_plugin', '__example_plugin_swift'], }, ] ] }; };
Error that i get on console is
ERROR frame-processor/unavailable: Frame Processors are not enabled. See https://mrousavy.github.io/react-native-vision-camera/docs/guides/troubleshooting ERROR Your app just crashed. See the error below. java.lang.UnsatisfiedLinkError: No implementation found for void com.mrousavy.camera.CameraView.frameProcessorCallback(androidx.camera.core.ImageProxy) (tried Java_com_mrousavy_camera_CameraView_frameProcessorCallback and Java_com_mrousavy_camera_CameraView_frameProcessorCallback__Landroidx_camera_core_ImageProxy_2) com.mrousavy.camera.CameraView.frameProcessorCallback(Native Method) com.mrousavy.camera.CameraView.configureSession$lambda-7$lambda-6(CameraView.kt:491) com.mrousavy.camera.CameraView.$r8$lambda$cqtIchEZdTZaV3R0UUrDpVbB1Es(Unknown Source:0) com.mrousavy.camera.CameraView$$ExternalSyntheticLambda1.analyze(Unknown Source:2) androidx.camera.core.ImageAnalysis.lambda$setAnalyzer$2(ImageAnalysis.java:463) androidx.camera.core.ImageAnalysis$$ExternalSyntheticLambda0.analyze(Unknown Source:2) androidx.camera.core.ImageAnalysisAbstractAnalyzer.lambda$analyzeImage$0$androidx-camera-core-ImageAnalysisAbstractAnalyzer(ImageAnalysisAbstractAnalyzer.java:283) androidx.camera.core.ImageAnalysisAbstractAnalyzer$$ExternalSyntheticLambda1.run(Unknown Source:14) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) java.lang.Thread.run(Thread.java:923)