react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

🐛 `zoom` props doesn't work properly with camera formats of specified resolution

Open bglgwyng opened this issue 2 years ago • 10 comments

What's happening?

When setting the zoom to a value other than 1 and combining it with specified camera formats and resolutions, as described in the reproducible code section, the preview results in a black screen.

Reproduceable Code

Modify the example app as

const format = useCameraFormat(device, [
  { fps: targetFps },
  { videoAspectRatio: screenAspectRatio },
  { videoResolution: { width: 1920, height: 1080 } }, // it was 'max' before
  { photoAspectRatio: screenAspectRatio },
  { photoResolution: { width: 1920, height: 1080 } }, // it was 'max' before
])

Then set zoom value as any other value than 1, for example

<Camera zoom={1.5} {...otherProps} />

Relevant log output

[unknown/unknown: Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo={NSLocalizedDescription=Cannot Complete Action, NSLocalizedRecoverySuggestion=Try again later.}]

Camera Device

{
  "supportsLowLightBoost": false,
  "isMultiCam": false,
  "hasTorch": true,
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:0",
  "sensorOrientation": "landscape-right",
  "hasFlash": true,
  "name": "Back Camera",
  "minZoom": 1,
  "supportsFocus": true,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsRawCapture": false,
  "neutralZoom": 1,
  "maxZoom": 121.875,
  "hardwareLevel": "full",
  "position": "back"
}

Device

iPhone 13 (iOS 16.6.1)

VisionCamera Version

3.6.8

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

bglgwyng avatar Dec 21 '23 05:12 bglgwyng

#2310 #2280 These issues can have the same cause. Please check if you described the camera format with specified resolution values.

bglgwyng avatar Dec 21 '23 05:12 bglgwyng

Lol, this is a fun one. I'll dig around the Apple forums to see why this is happening after I fix the Preview stretching issue - thanks for the bug report @bglgwyng !

mrousavy avatar Jan 09 '24 08:01 mrousavy

Is this still broken after https://github.com/mrousavy/react-native-vision-camera/pull/2329?

mrousavy avatar Jan 19 '24 14:01 mrousavy

Yes, the problem still exists.

bglgwyng avatar Jan 20 '24 03:01 bglgwyng

And someone on Stackoverflow said this might be the stopRunning method timing out, but we are not using that in this scenario I think (that's why the logs would've been useful and why I always ask for logs btw 😉) but yea I think we're not using stopRunning here right?

mrousavy avatar Jan 22 '24 08:01 mrousavy

@mrousavy Is this reported behavior reproduced on your device? I just tested it and I found that my previous description was a bit misleading. There's no crash and no black screen problem, but the frame rates get so low(about 1 frame in 3 seconds).

bglgwyng avatar Jan 22 '24 13:01 bglgwyng

No, I haven't seen that issue before - sorry :/

Let's keep it open tho, but honestly not sure if there's anything I can do.

mrousavy avatar Jan 22 '24 13:01 mrousavy

Lol, this is a fun one. I'll dig around the Apple forums to see why this is happening after I fix the Preview stretching issue - thanks for the bug report @bglgwyng !

Hi @mrousavy and a big thanks for the amazing job on this lib

I see you mention a Preview stretching issue that I cant find any issues about but am experiencing too on 3.8.2. Do you have any progress on that?

frenbergFNX avatar Feb 08 '24 13:02 frenbergFNX

Yes, there are like 6 issues about that and in the latest 3.9. beta release I fixed it.

mrousavy avatar Feb 08 '24 13:02 mrousavy

Hey - I think this issue has been fixed in VisionCamera 4.0.0. 🥳

Please try V4 and let me know if you still experience this issue;

  • if not, please consider 💖 sponsoring me on GitHub 💖 to support the development of VisionCamera and thank me for my time spent on fixing bugs and building new features.
  • if you still see this issue, please comment and we can re-open this. But please update your native logs with the native (Xcode/Android Studio) logs from running VisionCamera V4 so I can investigate this.

mrousavy avatar Apr 22 '24 11:04 mrousavy