Skip to content

[camera] Add support for zero-shutter-lag capture #190598

Open

Description

@toyaji

Use case

The problem

On Android, there's a noticeable lag between tapping the shutter and the moment
that's actually captured — even on a static scene it feels slow, and with a moving
subject (kids, pets, sports) the delay means missing the moment outright. Measured
at ~0.6 s on a Galaxy S21 (details below).

On iOS the OS already mitigates this automatically (see below), but apps get no
say: no way to opt out (Apple documents the opt-out — zero-shutter-lag costs
extra memory in the photo output), no way to re-enable it after a session
configuration change silently reverts it, and no way to query it at all.

What the platforms ship today

  • Android (CameraX): ships a zero-shutter-lag capture mode, but the plugin
    always uses the default latency-minimizing mode — there is no way to turn it on.
  • iOS (AVFoundation): for apps linked on or after iOS 17, zero-shutter-lag is
    enabled automatically when the session configuration supports it — but the
    plugin never touches the API, so there is no way to turn it off, back on, or
    ask about it.

The same missing API surfaces differently per platform: an opt-in on Android,
explicit control (mostly the documented opt-out) on iOS.

Alternatives considered

No pub.dev package reaches this platform capability — it lives behind
camera_android_camerax/camera_avfoundation themselves, so this is a request
against those.

On-device measurement — Android (Galaxy S21, 5 captures per mode)

Photographed a running millisecond stopwatch; shutter fired via adb shell input tap
(no human reaction time). The stopwatch visible in each saved photo shows how far
behind the shutter tap the captured frame is. Same session, same scene, only the
capture mode changed.

Captured frame Shutter → file saved
Current (MINIMIZE_LATENCY) baseline 912 ms
ZERO_SHUTTER_LAG 629 ms earlier 639 ms

Run-to-run spread was far below the 629 ms difference, and CameraX's
Selected ZSL size log confirmed the ZSL pipeline was genuinely active.

On-device verification — iOS (iPhone, iOS 26.5)
  • With ResolutionPreset.max: AVCapturePhotoOutput.isZeroShutterLagSupported
    reports true, and isZeroShutterLagEnabled is already true before the plugin
    touches anything — confirming the iOS 17+ auto-enable.
  • With ResolutionPreset.medium on the same device: unsupported. Support is a
    property of the session configuration, not just the device.
  • Setting isZeroShutterLagEnabled = false turns it off; setting it back to
    true re-enables it.
  • What the toggle actually controls, measured at ResolutionPreset.max by
    comparing AVCapturePhoto.timestamp against the host-clock time of the
    capturePhoto call (5 captures per mode, one warm-up capture discarded):
    with ZSL off the saved frame lands +279 ms after the call, with ZSL on
    -74 ms before it. Since iOS enables this automatically, that difference
    is what an app gives up by opting out — not something this proposal adds.

Proposal

What to add

Explicit zero-shutter-lag control plus a support query on CameraPlatform,
following the existing getSupportedVideoStabilizationModes pattern — defaults
keep today's behavior, so it's non-breaking.

How each platform provides it

When it can't be used

  • Android: CameraX degrades on its own — flash falls back per shot, devices
    without reprocessing never activate the ZSL session. Apps need no special
    handling.
  • iOS: support depends on the session configuration (verified above:
    supported at ResolutionPreset.max, unsupported at medium on the same
    device), so apps consult the support query and the implementation guards the
    write.

Next step

Draft PR with a working implementation for both platforms is up:
flutter/packages#12374 — happy
to reshape the API however maintainers prefer.

Related: #179064 (preview-frame snapshot) attacks the same latency at preview
resolution; this is complementary at full capture resolution.

Activity

  1. added
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    on Aug 5, 2026
  2. added
    P2Important issues not at the top of the work list
    on Aug 11, 2026
  3. toyaji commented on Aug 21, 2026

    @toyaji
    Author

    The implementation for both Android and iOS is complete and now up for review in flutter/packages#12374, with the on-device measurements in the PR description.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions