-
Notifications
You must be signed in to change notification settings - Fork 3k
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] Re-land SurfaceProducer migration with fix for camera preview rotation #6856
Conversation
@@ -10,7 +10,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart'; | |||
import 'package:flutter/services.dart' | |||
show DeviceOrientation, PlatformException; | |||
import 'package:flutter/widgets.dart' | |||
show Size, Texture, Widget, visibleForTesting; | |||
show RotatedBox, Size, Texture, Widget, visibleForTesting; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used RotatedBox
to rotate the preview mostly because that is what is used in the plugin code, but if there is a better way to rotate it, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me. @jonahwilliams?
packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart
Outdated
Show resolved
Hide resolved
@chinmaygarde if you get the chance to test this out and/or bring the landscape device to SVL next week I would love to see how it behaves with this change! Other than that fix (I left TODOs in the code), this PR can start going through code review :) |
As discussed offline with @matanlurey, going to land the fixes to the camera preview rotation without Impeller support in #7044 first and land this (which will essentially only include re-lading Impeller support) later on. |
…evices and set up fix for Impeller support (#7044) Partially lands #6856. This PR specifically includes: #### 1: A fix for correctly rotating the camera preview This fix is required for `Surface`s not backed by a `SurfaceTexture` because they don't contain the transformation information needed to correctly rotate the camera preview. In that case, we use the logic described in https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation. The fix is **not currently used** (the logic is not reachable) as Impeller support has not been added back to the plugin, but has been tested in #6856 and will be turned on when flutter/flutter#149294 is fixed. Part of flutter/flutter#149294. #### 2: A fix for correctly rotating the camera preview on naturally landscape-oriented devices I believe this issue was caused because we assume that the natural orientation of the device is portrait up. We fix this here by adding an extra rotation for the camera preview based on the natural orientation of the device. Fixes flutter/flutter#149177.
We need to add the lifecycle methods to correctly suspend/resume the camera surface: (Unless I missed something and that's being handled elsewhere?) |
I assume that the preview surface provider already handles that, but let me know if that doesn't cover everything! |
Despite the names those are indeed different things |
I just meant that the method will be called when a new surface is needed which causes CameraX to detach the surface from the camera and return a new surface (see our impl), effectively doing the same thing that doc describes, so I don't think there's anything else to do here. |
To double check that this method is called if a surface gets destroyed, though, I can follow up internally :) |
I see, perhaps you're right - if it works it works! |
Followed up with the CameraX team and found out that we need to call
|
auto label is removed for flutter/packages/6856, due to - The status or check suite Mac_arm64 custom_package_tests master has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…ra preview rotation (flutter/packages#6856)
flutter/packages@7c1a05c...4d2d2e3 2024-08-20 [email protected] [webview] Add macOS support in implementation package (flutter/packages#6221) 2024-08-19 [email protected] Roll Flutter from a0c0453 to 6a28048 (22 revisions) (flutter/packages#7449) 2024-08-19 [email protected] [ci] Remove scorecard action (flutter/packages#7450) 2024-08-19 [email protected] [camerax] Re-land SurfaceProducer migration with fix for camera preview rotation (flutter/packages#6856) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/camera/camera_android_camerax/android (flutter/packages#7441) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [sign_in]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/google_sign_in/google_sign_in_android/android (flutter/packages#7442) 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 [email protected],[email protected] 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
_Description of what this PR is changing or adding, and why:_ Adds a note to the Impeller Android plugins migration to clarify that plugin authors that create a camera preview may additionally need to correct the rotation of the preview due to rotation information of produced `Surface`s being lost. _Issues fixed by this PR (if any):_ N/A _PRs or commits this PR depends on (if any):_ Should land after flutter/packages#6856 as this is mentioned as an example. cc @navaronbracke ## Presubmit checklist - [x] This PR is marked as draft with an explanation if not meant to land until a future stable release. - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Parker Lougheed <[email protected]> Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]>
flutter/packages@7c1a05c...4d2d2e3 2024-08-20 [email protected] [webview] Add macOS support in implementation package (flutter/packages#6221) 2024-08-19 [email protected] Roll Flutter from a0c0453 to 6a28048 (22 revisions) (flutter/packages#7449) 2024-08-19 [email protected] [ci] Remove scorecard action (flutter/packages#7450) 2024-08-19 [email protected] [camerax] Re-land SurfaceProducer migration with fix for camera preview rotation (flutter/packages#6856) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/camera/camera_android_camerax/android (flutter/packages#7441) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [sign_in]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/google_sign_in/google_sign_in_android/android (flutter/packages#7442) 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 [email protected],[email protected] 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
Re-lands #6462 with the following change to
buildPreview
:Switches on a fix for correctly rotating the camera preview
This fix is required for
Surface
s not backed by aSurfaceTexture
because they don't contain the transformation information needed to correctly rotate the camera preview. In that case, we use the logic described in https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation. This logic was added in a previous PR (#7044); this simply enables it for devices whereSurface
s are not backed by aSurfaceTexture
(see how this is determined).Fixes flutter/flutter#149294.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).