From 3c845ed4b03240dee19eb5d7041b8549ab68578d Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Sat, 28 Aug 2021 14:14:16 +0200 Subject: [PATCH] fix: Fix app hard-crashing when FPS value is not supported (#391) --- ios/CameraView+AVCaptureSession.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ios/CameraView+AVCaptureSession.swift b/ios/CameraView+AVCaptureSession.swift index 7f6b35c..2d972a8 100644 --- a/ios/CameraView+AVCaptureSession.swift +++ b/ios/CameraView+AVCaptureSession.swift @@ -160,6 +160,14 @@ extension CameraView { try device.lockForConfiguration() if let fps = self.fps?.int32Value { + let supportsGivenFps = device.activeFormat.videoSupportedFrameRateRanges.contains { range in + return range.includes(fps: Double(fps)) + } + if !supportsGivenFps { + invokeOnError(.format(.invalidFps(fps: Int(fps)))) + return + } + let duration = CMTimeMake(value: 1, timescale: fps) device.activeVideoMinFrameDuration = duration device.activeVideoMaxFrameDuration = duration