Bug Report
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 8.4.0
@capacitor/core: 8.4.0
@capacitor/android: 8.4.0
@capacitor/ios: 8.4.0
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 8.4.0
@capacitor/core: 8.4.0
@capacitor/ios: 8.4.0
Plugin Version
@capgo/camera-preview: 8.4.7
context(s)
ManualModel: false
AutoMode: false
CapgoCloud: false
OnPremise: false
Platform(s)
iOS
Current Behavior
Starting the camera preview with the iOS cameraMode: true option crashes the app in Xcode.
Crash:
Thread 3: "*** -[AVCaptureConnection setVideoOrientation:] Not supported - use -isVideoOrientationSupported"
The crash happens in CameraController.swift in this block:
// Add video output if in camera mode
if cameraMode, let fileVideoOutput = self.fileVideoOutput, captureSession.canAddOutput(fileVideoOutput) {
captureSession.addOutput(fileVideoOutput)
// Set orientation immediately
fileVideoOutput.connections.forEach { $0.videoOrientation = videoOrientation }
}
It looks like videoOrientation is being set on every AVCaptureConnection, even though not all connections necessarily support video orientation.
Expected Behavior
The plugin should not crash when video output is attached during preview startup.
Before setting videoOrientation, the iOS implementation should check whether the connection supports it:
fileVideoOutput.connections.forEach { connection in
if connection.isVideoOrientationSupported {
connection.videoOrientation = videoOrientation
}
}
Alternatively, it should only set orientation on the actual video connection.
Code Reproduction
Minimal Capacitor usage:
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.start({
aspectRatio: '16:9',
positioning: 'center',
toBack: true,
disableAudio: false,
cameraMode: true,
});
On iOS, this reaches the native cameraMode path and crashes while setting videoOrientation on fileVideoOutput.connections.
Additional Context
The public TypeScript definitions document enableVideoMode?: boolean, but the iOS native implementation appears to read cameraMode:
let cameraMode = call.getBool("cameraMode") ?? false
and then uses it to decide whether to attach AVCaptureMovieFileOutput during preview startup.
Without cameraMode: true, recording can still work because captureVideo() has fallback logic that adds the video output later. However, using cameraMode: true currently crashes because this line does not guard isVideoOrientationSupported:
fileVideoOutput.connections.forEach { $0.videoOrientation = videoOrientation }
Bug Report
Capacitor Version
Plugin Version
context(s)
Platform(s)
iOS
Current Behavior
Starting the camera preview with the iOS
cameraMode: trueoption crashes the app in Xcode.Crash:
The crash happens in
CameraController.swiftin this block:It looks like
videoOrientationis being set on everyAVCaptureConnection, even though not all connections necessarily support video orientation.Expected Behavior
The plugin should not crash when video output is attached during preview startup.
Before setting
videoOrientation, the iOS implementation should check whether the connection supports it:Alternatively, it should only set orientation on the actual video connection.
Code Reproduction
Minimal Capacitor usage:
On iOS, this reaches the native
cameraModepath and crashes while settingvideoOrientationonfileVideoOutput.connections.Additional Context
The public TypeScript definitions document
enableVideoMode?: boolean, but the iOS native implementation appears to readcameraMode:and then uses it to decide whether to attach
AVCaptureMovieFileOutputduring preview startup.Without
cameraMode: true, recording can still work becausecaptureVideo()has fallback logic that adds the video output later. However, usingcameraMode: truecurrently crashes because this line does not guardisVideoOrientationSupported: