mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.35k stars 1.07k forks source link

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

Closed bglgwyng closed 5 months ago

bglgwyng commented 9 months ago

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 commented 9 months ago

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

mrousavy commented 8 months ago

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 commented 8 months ago

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

bglgwyng commented 8 months ago

Yes, the problem still exists.

mrousavy commented 8 months ago

From a post in the apple developer forums:

Screenshot 2024-01-22 at 09 19 50

mrousavy commented 8 months ago

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?

bglgwyng commented 8 months ago

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

mrousavy commented 8 months ago

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.

frenbergFNX commented 7 months ago

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?

mrousavy commented 7 months ago

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

mrousavy commented 5 months ago

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;