You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 93eede7
Browse filesBrowse the repository at this point in the historyBrowse files
[camera]fix a crash when switching camera while recording due to disconnected capturePhotoOputput (flutter#13248)
This PR fixes one of the test failures here flutter#191202. This failure is not iOS 27 specific. However, since it requires physical device (switch between front/back camera), it is not run on our CI, so we didn't catch it.
## How was it broken
Before switching camera, the capture session has:
```
Inputs: [ backCameraInput ]
Outputs: [ captureVideoOutput, capturePhotoOutput ]
Connections:
Wire 1: backCameraInput -> captureVideoOutput (created manually via addConnection)
Wire 2: backCameraInput -> capturePhotoOutput (created automatically via addOutput)
```
When switching camera input (from back camera to front camera), we remove video input and output, but left photo output untouched. So at this point the capture session has:
```
Inputs: [ ]
Outputs: [ capturePhotoOutput ] <-- still in the session, but unplugged!
Connections: [ ] <-- both Wire 1 and Wire 2 were deleted!
```
Now when adding back the camera input, we simply do:
```
videoCaptureSession.addInputWithNoConnections(captureVideoInput)
videoCaptureSession.addOutputWithNoConnections(captureVideoOutput.avOutput)
```
So our capture session ends up with:
```
Inputs: [ frontCameraInput ]
Outputs: [ capturePhotoOutput, newVideoOutput ]
Connections:
Wire 1: frontCameraInput -> newVideoOutput
Wire 2: (MISSING! capturePhotoOutput has no wire to frontCameraInput!)
```
Then a subsequent code calls
```
capturePhotoOutput.maxPhotoDimensions = maxSupportedDimensions
```
Which throws NSInvalidArgumentException because it has no connection.
The fix is simply to use addInput rather than addInputWithNoConnections, which would automatically add the frontCameraInput -> capturePhotoOutput connection.
Fixesflutter#194344
*List which issues are fixed by this PR. You must list at least one issue.*
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Copy file name to clipboardExpand all lines: packages/camera/camera_avfoundation/darwin/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1275,7 +1275,10 @@ final class DefaultCamera: NSObject, Camera {
0 commit comments