Skip to content

Use absolute zoom factors on iOS#76

Merged
janusw merged 4 commits intojanusw:masterfrom
jacksonjude:ios-absolute-zoom
Feb 6, 2026
Merged

Use absolute zoom factors on iOS#76
janusw merged 4 commits intojanusw:masterfrom
jacksonjude:ios-absolute-zoom

Conversation

@jacksonjude
Copy link
Copy Markdown

@jacksonjude jacksonjude commented Feb 2, 2026

This PR changes the MinAvailableVideoZoomFactor and MaxAvailableVideoZoomFactor values from relative (minimum = 1.0 for all devices) to absolute (ex. minimum = 0.5 for ultrawide, minimum = 1.0 for default, minimum = 3.0 for telephoto).

We do this by multiplying min/max values by the DisplayVideoZoomFactorMultiplier, if available (iOS 18+). As a fallback, we determine the absolute zoom factor of the wide angle lens, and divide all VirtualDeviceSwitchOverVideoZoomFactors values by it. The result is the following:

// Before

// Back Ultra Wide Camera
{
    MaxZoomFactor = 123.75,
    MinZoomFactor = 1.0
}
// After

// Back Ultra Wide Camera
{
    MaxZoomFactor = 61.875,
    MinZoomFactor = 0.5
}

This PR also changes the exposed ZoomFactor value to be absolute on iOS, internally converting the value inside SetZoomFactor to be relative (as required by AVCaptureDevice.VideoZoomFactor).

@jacksonjude jacksonjude marked this pull request as draft February 2, 2026 23:54
@jacksonjude jacksonjude marked this pull request as ready for review February 3, 2026 00:05
@janusw janusw added the OS:iOS label Feb 4, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request changes iOS zoom factor handling from relative (where minimum is always 1.0) to absolute values (where 1.0 represents the wide-angle lens reference point), bringing iOS into alignment with Android and Windows platform implementations. The change enables proper representation of ultrawide cameras with zoom factors less than 1.0.

Changes:

  • Calculates absolute zoom factor scales for iOS cameras using DisplayVideoZoomFactorMultiplier (iOS 18+) or by deriving scales from virtual device constituent cameras (iOS 13-17)
  • Modifies MinZoomFactor and MaxZoomFactor values to be absolute by multiplying device zoom factors by calculated scales
  • Updates SetZoomFactor to convert from absolute to relative zoom internally before passing to AVCaptureDevice.VideoZoomFactor

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Camera.MAUI/Apple/MauiCameraView.cs
Comment thread Camera.MAUI/Apple/MauiCameraView.cs
Comment thread Camera.MAUI/Apple/MauiCameraView.cs
Comment thread Camera.MAUI/Apple/MauiCameraView.cs
Comment thread Camera.MAUI/Apple/MauiCameraView.cs Outdated
Comment thread Camera.MAUI/Apple/MauiCameraView.cs
Comment thread Camera.MAUI/Apple/MauiCameraView.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jacksonjude
Copy link
Copy Markdown
Author

I have reviewed & resolved the comments from the Copilot PR review. Most of them were unnecessary defensive changes for out of bounds and divide by zero edge cases that are not possible based on Apple's own documentation.

Copy link
Copy Markdown
Owner

@janusw janusw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a lot of iOS hardware to test this on (an iPad with with only a single back camera is not very helpful here), but fortunately I shortly got my hands on a iPhone 12 Pro Max today (with iOS 18.6). Testing on that device yielded the expected results: The default back camera keeps its zoom range of 1 ... 120, while the BackUltraWide/BackDualWide/BackTriple cameras obtain a range of 0.5 ... 60, and the BackTelephoto has 2.5 ... 300.

I cannot test on iOS < 18, but I hope you did, @jacksonjude.

Overall, this looks ok to me, and it makes the zoom-factor handling more consistent with Android. Thanks for these valuable contributions, @jacksonjude!

@janusw janusw merged commit ed00562 into janusw:master Feb 6, 2026
3 checks passed
@janusw
Copy link
Copy Markdown
Owner

janusw commented Feb 7, 2026

@jacksonjude I plan to prepare a new release soon, which includes the improvements from this PR and #75. Is that in your favor, or would you like to contribute any further additions before I ship a new release?

@jacksonjude
Copy link
Copy Markdown
Author

A new release soon would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants