Fix Center Stage crash - set control mode to .app before enabling

AVCaptureDevice.centerStageControlMode must be .app (not .user) before
we can programmatically set isCenterStageEnabled. When mode is .user,
only the user can toggle it via Control Center.
This commit is contained in:
Matt Bruce 2026-01-04 15:27:11 -06:00
parent 56890cb519
commit 564d2107ea
2 changed files with 25 additions and 6 deletions

View File

@ -338,16 +338,25 @@ struct CustomCameraScreen: MCameraScreen {
private func applyCenterStage(_ enabled: Bool) {
// Center Stage is a system-wide setting on AVCaptureDevice
// Only available on devices with Ultra Wide front camera (iPhone 11+, iPad Pro 2021+)
guard AVCaptureDevice.isCenterStageEnabled != enabled else { return }
// Check if Center Stage is supported
if let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front),
device.activeFormat.isCenterStageSupported {
AVCaptureDevice.isCenterStageEnabled = enabled
Design.debugLog("Center Stage set to \(enabled)")
} else {
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front),
device.activeFormat.isCenterStageSupported else {
Design.debugLog("Center Stage not supported on this device")
return
}
// Must set control mode to .app before we can programmatically control Center Stage
// When mode is .user, only the user can toggle via Control Center
if AVCaptureDevice.centerStageControlMode != .app {
AVCaptureDevice.centerStageControlMode = .app
Design.debugLog("Center Stage control mode set to .app")
}
guard AVCaptureDevice.isCenterStageEnabled != enabled else { return }
AVCaptureDevice.isCenterStageEnabled = enabled
Design.debugLog("Center Stage set to \(enabled)")
}
// MARK: - Skin Smoothing

View File

@ -627,6 +627,7 @@
},
"Captured photo" : {
"comment" : "A label describing a captured photo.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -651,6 +652,7 @@
},
"Captured video" : {
"comment" : "A label describing a captured video.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -769,6 +771,7 @@
},
"Close preview" : {
"comment" : "A button label that closes the preview screen.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -1249,6 +1252,7 @@
},
"Front Flash" : {
"comment" : "Title of a toggle in the Settings view that controls whether the front flash is enabled.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -1397,6 +1401,7 @@
},
"Hide preview during capture for flash effect" : {
"comment" : "Text displayed in a toggle within the \"Camera Controls\" section, allowing the user to enable or disable the feature of hiding the camera preview during a photo capture to simulate a flash effect.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -1929,6 +1934,7 @@
},
"Retake" : {
"comment" : "Title for a button that allows the user to retake a captured photo or video.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -2119,6 +2125,7 @@
},
"Save" : {
"comment" : "Title for a button that saves the currently captured photo or video to the user's photo library.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -2143,6 +2150,7 @@
},
"Saved to Photos" : {
"comment" : "Text shown as a toast message when a photo is successfully saved to Photos.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -2359,6 +2367,7 @@
},
"Share" : {
"comment" : "Title for a button that shares the captured media.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {
@ -3031,6 +3040,7 @@
},
"Uses screen flash when taking front camera photos" : {
"comment" : "A toggle that enables or disables the use of the front camera's flash during photo captures.",
"extractionState" : "stale",
"isCommentAutoGenerated" : true,
"localizations" : {
"es-MX" : {