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 Preview Screen Continuously Jumps Up and Down #3361

Open
3 of 5 tasks
MS0015 opened this issue Jan 12, 2025 · 1 comment
Open
3 of 5 tasks

🐛 Camera Preview Screen Continuously Jumps Up and Down #3361

MS0015 opened this issue Jan 12, 2025 · 1 comment
Labels
🐛 bug Something isn't working

Comments

@MS0015
Copy link

MS0015 commented Jan 12, 2025

What's happening?

The camera preview is unstable and continuously moves up and down during usage. This issue occurs after installing the react-native-vision-camera package.

Camera.issue.mp4

Reproduceable Code

const [flashMode, setFlashMode] = useState('off');
  const [cameraType, setCameraType] = useState('back');

  const cameraRef = React.useRef(null);
  const device = useCameraDevice(cameraType);

  const toggleFlash = () => {
    setFlashMode(prev => (prev === 'on' ? 'off' : 'on'));
  };

  const toggleCameraType = () => {
    setCameraType(prev => (prev === 'back' ? 'front' : 'back'));
  };

  const capturePhoto = async () => {
    try {
      if (cameraRef.current) {
        const photo = await cameraRef.current.takePhoto();
        const imagePath = photo.path;
        // Navigate to next screen with image path
      }
    } catch (error) {
      Toast.show({
        type: 'error',
        text1: 'Failed to capture image',
      });
    }
  };

<Camera
  ref={cameraRef}
  style={StyleSheet.absoluteFill}
  device={device}
  isActive={true}
  flash={flashMode}
  photo={true}
  enableZoomGesture={true}
  focusable={false}
  videoStabilizationMode="auto"
/>

Relevant log output

1:53:45.315 PM: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
1:53:45.316 PM: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
1:53:45.321 PM: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating

Camera Device

{
  "minZoom": 1,
  "name": "Back Camera",
  "supportsRawCapture": false,
  "hardwareLevel": "full",
  "sensorOrientation": "portrait",
  "supportsFocus": true,
  "neutralZoom": 1,
  "isMultiCam": false,
  "maxExposure": 8,
  "position": "back",
  "formats": [],
  "minExposure": -8,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "hasTorch": true,
  "minFocusDistance": 10,
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:0",
  "maxZoom": 16,
  "hasFlash": true,
  "supportsLowLightBoost": false
}

Device

iPhone 7s

VisionCamera Version

4.6.3

Can you reproduce this issue in the VisionCamera Example app?

No, I cannot reproduce the issue in the Example app

Additional information

@MS0015 MS0015 added the 🐛 bug Something isn't working label Jan 12, 2025
Copy link

maintenance-hans bot commented Jan 12, 2025

Guten Tag, Hans here! 🍻 Thank you for reporting this issue.

It looks like you have provided some good details, but we also need to check a few things to help you further. Since you mentioned that you cannot reproduce this issue in the Example app, it would be helpful to gather more information from the logs during the runtime.

Please check the logs in Xcode (or use adb logcat for Android) when you encounter this issue, and share those with us. This will help mrousavy better understand what's happening.

Have you also considered checking for any specific configurations or conflicts in your project? Make sure to review any custom code you have that might affect the camera behavior.

Looking forward to your updates!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

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

No branches or pull requests

1 participant