Conversation
d12aa2a to
209da21
Compare
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
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. |
janusw
left a comment
There was a problem hiding this comment.
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!
|
@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? |
|
A new release soon would be great! |
This PR changes the
MinAvailableVideoZoomFactorandMaxAvailableVideoZoomFactorvalues 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 allVirtualDeviceSwitchOverVideoZoomFactorsvalues by it. The result is the following:This PR also changes the exposed
ZoomFactorvalue to be absolute on iOS, internally converting the value insideSetZoomFactorto be relative (as required byAVCaptureDevice.VideoZoomFactor).