react-native-vision-camera: [2.9.0] Error: The given view was not found in view manageršŸ›

What were you trying to do?

Build and run example App at https://github.com/mrousavy/react-native-vision-camera/commit/bd46da614ee2f43b23eb90a71ab4c59be54fd01f on Android device.

Maybe related to #457

Build Environment: Windows 10 x64 Openjdk 11.0.10 2021-01-19 Python 2.7.18

Reproduceable Code

git clone https://github.com/mrousavy/react-native-vision-camera.git
cd react-native-vision-camera
git checkout bd46da614ee2f43b23eb90a71ab4c59be54fd01f
npx yarn
cd example
npx yarn
npx yarn android

What happened instead?

After app launches and user grants permission to Camera and Mic, red error box appears with Stack Trace:

image

Relevant log output

LOG  Running "VisionCameraExample" with {"rootTag":1}
 LOG  Re-rendering Navigator. Camera: undefined | Microphone: undefined
 LOG  Re-rendering Navigator. Camera: denied | Microphone: undefined
 LOG  Re-rendering Navigator. Camera: denied | Microphone: denied
 LOG  Requesting camera permission...
 LOG  Camera permission status: authorized
 LOG  Requesting microphone permission...
 LOG  Microphone permission status: authorized
 LOG  re-rendering camera page without active camera
 LOG  re-rendering camera page without active camera
 LOG  Re-rendering camera page with active camera. Device: "back (0)" (4000x2000 @ 60fps)
 ERROR  Error: Exception in HostFunction: com.mrousavy.camera.ViewNotFoundError: [system/view-not-found] The given view (ID 95) was not found in the view manager., js engine: hermes

Device

Pixel 3, Android 11

VisionCamera Version

2.9.0

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I’m also seeing this issue. The Camera shows fine in the React Native Modal, but when I call takePhoto I am receiving the view-not-found error.

@ldstein thank you! This is helpful. I currently don’t have the time to investigate this, but if I do, I’ll get back to this.

I’m using 2.9.3 and still see this error

Update: I am only got this error when using <Camera /> inside <Modal />

drawing

Confirm this issue, if use react-native-modal or import from react-native

Only on Android. iOS is working perfect.

"react-native-reanimated": "^2.2.4",
"react-native-modal": "^13.0.0",
"react": "17.0.2",
"react-native": "0.66.1",
"react-native-vision-camera": "^2.9.3",
"vision-camera-face-detector": "^0.1.8",

@mrousavy may you could give some suggestions, how to wrap the <Camera /> component correctly to show camera in fullscreen mode.

This info could be useful to add in documentation. To avoid potential issues.

Thank you for your great library!

Update: I am only got this error when using <Camera /> inside <Modal />

I have similar problem while using @react-navigation/native-stack. using react-native-vision-camera@2.9.3

It happens when:

  • Using Android
  • Pressing back arrow button at header left(not happening with system back button)

Workaround was adding custom back button at headerLeft that disables camera before popping screen.

Example code:

function CameraScreen() {
  const [quit, setQuit] = useState(false);
  const navigation = useNavigation();
  
  useEffect(() => {
    if (Platform.OS !== 'android') {
      return;
    }

    navigation.setOptions({
      headerLeft: () => (
        <Button
          title="Dismiss"
          onPress={() => {
            setQuit(true);
          }}
        />
      ),
    });
  }, [navigation]);

  useEffect(() => {
    if (quit) {
      navigation.goBack();
    }
  }, [navigation, quit]);

  return (
    <Camera active={!quit} />
  );
}

I’m using 2.9.3 and still see this error

Update: I am only got this error when using <Camera /> inside <Modal />

drawing

maybe #511 fixes this issue… it’s giving me headaches.

I’m a little late to the party, but happy to report #511 fixed the issue, thanks!

maybe #511 fixes this issue… it’s giving me headaches.