Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[camerax] Prevent using unsupported concurrent camera use cases #6608

Merged
merged 16 commits into from May 6, 2024

Conversation

camsim99
Copy link
Contributor

@camsim99 camsim99 commented Apr 24, 2024

Adds logic + documentation to prevent the usage of unsupported (by CameraX) concurrent camera use cases.

The CameraX plugin should only support the concurrent camera use cases supported by Camerax; see their documentation for more information. To avoid the usage of unsupported concurrent use cases, this PR changes the plugin so that it behaves according to the following:

  • If the preview is paused (via pausePreview), concurrent video recording and image streaming (via startVideoCapturing(cameraId, VideoCaptureOptions(streamCallback:...))) is supported.
  • If the preview is not paused
    • and the camera device is at least supported hardware LIMITED, then concurrent
      image capture and video recording is supported.
    • and the camera device is at least supported hardware LEVEL_3, then concurrent video recording and image streaming is supported, but if used, concurrent image capture alongside this is not supported.

Also changes Surface constants to match Dart style and small documentation nits I noticed.

Fixes flutter/flutter#146395, fixes flutter/flutter#144414.

Pre-launch Checklist

#getSupportedHardwareLevel,
[identifier],
),
returnValue: 0,
Copy link
Contributor

@reidbaker reidbaker May 1, 2024

Choose a reason for hiding this comment

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

Consider a comment saying this is LIMITED. It could help in debugging later to know that the device might not have returned limited but we had an error. https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is generated code :/ I think it's just a mock value

Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

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

I glossed over the code that appeared generated.

@camsim99
Copy link
Contributor Author

camsim99 commented May 1, 2024

Just realized I didn't check for LIMITED level devices to disable image capture...just wanted to note I need to add this check + test before landing this!

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label May 6, 2024
@auto-submit auto-submit bot merged commit 79d733c into flutter:main May 6, 2024
78 checks passed
vashworth pushed a commit to vashworth/packages that referenced this pull request May 6, 2024
…ter#6608)

Adds logic + documentation to prevent the usage of unsupported (by CameraX) concurrent camera use cases.

The CameraX plugin should only support the concurrent camera use cases supported by Camerax; see [their documentation](https://developer.android.com/media/camera/camerax/architecture#combine-use-cases) for more information. To avoid the usage of unsupported concurrent use cases, this PR changes the plugin so that it behaves according to the following:

* If the preview is paused (via `pausePreview`), concurrent video recording and image streaming (via `startVideoCapturing(cameraId, VideoCaptureOptions(streamCallback:...))`) is supported.
* If the preview is not paused
  * **and** the camera device is at least supported hardware [`LIMITED`](https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED), then concurrent
    image capture and video recording is supported.
  * **and** the camera device is at least supported hardware [`LEVEL_3`](https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3), then concurrent video recording and image streaming is supported, but if used, concurrent image capture alongside this is not supported.

Also changes `Surface` constants to match Dart style and small documentation nits I noticed.

Fixes flutter/flutter#146395, fixes flutter/flutter#144414.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 7, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 7, 2024
flutter/packages@2dfe645...5ccddfc

2024-05-06 15619084+vashworth@users.noreply.github.com [shared_preferences_foundation] Adds Swift Package Manager compatibility (flutter/packages#6640)
2024-05-06 stuartmorgan@google.com [file_selector] Add support for SPM (flutter/packages#6672)
2024-05-06 43054281+camsim99@users.noreply.github.com [camerax] Add empty implementation for `prepareForVideoRecording` not used on Android (flutter/packages#6676)
2024-05-06 stuartmorgan@google.com [ci] Reduce the number of tasks in recipe CQ (flutter/packages#6673)
2024-05-06 engine-flutter-autoroll@skia.org Roll Flutter from f1037a0 to 04424e1 (25 revisions) (flutter/packages#6674)
2024-05-06 43054281+camsim99@users.noreply.github.com [camerax] Prevent using unsupported concurrent camera use cases (flutter/packages#6608)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request May 13, 2024
…to `camera_android_camerax` (#6629)

Breaking change: Changes default Android implementation from `camera_android` to `camera_android_camerax` via a breaking change and updates relevant documentation.

~<ins>**Note:**</ins> Planning to land this after #6608, as it is a semi-crucial fix.~ Done :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: camera platform-android
Projects
None yet
2 participants