Skip to content

[camera_avfoundation] Add responsive capture API - #13689

Open
toyaji wants to merge 1 commit into
flutter:mainfrom
toyaji:camera-avfoundation-responsive-capture
Open

toyaji wants to merge 1 commit into
flutter:mainfrom
toyaji:camera-avfoundation-responsive-capture

Conversation

@toyaji

@toyaji toyaji commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Adds an iOS-only, opt-in API for AVCapturePhotoOutput responsive capture to AVFoundationCamera: isResponsiveCaptureSupported(cameraId) and setResponsiveCaptureEnabled(cameraId, enabled).

With responsive capture, the next photo capture can start while the previous photo is still processing. It is off by default and does not change setZeroShutterLagEnabled or any existing behavior.

Fixes flutter/flutter#197111

Two captures in a row (illustrative, not to scale):

Responsive capture off
  Capture:  [ 1 ]                    [ 2 ]
  Process:       [====== 1 ======]        [====== 2 ======]
                                                          ^ photo 2 done

Responsive capture on
  Capture:  [ 1 ][ 2 ]
  Process:       [====== 1 ======][====== 2 ======]
                                                  ^ photo 2 done (earlier)

Why only in camera_avfoundation

  • It only helps apps that call CameraPlatform.instance.takePicture again before the previous call returns. CameraController.takePicture does not allow overlapping calls, so most apps do not need it.
  • Android's CameraX already overlaps capture and processing without a setting, so there is nothing to add to camera_platform_interface or camera_android_camerax.
  • Apps check that CameraPlatform.instance is an AVFoundationCamera before calling it, like GoogleMapsFlutterAndroid in google_maps_flutter_android. The README shows this.

Details

  • Requires iOS 17 or later and zero-shutter-lag enabled, as AVCapturePhotoOutput does. When unsupported, isResponsiveCaptureSupported returns false and enabling it is a no-op, so the plugin never sets an unsupported flag (which throws).
  • Zero-shutter-lag and responsive capture requests are stored separately and applied in one beginConfiguration/commitConfiguration. Disabling zero-shutter-lag turns responsive capture off first; enabling it again restores the request. Both are re-applied after switching cameras, including while recording.
  • Photos are still delivered in capture order, and the plugin already tracks photo delegates by uniqueID. Responsive capture uses more memory, which the docs mention.
  • Fast capture prioritization is left out because it lowers photo quality; it can be a separate opt-in later.

Testing

  • XCTest: supported check; zero-shutter-lag alone does not enable responsive capture; enabled when zero-shutter-lag is on; a request made before zero-shutter-lag is applied with it in one configuration; no reconfiguration when unsupported; disabling; disabling zero-shutter-lag turns it off first and restores it; re-applied after switching cameras while recording.
  • Dart unit tests for the two new methods.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@toyaji toyaji changed the title [camera_avfoundation] Enable responsive capture with zero-shutter-lag [camera_avfoundation] Add responsive capture API Nov 21, 2026
Adds iOS-only isResponsiveCaptureSupported and setResponsiveCaptureEnabled
to AVFoundationCamera. Responsive capture is off by default, requires
zero-shutter-lag, and is applied together with it in one session
configuration.
@toyaji
toyaji force-pushed the camera-avfoundation-responsive-capture branch from fc769ce to 12f4a3c Compare November 21, 2026 13:11
@toyaji
toyaji marked this pull request as ready for review November 21, 2026 13:45
@github-actions
github-actions Bot marked this pull request as draft November 21, 2026 13:45
@github-actions github-actions Bot added the waiting for response The Flutter team cannot make further progress on this PR until the author responds label Nov 21, 2026
@github-actions

Copy link
Copy Markdown

Hi @toyaji, thank you for your contribution!

This pull request has been converted to a draft because it does not appear to follow our pull request template:

  • Unchecked checklist items (4 of 11): All items in the Pre-Review Checklist must be completed and checked off (- [x]) before the PR can be reviewed:
    • - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
    • - [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
    • - [ ] I read the [Tree Hygiene] page, which explains my responsibilities.
    • - [ ] I signed the [CLA].

How to fix this

  1. Click the ... menu in the top-right corner of your PR description above and select Edit.
  2. Address the issues listed above. Make sure every item in the Pre-Review Checklist is present without modifications and checked off (- [x]).
  3. Save your changes, then click the "Ready for review" button at the bottom of the PR.
Click here for the raw Markdown of the Pre-Review Checklist to copy and paste
## Pre-Review Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] page, which explains my responsibilities.
- [ ] I read and followed the [relevant style guides] and ran [the auto-formatter].
- [ ] I signed the [CLA].
- [ ] The title of the PR starts with the name of the package surrounded by square brackets, e.g. `[shared_preferences]`
- [ ] I [linked to at least one issue that this PR fixes] in the description above.
- [ ] I followed [the version and CHANGELOG instructions], using [semantic versioning] and the [repository CHANGELOG style], or I have commented below to indicate which documented exception this PR falls under[^1].
- [ ] I updated/added any relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under[^1].
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.

<!-- Links -->
[Contributor Guide]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md
[AI contribution guidelines]: https://github.com/flutter/flutter/blob/master/CONTRIBUTING.ai.md#pull-requests
[Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[relevant style guides]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md#style
[the auto-formatter]: https://github.com/flutter/packages/blob/main/script/tool/README.md#format-code
[CLA]: https://cla.developers.google.com/
[Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
[linked to at least one issue that this PR fixes]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[the version and CHANGELOG instructions]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version-and-changelog-updates
[semantic versioning]: https://dart.dev/tools/pub/versioning#semantic-versions
[repository CHANGELOG style]: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changelog-style
[test exemption]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces iOS-only support for responsive capture in the camera_avfoundation package by adding isResponsiveCaptureSupported and setResponsiveCaptureEnabled methods. The changes span the Pigeon definitions, Dart platform interface implementation, Swift plugin code, and native AVCapturePhotoOutput handling, coordinating responsive capture with zero-shutter-lag settings. Unit tests, documentation, and example code have also been updated to support these new features. There are no review comments, and I have no feedback to provide.

@toyaji
toyaji marked this pull request as ready for review November 21, 2026 13:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for iOS-only responsive capture (isResponsiveCaptureSupported and setResponsiveCaptureEnabled) to the camera_avfoundation package. It introduces the necessary platform interface methods, Pigeon definitions, Swift implementation details (including managing the dependency on zero-shutter-lag), documentation, and comprehensive unit tests. There are no review comments to address, and I have no additional feedback to provide.

@github-actions github-actions Bot removed the waiting for response The Flutter team cannot make further progress on this PR until the author responds label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[camera_avfoundation] Add support for responsive capture on iOS

1 participant