Closed kssgarcia closed 5 months ago
You could only run the camera if the screen is active. If the camera doesn't run, the frame processor should not either. So something like:
import { useNavigation } from 'expo-router';
...
const navigation = useNavigation();
const isScreenFocused = navigation.isFocused();
...
<Camera
...
isActive={isScreenFocused}
/>
I understood you that I should set the active
property false
when the screen is not focus, but I am already doing this,
<Camera
style={StyleSheet.absoluteFillObject}
ref={cameraRef}
device={device}
isActive={isActive}
photo={true}
format={format}
fps={fps}
orientation="portrait"
photoQualityBalance="speed"
// enableFpsGraph={true}
frameProcessor={frameProcessor}
/>
the isActive={isActive}
set this to false
when the screen is not focus or when the app is in second plane. This seems to work fine, but when I use frameProcessor={frameProcessor}
this is still running when the screen is not focus.
Strange, maybe it's a regression on a new version? In this case you could pass isActive
as a dependency of the frame processor and not run what's inside if it is false, like:
useFrameProcessor((frame) => {
if (!isActive) return;
...
}, [isActive]);
@gwendall you were right, ty. It seems that I was setting the isActive
in a wrong way. Ty man
Question
I am making an app that use expo-router, what I want to know if there is a way to disable the
useFrameProcessor
because when I go to another route the processor still is running. By the way, I am usingactive
property when I change the route. This is myCamera
component:What I tried
No response
VisionCamera Version
4.0.5
Additional information