Skip to content

[camera_android_camerax] Allow high-resolution still captures for max preset#11956

Open
kalyujniy wants to merge 2 commits into
flutter:mainfrom
brickit-app:fix-camerax-max-high-resolution
Open

[camera_android_camerax] Allow high-resolution still captures for max preset#11956
kalyujniy wants to merge 2 commits into
flutter:mainfrom
brickit-app:fix-camerax-max-high-resolution

Conversation

@kalyujniy

@kalyujniy kalyujniy commented Jun 22, 2026

Copy link
Copy Markdown

Updates camera_android_camerax so ResolutionPreset.max can select Camera2 high-resolution JPEG still capture sizes on Android. For ResolutionPreset.max, ImageCapture now uses ResolutionSelector.PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE; preview and image analysis keep the existing selector without high-resolution mode.

Fixes flutter/flutter#188310

Problem

On some Android devices, Camera2 exposes the largest 4:3 still resolution only through getHighResolutionOutputSizes(ImageFormat.JPEG). The CameraX backend used ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY without ResolutionSelector.PREFER_HIGHER_RESOLUTION_OVER_CAPTURE_RATE, so CameraX could pick the largest regular JPEG size instead.

Observed

  • Camera2 regular JPEG max: 3264x2448
  • Camera2 high-resolution JPEG: 4624x3468
  • Flutter takePicture(): 2448x3264

After fix

  • CameraX ImageCapture: 4624x3468
  • Flutter takePicture(): 3468x4624

Risk / tradeoff

High-resolution still capture can be slower and use more memory. Limited to ResolutionPreset.max and ImageCapture only.

Note

Generated Pigeon files (camerax_library.g.dart, CameraXLibrary.g.kt) include formatting churn from local pigeon regeneration; functional changes are limited to ResolutionSelector allowed resolution mode and max-preset ImageCapture selector behavior.

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.

Test plan

  • flutter test test/android_camera_camerax_test.dart
  • dart run script/tool/bin/flutter_plugin_tools.dart format --packages camera_android_camerax --no-java --no-kotlin --no-clang-format --no-swift
  • dart run script/tool/bin/flutter_plugin_tools.dart analyze --packages camera_android_camerax
  • dart run script/tool/bin/flutter_plugin_tools.dart dart-test --packages camera_android_camerax
  • Java: ResolutionSelectorTest
  • Android native tests (native-test --android) — not run locally (no JRE); left to CI

@google-cla

google-cla Bot commented Jun 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 updates ResolutionPreset.max to support CameraX high-resolution still capture sizes on Android by introducing an allowedResolutionMode configuration to ResolutionSelector. It adds a separate _imageCaptureResolutionSelector for still image capture, allowing the camera to prefer higher resolution over capture rate. The review feedback suggests passing the preset resolution selector as an argument to _getImageCaptureResolutionSelectorFromPreset to eliminate temporal coupling and preserve existing configuration properties.

Comment thread packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart Outdated
…lver

Avoid temporal coupling in _getImageCaptureResolutionSelectorFromPreset by
passing the preset resolution selector as an argument and copying its
properties when building the max-preset ImageCapture selector.
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_android_camerax] ResolutionPreset.max does not select Camera2 high-resolution JPEG still capture sizes

1 participant