You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6ba32f3
Browse filesBrowse the repository at this point in the historyBrowse files
iOS implementation of the zero-shutter-lag API added in
camera_platform_interface 2.14.0 (this bumps the constraint to
^2.14.0). Part of flutter/flutter#190598.
## What
- `isZeroShutterLagSupported` ->
[`AVCapturePhotoOutput.isZeroShutterLagSupported`](https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/iszeroshutterlagsupported)
(iOS 17+/macOS 14+; `false` on older versions)
- `setZeroShutterLagEnabled` ->
[`AVCapturePhotoOutput.isZeroShutterLagEnabled`](https://developer.apple.com/documentation/avfoundation/avcapturephotooutput/iszeroshutterlagenabled)
## Why explicit control when iOS auto-enables it
Per the `AVCapturePhotoOutput.h` header, "For apps linked on or after
iOS 17 zero shutter lag is automatically enabled when supported." The
documented role of the setter is the explicit opt-out (WWDC23 session
10105: "you can set AVCapturePhotoOutput.isZeroShutterLagEnabled to
false to opt out" - https://developer.apple.com/videos/play/wwdc2023/10105/),
plus deterministic re-enable: support can be revoked by configuration
changes, and when it is, the enabled state silently reverts.
Because of that auto-enable, iOS 17+ starts with zero shutter lag on
while Android starts with it off, so the same Dart call is an opt-out
here and an opt-in there. No latency numbers are quoted for iOS: the
platform already enables the mode by default, so this change is about
making that state explicit and controllable, not about improving it.
<details><summary>Guard and configuration timing</summary>
The header states the property "may only be set to YES if
zeroShutterLagSupported is YES, otherwise an NSInvalidArgumentException
is thrown", and that changing it "requires a lengthy reconfiguration of
the capture render pipeline", to be done within
`beginConfiguration`/`commitConfiguration` while running. The
implementation guards enabling on the support query and wraps the write
in a configuration block. The requested state is kept (plugin- and
camera-level) and reapplied after session reconfigurations and camera
switches, which silently reset it — mirroring the settings-retention
approach on the Android side. Availability is handled inside the
`CapturePhotoOutput` protocol passthrough (`flutter`-prefixed members,
matching the existing `CaptureDevice.flutterActiveFormat` pattern), so
callers need no availability checks and pre-iOS 17 devices report
unsupported / ignore writes.
</details>
Regenerating with pigeon 26.1.5 also reverts two pre-existing hand-edits
to the generated files from flutter#11616 (a redundant Int32 fallback cast and
a missing Dart doc comment).
Copy file name to clipboardExpand all lines: packages/camera/camera_avfoundation/darwin/camera_avfoundation/Sources/camera_avfoundation/CameraPlugin.swift
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,11 @@ public final class CameraPlugin: NSObject, FlutterPlugin {
21
21
/// An internal camera object that manages camera's state and performs camera operations.
22
22
varcamera:Camera?
23
23
24
+
/// The zero-shutter-lag state last requested via `setZeroShutterLagEnabled`,
25
+
/// if any. Kept here so it survives camera recreation (e.g. switching
26
+
/// cameras) and is applied to newly created cameras.
Copy file name to clipboardExpand all lines: packages/camera/camera_avfoundation/darwin/camera_avfoundation/Sources/camera_avfoundation/CaptureOutput.swift
Copy file name to clipboardExpand all lines: packages/camera/camera_avfoundation/darwin/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
+41Lines changed: 41 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,12 @@ final class DefaultCamera: NSObject, Camera {
122
122
123
123
privatevarfileFormat=PlatformImageFileFormat.jpeg
124
124
privatevarimageQuality:Int64=100
125
+
126
+
/// The zero-shutter-lag state last requested via [setZeroShutterLagEnabled],
127
+
/// if any. Session reconfiguration (e.g. switching cameras) silently resets
128
+
/// `isZeroShutterLagEnabled`, so the requested state is kept here and
0 commit comments