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

🐛 camera crashes when implementing tap to focus #1396

Closed
4 tasks done
rynell-lee opened this issue Dec 22, 2022 · 6 comments · Fixed by #1466
Closed
4 tasks done

🐛 camera crashes when implementing tap to focus #1396

rynell-lee opened this issue Dec 22, 2022 · 6 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@rynell-lee
Copy link

What were you trying to do?

I am trying to implement tap to focus feature using the focus feature and react-native-gesture-handler tap gesture function.

Reproduceable Code

const singleTap = Gesture.Tap()
    .maxDuration(250)
    .onStart(async (event: TapGestureHandlerEventPayload) => {
      // console.log(event);
      let point: Point = {
        x: event.x,
        y: event.y,
      };
      console.log(point);
      try {
        cameraRef.current?.focus(point);
      } catch (err) {
        console.error(err);
      }
    });

<GestureDetector gesture={Gesture.Exclusive(singleTap)}>
        <Camera
          ref={cameraRef}
          style={StyleSheet.absoluteFill}
          device={device}
          isActive={isAppForeground}
          preset="high"
          video={true}
          audio={true}
          enableZoomGesture={true}
          onInitialized={() => SetReady(true)}
          onError={(error) => {
            console.log(error);
          }}
        />
      </GestureDetector>

What happened instead?

I am able to log out the x and y coordinates showing that the tap function works, however when I implemented the focus function my camera immediately crashes. I tried catching the error but it was not logged out.

Relevant log output

No response

Device

Samsung Galaxy tab S8 (Android 12)

VisionCamera Version

2.15.2

Additional information

@rynell-lee rynell-lee added the 🐛 bug Something isn't working label Dec 22, 2022
@demsr
Copy link

demsr commented Dec 22, 2022

@rynell-lee please make sure your device supports focus

@rynell-lee
Copy link
Author

@rynell-lee please make sure your device supports focus

image

@demsr my device supports focus!

@guiac
Copy link

guiac commented Jan 6, 2023

same here. any solution?

@demsr
Copy link

demsr commented Jan 9, 2023

@guiac @rynell-lee Can you one of you provide a minimal (not) working example and push it to github? I can only check on ios though

@myselfuser1
Copy link

@mrousavy
Copy link
Owner

Hey! I've rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.

I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?

Here's an instruction on how you can test that: #1674 (comment)

If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉
Otherwise please let me know and I'll keep this issue open to keep track of it.

Thank you!

@mrousavy
Copy link
Owner

Ohh actually I think in that PR I forgot to add touchToFocus, so I still need to implement that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants