-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(ios): prevent crash when capturePhoto has no active video connection #3637
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
base: main
Are you sure you want to change the base?
Conversation
- 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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Could you please approve this update? i cannot take photo on iphone17 pro |
|
Hello There, Same here...we are getting reports about this... thanks in advance |
|
+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 |
|
Running into multiple instances of this as well. Do we have an ETA or is it worth patching ourselves? |
|
I created a patch using this code. The camera on the iPhone 17 Pro now works, but the preview appears significantly darker than usual before capturing the photo. with this error: |
|
Camera is not darker on my iphone 17 pro but foggy and desaturated. |
| Takes a photo. | ||
| Captures a photo. | ||
| `takePhoto` is only available if `photo={true}`. | ||
| */ | ||
| func takePhoto(options: TakePhotoOptions, promise: Promise) { | ||
| // Run on Camera Queue | ||
| CameraQueues.cameraQueue.async { | ||
| // Get Photo Output configuration | ||
| // Validate configuration | ||
| guard let configuration = self.configuration else { | ||
| promise.reject(error: .session(.cameraNotReady)) | ||
| return | ||
| } | ||
| guard configuration.photo != .disabled else { | ||
| // User needs to enable photo={true} | ||
| promise.reject(error: .capture(.photoNotEnabled)) | ||
| return | ||
| } | ||
|
|
||
| // Check if Photo Output is available | ||
| // Validate outputs and inputs | ||
| guard let photoOutput = self.photoOutput, | ||
| let videoDeviceInput = self.videoDeviceInput else { | ||
| // Camera is not yet ready | ||
| promise.reject(error: .session(.cameraNotReady)) | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is AI - why did you (or your AI) remove/change those comments?
| path: options.path, | ||
| cameraSessionDelegate: self.delegate | ||
| ) | ||
| photoOutput.capturePhoto(with: photoSettings, delegate: photoCaptureDelegate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but this PR is way too many changes/lines for that simple of a fix.
I think all you'd need to do is add a simple guard above photoOutput.capturePhoto(with: ..., delegate: ...) to ensure the photoOutput has a valid .video connection. 3 lines of code max.
What
This PR fixes a crash on iOS devices where calling
AVCapturePhotoOutput.capturePhoto(with:delegate:) could throw:
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
Tested on
Related issues