-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
[WIP] feat: Android Impeller support #1283
base: develop
Are you sure you want to change the base?
[WIP] feat: Android Impeller support #1283
Conversation
@@ -16,8 +16,8 @@ screenshots: | |||
path: example/screenshots/overlay.png | |||
|
|||
environment: | |||
sdk: ">=3.4.0 <4.0.0" | |||
flutter: ">=3.22.0" | |||
sdk: ">=3.6.0 <4.0.0" |
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.
The SurfaceProducer API has seen some changes over a long period of time, due to the lengthy release cadence of the framework itself.
The SurfaceProducer API was available, but non-functional in Flutter 3.22, with the migration doc for plugin authors listing Flutter 3.24 as the minimum required version for the migration. However, in Flutter 3.27 both Impeller on Android has been turned on by default, and there was a name change for one of the two callbacks in the SurfaceProducer usage. (onSurfaceCreated -> onSurfaceAvailable)
In Flutter 3.28 there will be another name change (onSurfaceDestroyed -> onSurfaceCleanup), but since the current stable is only version 3.27, I added a TODO for that change
// See: https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result | ||
|
||
// Always attempt a release. | ||
surface.release() |
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 think that adding this line fixes any occurrences of A resource failed to call close
that we sometimes get.
Previously, we never did anything with the result callback, thus also not releasing the surface.
// Only need to release, do nothing. | ||
} | ||
SurfaceRequest.Result.RESULT_INVALID_SURFACE -> { | ||
// The surface was invalid, so it is not clear how to recover from this. |
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 think that adding this line fixes any occurrences of A resource failed to call close that we sometimes get.
Previously, we never did anything with the result callback, thus also not releasing the surface.
|
||
// Preview | ||
val surfaceProvider = Preview.SurfaceProvider { request -> | ||
if (isStopped()) { |
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.
We no longer have this check, I'm not sure if we should put it back or not.
|
||
val texture = textureEntry!!.surfaceTexture() | ||
texture.setDefaultBufferSize( |
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.
This is replaced by the surfaceProducer.setSize(request.resolution.width, request.resolution.height)
on line 199.
@juliansteenbakker I moved over the changes from the old PR into this one. One thing that I don't know for sure is if we should provide Impeller support on Android in Flutter 3.24 or 3.27. |
@@ -53,6 +53,67 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { | |||
|
|||
int? _textureId; | |||
|
|||
/// Rotate the given [child] to account for the device orientation. | |||
Widget _buildCameraViewWithDeviceOrientation(Widget child) { | |||
final Map<DeviceOrientation, int> degreesForDeviceOrientation = |
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.
This function is still a work in progress, as we need to retrieve some arguments (camera direction, sensor orientation, natural device orientation) and observe the device orientation changes.
This PR adds support for Impeller on Android.
Supercedes #1277 (retargets those changes onto the new develop branch)
TODO:
SurfaceTexture
withSurfaceProducer
onSurfaceDestroyed
(I need to add the annotation)Fixes #867