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

feat: Android Impeller support #1277

Conversation

navaronbracke
Copy link
Collaborator

TODO: test this change + add orientation correction if needed

This PR adds support for SurfaceProducer on Android, which enables support for Impeller on Android.

Fixes #867

@navaronbracke
Copy link
Collaborator Author

@juliansteenbakker I will finish up the implementation and then look into getting someone from the Android team to perhaps peer review this change. This is mostly surface producer changes, by taking a look at the prior art from camera_android_camerax

// See: https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result

// Always attempt a release.
surface.release()
Copy link
Collaborator Author

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()) {
Copy link
Collaborator Author

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.

sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"
sdk: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"
Copy link
Collaborator Author

@navaronbracke navaronbracke Jan 7, 2025

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 callback 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

@juliansteenbakker juliansteenbakker deleted the branch juliansteenbakker:ios-vision January 7, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants