Skip to content

Conversation

Jeremy-Kr
Copy link

@Jeremy-Kr Jeremy-Kr commented Sep 26, 2025

What

This PR fixes a crash on iOS devices where calling
AVCapturePhotoOutput.capturePhoto(with:delegate:) could throw:

*** -[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection

The crash was caused by attempting to capture a photo when the AVCaptureSession was running but the video connection was not yet active (e.g., right after camera switch, format change, or session interruption).

Changes

  • Added a readiness check before capture:
    • Ensure AVCaptureSession.isRunning == true
    • Ensure video connection is both enabled and active
  • Added an auto-repair path:
    • Re-add AVCapturePhotoOutput inside beginConfiguration/commitConfiguration
    • Reset session preset to .photo if available
    • Restart the session if necessary
  • Added a short polling window (default 0.5s, every 50ms) to handle timing races after reconfiguration
  • Preserved existing logging (VisionLogger.log) and behavior for resolution, flash, red-eye reduction, depth data, portrait effects matte, and distortion correction.

Tested on

  • iPhone 17 Pro (iOS 18 beta) – verified crash no longer occurs when switching cameras rapidly and capturing immediately.
  • iPhone 16 Pro (iOS 26.0) - regression check, normal behavior.
  • iPhone 16 Pro (iOS 18.6) - regression check, normal behavior.
  • iPhone 16 (iOS 26.0) - regression check, normal behavior.
  • iPhone 12 Pro (iOS 16.x) – regression check, normal behavior.

Related issues

- Ensure AVCaptureSession is running and video connection is both enabled + active
- Add auto-repair: re-add AVCapturePhotoOutput inside begin/commitConfiguration
- Reset session preset to .photo if available, restart session if necessary
- Add short polling window (0.5s, 50ms interval) to handle timing races
- Preserve existing logging and behavior for resolution, flash, depth, portrait effects, and distortion correction
Copy link

vercel bot commented Sep 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-native-vision-camera Ready Ready Preview Comment Sep 26, 2025 9:03am

@Tebrynn
Copy link

Tebrynn commented Oct 9, 2025

Could you please approve this update? i cannot take photo on iphone17 pro

@FaggioniHQ
Copy link

Hello There,

Same here...we are getting reports about this... thanks in advance

@isinuyk
Copy link

isinuyk commented Oct 13, 2025

+1

When can we expect it to be merged and released?

We need to know whether to patch it or wait for the official fix

@sgiroux
Copy link

sgiroux commented Oct 14, 2025

Running into multiple instances of this as well. Do we have an ETA or is it worth patching ourselves?

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.

🐛 NSInvalidArgumentException: *** -[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection

5 participants