Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.9.0] Error: The given view was not found in view manager🐛 #500

Closed
3 of 4 tasks
ldstein opened this issue Oct 11, 2021 · 17 comments
Closed
3 of 4 tasks

[2.9.0] Error: The given view was not found in view manager🐛 #500

ldstein opened this issue Oct 11, 2021 · 17 comments
Labels
🤖 android Issue affects the Android platform 🐛 bug Something isn't working 📢 help wanted Extra attention is needed

Comments

@ldstein
Copy link

ldstein commented Oct 11, 2021

What were you trying to do?

Build and run example App at bd46da6 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

@ldstein ldstein added the 🐛 bug Something isn't working label Oct 11, 2021
@mrousavy
Copy link
Owner

That's such an annoying bug. Can't seem to find a fix for that :(

@mrousavy mrousavy added 📢 help wanted Extra attention is needed 🤖 android Issue affects the Android platform labels Oct 11, 2021
@mrousavy
Copy link
Owner

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

@ldstein
Copy link
Author

ldstein commented Oct 13, 2021

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!

@r0b0t3d
Copy link
Contributor

r0b0t3d commented Oct 23, 2021

I'm using 2.9.3 and still see this error

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

drawing

@iAmGhost
Copy link

iAmGhost commented Oct 27, 2021

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} />
  );
}

@rusakovic
Copy link

rusakovic commented Nov 3, 2021

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!

@ldstein
Copy link
Author

ldstein commented Nov 3, 2021

I ended up having to use similar workarounds as described above.

The workaround involves deactivating or unmounting the <camera /> component before a screen transition. The logic is more or less:

  • Intercept a screen transition (via navigation, back button press or hardware back button event)
  • Cancel the transition
  • Re-render the current screen with <camera active={false} ...otherProps /> or unmount it completely.
  • Trigger the previously cancelled transition

The ViewID bug seems to only crop up when using RNVC in conjunction with screen management libraries (react-native-navigation, react-navigation, react-native-modal).

@rusakovic
Copy link

I ended up having to use similar workarounds as described above.

The workaround involves deactivating or unmounting the <camera /> component before a screen transition. The logic is more or less:

  • Intercept a screen transition (via navigation, back button press or hardware back button event)
  • Cancel the transition
  • Re-render the current screen with <camera active={false} ...otherProps /> or unmount it completely.
  • Trigger the previously cancelled transition

The ViewID bug seems to only crop up when using RNVC in conjunction with screen management libraries (react-native-navigation, react-navigation, react-native-modal).

  1. Thank you for your quick reply. So, your issue during Unmount of the camera, right?
    But you could mount the camera in modal?

Is it correct?

Because my issue, I couldn't mount the Camera in Modal.

  1. So, you move Camera to react-navigation as Modal screen, right?

@ldstein
Copy link
Author

ldstein commented Nov 3, 2021

It's been awhile. I think I only hit assertFrameProcessors error when the screen with the active camera was being transitioned away from.

Edit - Just checked my code I'm only setting active={true} and frameProcessor={processFrame} after the screen transition has completed and screen containing the camera component is in focus.

I should also mention I ended up moving away from react-navigation. Hit some compatibility issues with the alpha and beta builds of react-native-reanimated. #542 .

@iAmGhost
Copy link

iAmGhost commented Nov 4, 2021

It's been awhile. I think I only hit assertFrameProcessors error when the screen with the active camera was being transitioned away from.

I can confirm this issue only happens when frameProcessor is set.

@rusakovic

Because my issue, I couldn't mount the Camera in Modal.

Sorry for confusing, I had problem when unmounting screen but similar error so I thought it can be helpful.
It looks this happens when setting frameProcessor during animation so try to avoid it. It will be ugly but maybe setTimeout can be helped.

I'm not sure this issue should be re-opened or separated, please help us @mrousavy

@rusakovic
Copy link

rusakovic commented Nov 6, 2021

Agree.
Maybe @mrousavy could give some advices or usecases for Modal. Or how to wrap Camera correctly.
For react-native-modal I tried to use

onModalShow func () => null Called when the modal is completely visible

to activate the Camera, but it didn't help.

Update:
The issue with Modal is not with mounting of Modal. I added Button inside the Modal to open the Camera. And the issue is the same: com.mrousavy.camera.ViewNotFoundError: [system/view-not-found]

@ldstein
Copy link
Author

ldstein commented Nov 12, 2021

FWIW, here is a mimimal App demonstrating the crash with react-native-modal

This is different to my original issue which I was able to work around by avoiding mounting/unmounting during transitions.

https://github.com/ldstein/MeshCameraTest/tree/modal-test

@mrousavy
Copy link
Owner

@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.

@alexstanbury
Copy link
Contributor

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.

@rusakovic
Copy link

@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.

will be very helpful, if you could help with this issue.

@alexstanbury
Copy link
Contributor

Perhaps we need to open a new issue as this one has been closed.

@fundon
Copy link

fundon commented Feb 24, 2022

Same issue, Follow the workaround of @iAmGhost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Issue affects the Android platform 🐛 bug Something isn't working 📢 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants