-
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
Migrate camera/android
from SurfaceTexture
->SurfaceProducer
.
#6461
Conversation
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? Test failures in Impeller migration PR: flutter/packages#6461 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/wiki/Hotfix-Documentation-Best-Practices) for examples Ensure that Android platform view updates are posted on correct thread when platform view is created on background handler. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Migration to Impeller plugin APIs is blocked. ### Workaround: Is there a workaround for this issue? Disable impeller ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? However the tests are in flutter/packages and not flutter/engine. ### Validation Steps: What are the steps to validate that this fix works? Run the unit tests on the linked PR in flutter/packages
Due to a release hiccup, the |
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.
Is this file a local conflict resolution mistake?
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.
probably something went wrong applying the formatting diff.
@@ -104,7 +104,8 @@ public void createCaptureSession( | |||
} | |||
|
|||
@Override | |||
public void close() {} | |||
public void close() { |
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.
hmm, that formatting didn't work either
Thank you @stuartmorgan ! |
Current test failure is:
|
@johnmccutchan @camsim99 PTAL |
…ce-producer-camera-android
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.
LGTM
Co-authored-by: Camille Simon <[email protected]>
flutter/packages@31d3329...910fabb 2024-05-29 [email protected] Amend package:web tweaks to allow package:web roll (flutter/packages#6793) 2024-05-29 [email protected] Migrate `video_player/android` from `SurfaceTexture`->`SurfaceProducer`. (flutter/packages#6456) 2024-05-29 [email protected] [google_maps_flutter] Undeprecate BitmapDescriptor methods (flutter/packages#6832) 2024-05-29 [email protected] Migrate CameraX from SurfaceTexture to SurfaceProducer. (flutter/packages#6462) 2024-05-29 [email protected] Migrate `camera/android` from `SurfaceTexture`->`SurfaceProducer`. (flutter/packages#6461) 2024-05-29 [email protected] [dynamic_layouts] Remove the dynamic_layouts package (flutter/packages#6830) 2024-05-29 [email protected] [camerax] Add notes about Android permissions (flutter/packages#6741) 2024-05-29 [email protected] [Re-land] Bump legacy all_packages project AGP version to 7.0.0, Gradle version to 7.0.2 (flutter/packages#6742) 2024-05-29 [email protected] Roll Flutter from a1a33e6 to c85fa6a (20 revisions) (flutter/packages#6829) 2024-05-29 [email protected] [rfw] Migrate deprecated doc references (flutter/packages#6744) 2024-05-29 [email protected] [flutter_adaptive_scaffold] Migrate MaterialStateProperty to WidgetStateProperty (flutter/packages#6743) 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
flutter/packages@31d3329...910fabb 2024-05-29 [email protected] Amend package:web tweaks to allow package:web roll (flutter/packages#6793) 2024-05-29 [email protected] Migrate `video_player/android` from `SurfaceTexture`->`SurfaceProducer`. (flutter/packages#6456) 2024-05-29 [email protected] [google_maps_flutter] Undeprecate BitmapDescriptor methods (flutter/packages#6832) 2024-05-29 [email protected] Migrate CameraX from SurfaceTexture to SurfaceProducer. (flutter/packages#6462) 2024-05-29 [email protected] Migrate `camera/android` from `SurfaceTexture`->`SurfaceProducer`. (flutter/packages#6461) 2024-05-29 [email protected] [dynamic_layouts] Remove the dynamic_layouts package (flutter/packages#6830) 2024-05-29 [email protected] [camerax] Add notes about Android permissions (flutter/packages#6741) 2024-05-29 [email protected] [Re-land] Bump legacy all_packages project AGP version to 7.0.0, Gradle version to 7.0.2 (flutter/packages#6742) 2024-05-29 [email protected] Roll Flutter from a1a33e6 to c85fa6a (20 revisions) (flutter/packages#6829) 2024-05-29 [email protected] [rfw] Migrate deprecated doc references (flutter/packages#6744) 2024-05-29 [email protected] [flutter_adaptive_scaffold] Migrate MaterialStateProperty to WidgetStateProperty (flutter/packages#6743) 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
…lutter#6461) _**WIP**: We do not plan to land this PR until the next stable release (>= April 3rd 2024)_. Work towards flutter/flutter#145930. ## Details Migrates uses of `createSurfaceTexture` to `createSurfaceProducer`, which is intended to have no change in behavior, but _does_ change the backend rendering path, so it will require more testing (and we're also open to minor API renames or changes before it becomes stable). ## Background Android plugins previously requested a `SurfaceTexture` from the Android embedder, and used that to produce a `Surface` to render external textures on (i.e. `video_player`). This worked because 100% of Flutter applications on Android used OpenGLES (via our Skia backend), and `SurfaceTexture` is actually an (opaque) OpenGLES-texture. Starting soon (roughly ~Q3, this is not a guarantee and just an estimate), Flutter on Android will start to use our new Impeller graphics backend, which on newer devices (`>= API_VERSION_28`), will default to the Vulkan, _not_ OpenGLES. In other words, `SurfaceTexture` will cease to work (it is possible, but non-trivial, to map an OpenGLES texture over to Vulkan). After consultation with the Android team, they helped us understand that vending `SurfaceTexture` (the _consumer-side_ API) was never the right abstraction, and we should have been vending the _producer-side_ API, or `Surface` directly. The new `SurfaceProducer` API is exactly that - it generates a `Surface`, and similar to our platform view strategy, picks the "right" _consumer-side_ implementation details _for_ the user/plugin packages. The new `SurfaceProducer` API has 2 possible rendering types (as an implementation detail): - `SurfaceTexture`, for older OpenGLES devices, which works exactly as it does today. - `ImageReader`, for newer OpenGLES _or_ Vulkan devices. These are some subtle nuances in how these two APIs work differently (one example: flutter/flutter#144407), but our theory at this point is we don't expect these changes to be observed by any users, and we have other ideas if necessary. > [!NOTE] > These invariants are [tested on CI in `flutter/engine`](https://github.com/flutter/engine/tree/main/testing/scenario_app/android#ci-configuration). Points of contact: - @matanlurey or @jonahwilliams (Flutter Engine) - @johnmccutchan or @reidbaker (Flutter on Android)
…cer`. (flutter#6461)" This reverts commit 058851b
…cer`." (#6964) Reverts #6461 Resolves flutter/flutter#150549
WIP: We do not plan to land this PR until the next stable release (>= April 3rd 2024).
Work towards flutter/flutter#145930.
Details
Migrates uses of
createSurfaceTexture
tocreateSurfaceProducer
, which is intended to have no change in behavior, but does change the backend rendering path, so it will require more testing (and we're also open to minor API renames or changes before it becomes stable).Background
Android plugins previously requested a
SurfaceTexture
from the Android embedder, and used that to produce aSurface
to render external textures on (i.e.video_player
). This worked because 100% of Flutter applications on Android used OpenGLES (via our Skia backend), andSurfaceTexture
is actually an (opaque) OpenGLES-texture.Starting soon (roughly ~Q3, this is not a guarantee and just an estimate), Flutter on Android will start to use our new Impeller graphics backend, which on newer devices (
>= API_VERSION_28
), will default to the Vulkan, not OpenGLES. In other words,SurfaceTexture
will cease to work (it is possible, but non-trivial, to map an OpenGLES texture over to Vulkan).After consultation with the Android team, they helped us understand that vending
SurfaceTexture
(the consumer-side API) was never the right abstraction, and we should have been vending the producer-side API, orSurface
directly. The newSurfaceProducer
API is exactly that - it generates aSurface
, and similar to our platform view strategy, picks the "right" consumer-side implementation details for the user/plugin packages.The new
SurfaceProducer
API has 2 possible rendering types (as an implementation detail):SurfaceTexture
, for older OpenGLES devices, which works exactly as it does today.ImageReader
, for newer OpenGLES or Vulkan devices.These are some subtle nuances in how these two APIs work differently (one example: flutter/flutter#144407), but our theory at this point is we don't expect these changes to be observed by any users, and we have other ideas if necessary.
Note
These invariants are tested on CI in
flutter/engine
.Points of contact: