Skip to content

Crash when using external camera on iPad (unsupported frame rate) #1904

@shogo4405

Description

@shogo4405

Discussed in #1903

Originally posted by noho501 April 10, 2026

Question

Could you please help take a look and let me know if there might be anything incorrect in my setup? The app crashes when setting the frame rate for an external camera, even though HaishinKit already checks isFrameRateSupported.

These crashes are observed in Firebase Crashlytics and occur quite frequently. I’ve included one representative example above, but there are many similar cases with different supported FPS ranges.

Fatal Exception: NSInvalidArgumentException
*** -[AVCaptureDevice setActiveVideoMinFrameDuration:]
Unsupported frame duration - Supported ranges: ( "<AVFrameRateRange: 30 - 30>" ),
tried to set maxFrameRate to 24.000000

0  CoreFoundation   __exceptionPreprocess
1  libobjc.A.dylib  objc_exception_throw
2  AVFCapture       -[AVCaptureFigVideoDevice setActiveVideoMinFrameDuration:]
3  myliveapp          VideoDeviceUnit.setFrameRate(_:) (VideoDeviceUnit.swift:117)
4  myliveapp          CameraLiveStreamVC.setupCamera()
5  myliveapp          MediaMixer.configuration(video:)

Here is my code:

do {
    // Sets to input frameRate.
    try? await mixer.configuration(video: 0) { video in
        do {
            try video.setFrameRate(Float64(videoFrame.fps))
        } catch {
            logger.error(error)
        }
        
        guard let device = video.device else { return }
        try device.lockForConfiguration()
        device.ramp(toVideoZoomFactor: zoomFactor, withRate: 5.0)
        device.unlockForConfiguration()
    }
    
    // Sets to output frameRate.
    try await mixer.setFrameRate(Float64(videoFrame.fps))
} catch {
    DispatchQueue.main.async {
        let alertController = UIAlertController(title: "Errror", message: error.localizedDescription, preferredStyle: .alert)
        alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
        self.present(alertController, animated: true, completion: nil)
    }
    logger.error(error)
}

Background / Tried Steps

  • Connected an external camera to an iPad via a Type-C capture card
  • The camera might to support fixed frame rates such as 30, 50, or 59 FPS
  • The app is configured to set a different frame rate (e.g., 24 or 60 FPS)
  • In these cases, the app sometimes crashes when applying the frame rate

Environment

Device: iPad mini (A17 Pro)
OS: iPadOS 26.3.1
External Camera (Type-C)
Crash log: Firebase Crashlytics
Haishinkit 2.2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions