fix: Restore CameraDevice neutralZoom - #4169
Conversation
|
@ngocdevv is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
mrousavy
left a comment
There was a problem hiding this comment.
Thanks for this PR.
I still haven't decided yet if we should have a .neutralZoom, or if we should just normalize zoom on iOS to also go below 1 so that it is like on Android..? Then zoom start is always 1 and we dont need to worry about anything else
| */ | ||
| var neutralZoomFactor: Double { | ||
| if #available(iOS 18.0, *) { | ||
| let multiplier = displayVideoZoomFactorMultiplier |
There was a problem hiding this comment.
This value changes as the device starts zooming. So if you zoom in, and then ask device.neutralZoomFactor, it is no longer 1 (or 2) but might be any arbitrary number.
I think.
|
|
||
| guard | ||
| let wideAngleIndex = constituentDevices.firstIndex(where: { | ||
| $0.deviceType == .builtInWideAngleCamera | ||
| }), | ||
| wideAngleIndex > 0 | ||
| else { | ||
| return 1 | ||
| } | ||
|
|
||
| let switchoverIndex = wideAngleIndex - 1 | ||
| guard virtualDeviceSwitchOverVideoZoomFactors.indices.contains(switchoverIndex) else { | ||
| return 1 | ||
| } | ||
| return virtualDeviceSwitchOverVideoZoomFactors[switchoverIndex].doubleValue |
There was a problem hiding this comment.
Also this Plan B and Plan C approach are kinda ugly. I'm not sure if there is a better way, but as it is, its a bit ugly.
What
VisionCamera v5 no longer exposes
CameraDevice.neutralZoom. On iOS virtual Cameras with an ultra-wide constituent, AVFoundation uses an internal zoom scale whereminZoomcan be1while the standard wide-angle lens is reached at2. Consumers therefore cannot initialize at the natural user-facing1xvalue without recreating native lens-selection logic.This restores
neutralZoomso consumers can start on the standard wide-angle lens and still allow zooming out to ultra-wide.Closes #3845
How
CameraDevice.neutralZoomto the Nitro spec and regenerates the Swift, Kotlin, and C++ bindings.displayVideoZoomFactorMultiplier.1.0on Android and for physical Cameras.Test
bun camera specsbun run buildbunx tsc --noEmit -p apps/simple-camera/tsconfig.jsonbun example build:android(Kotlin, JNI/C++, four ABIs, debug APK)xcodebuild -workspace apps/simple-camera/ios/SimpleCamera.xcworkspace -scheme SimpleCamera -configuration Debug -destination generic/platform=iOS\ Simulator CODE_SIGNING_ALLOWED=NO buildbun lint-swiftbun lint-kotlinbun lint-jsbun docs types:checkbun docs check:links