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.getAvailableCameraDevices() returns null on Android, physical device🐛 #1462

Closed
3 of 4 tasks
stivenm16 opened this issue Feb 8, 2023 · 5 comments · Fixed by #1466
Closed
3 of 4 tasks

Camera.getAvailableCameraDevices() returns null on Android, physical device🐛 #1462

stivenm16 opened this issue Feb 8, 2023 · 5 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@stivenm16
Copy link

What were you trying to do?

I'm trying to access to all available Camera Devices but it returns null when I'm running my app on a physical device, however when I run the code in the emulator it works fine and returns a full array with options. The phone is connected via usb. This unexpected behaviour still persist after build it

Reproduceable Code

const TestComponent = () => {
  const { navigate } = useNavigation();
 
  useEffect(() => {
    const requestPermissions = async () => {
      await Camera.requestCameraPermission();
    };
    requestPermissions();
  });


  const devices = useCameraDevices();
  const device = devices.back;

  // console.log(devices, "devices"); => it returns null on physical device

  if (device == null)
    return (
      <View>
        <Text> Device null</Text>
      </View>
    );

  return (
    <View style={{ flex: 1, backgroundColor: "red", padding: 10 }}>
      <Camera style={{ flex: 1 }} device={device} isActive={true} />
      <Text>It works</Text>
    </View>
  );
};

What happened instead?

useCameraDevices() returns null when is called on a physical device

Relevant log output

No response

Device

Silver Max lite 2

VisionCamera Version

2.15.2 - 2.15.4

Additional information

@stivenm16 stivenm16 added the 🐛 bug Something isn't working label Feb 8, 2023
@stivenm16 stivenm16 changed the title Camera.getAvailableCameraDevices() returns undefined on Android, physical device🐛 Camera.getAvailableCameraDevices() returns null on Android, physical device🐛 Feb 8, 2023
@EmiBenitez
Copy link

any news about this? I have the same problem.

@Ntouris3
Copy link

I'm facing the same issue

@chj-damon
Copy link

I tried in Smartisan which is another brand and also the devices are all undefined.

@SohaibKtb
Copy link

same for Tecno devices

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

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.

7 participants