Skip to content

Conversation

@herarya
Copy link

@herarya herarya commented Dec 3, 2025

Fix iPhone 17 Pro/Pro Max crashes app when capturePhoto

What

This PR fixes a crash on iPhone 17 Pro and Pro Max devices when attempting to capture photos. The crash was caused by calling AVCapturePhotoOutput.capturePhoto(with:delegate:) when the video connection was not yet active or enabled, resulting in the error: "No active and enabled video connection".

Changes

  • Added readiness check to ensure AVCaptureSession.isRunning is true before attempting photo capture
  • Added validation to verify the video connection is both enabled and active before capture
  • Implemented auto-repair logic that re-adds AVCapturePhotoOutput and resets the session preset when the video connection is not ready
  • Added polling mechanism (max 0.5s, 50ms intervals) to handle timing races after session reconfiguration
  • Session automatically starts if not running, with a brief wait period (200ms) for initialization

Tested on

  • iPhone 17 Pro, iOS 26.x (verified fix works as expected)
Tested-iphone17pro.mp4
  • iPhone 16 verified
  • iPhone 17 verified

Related issues

Fix Phone 17 Pro/Pro Max crashes app when capturePhoto
@vercel
Copy link

vercel bot commented Dec 3, 2025

@herarya is attempting to deploy a commit to the mrousavy's Team Team on Vercel.

A member of the Team first needs to authorize it.

@pouyaemami
Copy link

We just tried this and it looks promising but we are still seeing a greyed out video feed when taking a picture the first time around:
Screenshot 2025-12-03 at 15 39 35

When a picture is taken and we go back to the camera to re-take another one, the image looks right:
Screenshot 2025-12-03 at 15 39 52

@Tebrynn
Copy link

Tebrynn commented Dec 5, 2025

I've got same problem. Grayed image and crash when take photo.

MikaelAmborn added a commit to MikaelAmborn/react-native-vision-camera that referenced this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants