-
-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Summary
Request support for AVFoundation's virtual camera devices (builtInTripleCamera, builtInDualWideCamera, builtInDualCamera) to enable access to ultra-wide and telephoto lenses, and proper zoom factor support below 1.0x.
Problem Statement
Currently, MijickCamera uses a single builtInWideAngleCamera device, which limits zoom functionality:
- No Ultra-Wide Access: Zoom factors below 1.0x are not supported, preventing access to the ultra-wide camera (typically 0.5x zoom)
- Limited Lens Switching: Cannot switch between physical camera lenses (ultra-wide, wide, telephoto)
- Inconsistent Zoom Behavior: Setting zoom to 0.5x gets clamped to 1.0x (the minimum for wide-angle camera)
Use Case
Modern iPhones (iPhone 11 and later) have multiple camera lenses:
- Ultra-wide (0.5x zoom factor)
- Wide (1.0x zoom factor)
- Telephoto (2x or 3x zoom factor, depending on device)
Users expect to be able to:
- Switch between these lenses using preset zoom factors
- Use pinch-to-zoom to smoothly transition between lenses
- Access the full zoom range from 0.5x to maximum digital zoom
Proposed Solution
Add support for virtual camera devices that automatically switch between physical cameras based on zoom factor:
Option 1: Automatic Virtual Device Selection
Automatically use the best available virtual device:
builtInTripleCamera(if available) - supports ultra-wide, wide, and telephotobuiltInDualWideCamera(if available) - supports ultra-wide and widebuiltInDualCamera(if available) - supports wide and telephoto- Fallback to
builtInWideAngleCamera(current behavior)
Option 2: Configurable Device Type
Add a new configuration method:
MCamera()
.setCameraDeviceType(.tripleCamera) // or .dualWide, .dual, .wideAngle
.startSession()Option 3: Automatic Based on Zoom Factor
When setZoomFactor() is called with a value < 1.0, automatically switch to a virtual device that supports it.
Technical Details
AVFoundation Virtual Devices
Virtual devices provide seamless switching between physical cameras:
// Example: Triple Camera System
let tripleCamera = AVCaptureDevice.default(
.builtInTripleCamera,
for: .video,
position: .back
)
// Zoom factors automatically switch cameras:
// 0.5x → Ultra-wide camera
// 1.0x → Wide camera
// 3.0x → Telephoto camera
let minZoom = tripleCamera.minAvailableVideoZoomFactor // Could be 0.5
let maxZoom = tripleCamera.maxAvailableVideoZoomFactor // Could be 15.0+
let switchOverFactors = tripleCamera.virtualDeviceSwitchOverVideoZoomFactorsCurrent Limitation
With single builtInWideAngleCamera:
minAvailableVideoZoomFactor= 1.0 (cannot go below)- Setting zoom to 0.5x gets clamped to 1.0x
- No access to ultra-wide or telephoto physical lenses
Benefits
- Full Camera System Access: Utilize all available camera hardware
- Better User Experience: Match native iOS Camera app behavior
- Proper Zoom Support: Support zoom factors from 0.5x to maximum
- Seamless Lens Switching: Automatic camera switching based on zoom factor
- Future-Proof: Support for new multi-camera configurations
Implementation Considerations
- Backward Compatibility: Maintain current behavior for devices without multi-camera support
- Session Management: Virtual devices may require different session configuration
- Performance: Ensure smooth transitions between cameras
- Error Handling: Gracefully handle cases where virtual device is unavailable
Related Issues
- Issue [BUG]Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value #108: Crash when using flash (may be related to single camera device limitations)
- Current zoom implementation only supports 1.0x and above
Additional Context
This feature would enable apps built with MijickCamera to:
- Provide lens switching UI (0.5x, 1x, 2x, 3x buttons)
- Support pinch-to-zoom across the full range
- Match the functionality of native iOS camera apps
- Better utilize modern iPhone camera hardware
References
- Apple Documentation: AVCaptureDevice.DeviceType
- Apple Documentation: virtualDeviceSwitchOverVideoZoomFactors
Submitted by: GreenCheckmark App Team
Date: 2026-01-25
MijickCamera Version: 3.0.3