Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Reenable HardwareBuffer backed Android Platform Views on SDK >= 29 #44790

Merged
merged 2 commits into from
Aug 17, 2023

Conversation

johnmccutchan
Copy link
Contributor

@johnmccutchan johnmccutchan commented Aug 17, 2023

  • Fix a bug in the SDK < 33 ImageReader construction code path.
  • Fix a bug that resulted in references to Images produced by a closed ImageReader.
  • Fix an order of operations bug in ImageReaderPlatformViewRenderTarget release/finalizer code path.
  • Enable HardwareBuffer backed Android Platform Views on SDK >= 29

Manually tested on device rotating and shutting down the app.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@jason-simmons
Copy link
Member

jason-simmons commented Aug 17, 2023

Tried this PR on a Pixel 3.

If I run the https://github.com/flutter/flutter/tree/master/dev/integration_tests/abstract_method_smoke_test test and rotate the screen, then the PlatformViewAndroidJNIImpl::ImageGetHardwareBuffer JNI call gets an uncaught exception.

java.lang.IllegalStateException: Image is already closed
    at android.media.Image.throwISEIfImageIsInvalid(Image.java:73)
    at android.media.ImageReader$SurfaceImage.getHardwareBuffer(ImageReader.java:989)

}
throw new UnsupportedOperationException(
"ImageReaderPlatformViewRenderTarget requires API version 29+");
}

public ImageReaderPlatformViewRenderTarget(ImageTextureEntry textureEntry) {
if (Build.VERSION.SDK_INT < 26) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be 29, instead of 26.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Done.

@johnmccutchan johnmccutchan force-pushed the reenable_hb_apvs branch 2 times, most recently from 2d7cb2f to 2efc833 Compare August 17, 2023 17:13
@johnmccutchan
Copy link
Contributor Author

@jason-simmons This is ready for review.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

Few nits

Comment on lines +42 to +43
FML_LOG(WARNING)
<< "No DlImage available for HardwareBufferExternalTexture to paint.";
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the developer action to take here?

If there is none, maybe this should be a DLOG/DCHECK?

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 useful information for debugging the engine and I'd like to keep it in place for now until this code is more solid.

// to read back texture data. If we don't always want to use it, how do we
// decide when
// to use it or not? Perhaps PlatformViews can indicate if they may contain
// DRM'd content.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting
nit: please link an issue here explaining what has to be done (even if just what investigation is left to do or what resources someone interested in this should read about)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed added more context to the TODO.

@@ -65,7 +65,8 @@ void SurfaceTextureExternalTexture::Paint(PaintContext& context,
flutter::DlCanvas::SrcRectConstraint::kStrict // enforce edges
);
} else {
FML_LOG(WARNING) << "No DlImage available.";
FML_LOG(WARNING)
<< "No DlImage available for SurfaceTextureExternalTexture to paint.";
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto on log message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here.

- Fix a bug in the SDK < 33 ImageReader construction code path.
- Fix a bug that resulted in references to Images produced by a closed ImageReader.
- Fix an order of operations bug in ImageReaderPlatformViewRenderTarget release/finalizer code path.
- Enable HardwareBuffer backed Android Platform Views on SDK >= 29
@jason-simmons
Copy link
Member

LGTM

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

RSLGTM

@johnmccutchan johnmccutchan merged commit d259a52 into flutter:main Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 18, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 18, 2023
…132812)

flutter/engine@5019d6d...866b43f

2023-08-17 skia-flutter-autoroll@skia.org Roll Skia from 1bec2899ace8 to 1e62a2d4c429 (1 revision) (flutter/engine#44829)
2023-08-17 skia-flutter-autoroll@skia.org Roll Dart SDK from 7e4e5796ee99 to 7101eb7569ac (2 revisions) (flutter/engine#44828)
2023-08-17 skia-flutter-autoroll@skia.org Roll Skia from e4be2cab442f to 1bec2899ace8 (1 revision) (flutter/engine#44826)
2023-08-17 skia-flutter-autoroll@skia.org Roll Skia from bfd45173e5e3 to e4be2cab442f (3 revisions) (flutter/engine#44824)
2023-08-17 gspencergoog@users.noreply.github.com Add Doxygen doc generation for iOS, macOS, Linux, Windows, and Impeller (flutter/engine#43915)
2023-08-17 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from VW7WAVPT3Cj5erlae... to Tnp43n_nAR2N0l_gY... (flutter/engine#44823)
2023-08-17 jason-simmons@users.noreply.github.com Fix FlutterInjectorTest assumptions about how the executor service assigns tasks to threads (flutter/engine#44775)
2023-08-17 john@johnmccutchan.com Reenable HardwareBuffer backed Android Platform Views on SDK >= 29 (flutter/engine#44790)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from VW7WAVPT3Cj5 to Tnp43n_nAR2N

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jsimmons@google.com,rmistry@google.com,zra@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
…lutter#44790)

- Fix a bug in the SDK < 33 ImageReader construction code path.
- Fix a bug that resulted in references to Images produced by a closed
ImageReader.
- Fix an order of operations bug in ImageReaderPlatformViewRenderTarget
release/finalizer code path.
- Enable HardwareBuffer backed Android Platform Views on SDK >= 29

Manually tested on device rotating and shutting down the app.
jiahaog added a commit to jiahaog/flutter-engine that referenced this pull request Sep 18, 2023
jiahaog added a commit to jiahaog/flutter-engine that referenced this pull request Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants