Skip to content

[Android] Skip the HardwareBuffer defect fallback for platform views - #193441

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
luskan:ahb-defect-override-pr
Nov 13, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
luskan:ahb-defect-override-pr

Conversation

@luskan

@luskan luskan commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

PR #181931 (the fix for #166481) made FlutterRenderer.createSurfaceProducer() return SurfaceTextureSurfaceProducer on Huawei devices with API <= 29. That fallback is for plugins like video_player, which pass the producer's surface straight to MediaCodec. Platform views call the same method for Texture Layer Hybrid Composition, so they got the fallback too. On Huawei JNY-LX1 / Android 10 this makes a TextureView with OpenGL content inside an AndroidView blank or frozen (#188303).

This keeps platform views on ImageReaderSurfaceProducer on API 29+, as it was from 3.29.2 to 3.41:

  • New FlutterRenderer.createPlatformViewSurfaceProducer(SurfaceLifecycle) creates a producer without the HardwareBuffer defect check. The API 29 requirement and debugForceSurfaceProducerGlTextures still apply.
  • PlatformViewsController.makePlatformViewRenderTarget uses it when the texture registry is a FlutterRenderer.
  • createSurfaceProducer() is unchanged, so plugins keep the Video player on Android 29 device does not play media #166481 fallback.

Apps do not need to change anything.

Fixes #188303. Related to #166481 and #181931.

Testing:

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@luskan
luskan requested a review from a team as a code owner September 28, 2026 11:04
@luskan
luskan requested review from gmackall and removed request for a team September 28, 2026 11:04
@github-actions github-actions Bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Sep 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a static hardwareBufferDefectOverride variable and a corresponding setHardwareBufferDefectOverride method in FlutterRenderer to allow overriding the Android HardwareBuffer defect check. The hasAndroidHardwareBufferDefect method is updated to respect this override when it is set. Additionally, unit tests are added in FlutterRendererTest to verify the override behavior under various SDK versions and configurations, with a teardown method to reset the override after each test. I have no feedback to provide.

@camsim99 camsim99 added the CICD Run CI/CD label Oct 13, 2026

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm skeptical of adding this api - it seems like it would be pushing a burden that should be on Flutter itself on to app developers, and locking in a permanent public API for an internal rendering workaround.

I think there are two paths here which require different treatment:

  1. #181931 was attempting to fix Flutter Texture widgets (specifically video_player in #166481), where a plugin calls TextureRegistry.createSurfaceProducer() and passes the Surface directly to MediaCodec (OMX.hisi.video.decoder.avc), which fails during buffer allocation when backed by ImageReaderSurfaceProducer on Huawei API <= 29 devices.
  2. PlatformViews (AndroidView / PlatformViewsController.makePlatformViewRenderTarget) also call createSurfaceProducer(lifecycle) under the hood on API 29+ for Texture Layer Hybrid Composition, so #181931 (unintentionally, it seems) moved PlatformViews onto the SurfaceTextureSurfaceProducer fallback as well. However, PlatformViews don't connect MediaCodec directly to the ImageReader surface—Android's UI renderer draws the view hierarchy into it via lockHardwareCanvas() (and any child TextureView inside the PlatformView renders into its own internal SurfaceTexture first). In fact, PlatformViews on Huawei API 29 used ImageReaderSurfaceProducer in stable from Flutter 3.29.2 (#164201) through 3.41 without issue.

Because a static override is process-wide, an app on Huawei Android 10 that uses both video_player and a PlatformView (note that devices like MAR-LX1A appear in both #166481 and #188303) wouldn't have a single setting that works for both.

Instead of adding a public override that apps have to opt into, could we scope the hasAndroidHardwareBufferDefect() fallback so that PlatformViewsController.makePlatformViewRenderTarget bypasses it and stays on ImageReaderSurfaceProducer on API 29+?That would fix #188303 out of the box for all apps while keeping the #181931 fallback for external texture plugins like video_player.

Would you be open to updating the PR along those lines (roughly, the gist here) and testing that on your JNY-LX1 device?

@luskan
luskan force-pushed the ahb-defect-override-pr branch from eb8ed1d to 77b10f6 Compare October 21, 2026 11:59
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 21, 2026
@luskan luskan changed the title [Android] Allow apps to override the HardwareBuffer defect check [Android] Skip the HardwareBuffer defect fallback for platform views Oct 21, 2026
@luskan

luskan commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that makes sense. I updated the PR along the lines of your gist and removed the setter (rebased on main, one commit). On top of the gist I added a test for API 28 and a PlatformViewsControllerTest case for the new call. createPlatformViewSurfaceProducer is public only because PlatformViewsController is in another package, happy to change that if you prefer another way.

Tested on JNY-LX1 / Android 10 with 3.47.5 plus this change, in our app and in the repro app, which now also plays a video with video_player (https://github.com/luskan/flutter_textureview_platform_view):

@luskan
luskan requested a review from gmackall October 21, 2026 12:23
@jesswrd jesswrd added the CICD Run CI/CD label Oct 28, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 3, 2026
@gmackall gmackall added the CICD Run CI/CD label Nov 3, 2026
@gmackall
gmackall requested review from a team and reidbaker and removed request for a team November 3, 2026 18:04
@gmackall

gmackall commented Nov 3, 2026

Copy link
Copy Markdown
Member

Tested on JNY-LX1 / Android 10 with 3.47.5 plus this change, in our app and in the repro app, which now also plays a video with video_player (https://github.com/luskan/flutter_textureview_platform_view):
...

Nice!

@gmackall

Copy link
Copy Markdown
Member

Triage housekeeping, I think this will also fix #196048

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit

auto-submit Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193441, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit

auto-submit Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193441, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit

auto-submit Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit

auto-submit Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

@gmackall

Copy link
Copy Markdown
Member

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

Hmm maybe we need to update autosubmit bot to treat expected like queued? They are being used interchangeably at least here, right, this check is underway.

@gmackall

Copy link
Copy Markdown
Member

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

Hmm maybe we need to update autosubmit bot to treat expected like queued? They are being used interchangeably at least here, right, this check is underway.

oh wait nvm I needed to approve workflows to run

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit

auto-submit Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@gmackall

Copy link
Copy Markdown
Member

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

I approved workflows please I'm begging you, run 🫩

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit

auto-submit Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193441, Failed to enqueue flutter/flutter/193441 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 12, 2026
@gmackall

Copy link
Copy Markdown
Member

Thanks for working on this!

Merged via the queue into flutter:master with commit 945b567 Nov 13, 2026
48 of 49 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 13, 2026
…13653)

Manual roll Flutter from 9c427b5d7b1c to 1b9585481095 (32 revisions)

Manual roll requested by [email protected]

flutter/flutter@9c427b5...1b95854

2026-11-13 [email protected] Roll pub packages (flutter/flutter#196541)
2026-11-13 [email protected] Do not route PRs for review without cla, convert to draft (flutter/flutter#196341)
2026-11-13 [email protected] Roll Skia from d87a6c04da74 to 11f46cfe8838 (13 revisions) (flutter/flutter#196533)
2026-11-13 [email protected] [flutter_tools, flutter_test] Deprecate --experimental-faster-testing (flutter/flutter#196123)
2026-11-13 [email protected] [flutter_tools] Handle RPCError in ScreenshotCommand.runSkia (flutter/flutter#196132)
2026-11-13 [email protected] Roll Dart SDK from a8b961fd48bb to c91e8b6674e2 (2 revisions) (flutter/flutter#196502)
2026-11-13 [email protected] Roll Skia from 0c5ce4960cef to d87a6c04da74 (12 revisions) (flutter/flutter#196497)
2026-11-13 [email protected] Don't call `skia_image()`  for raster-owned images in `DlImage::Equals` (flutter/flutter#196473)
2026-11-13 [email protected] [flutter_tools] Require FlutterCommandRunner DI fields and extract findCommandName (flutter/flutter#196331)
2026-11-13 [email protected] [web] Unify ui.Canvas behind a shared EngineCanvas frontend (flutter/flutter#196348)
2026-11-13 [email protected] Link to MediaQuery.displayFeaturesOf from DisplayFeatures (flutter/flutter#193728)
2026-11-13 [email protected] Removes reference to unnecessary ensureSemantics call in doc (flutter/flutter#195831)
2026-11-13 [email protected] [flutter_tools] Register trackWidgetCreation in AppleBuildOptionsBundle (flutter/flutter#196078)
2026-11-12 [email protected] [Android] Skip the HardwareBuffer defect fallback for platform views (flutter/flutter#193441)
2026-11-12 [email protected] Fix supports_decal check in framebuffer_blend.frag (flutter/flutter#196227)
2026-11-12 [email protected] [ios] Update the screen in didUpdateEffectiveGeometry (flutter/flutter#195508)
2026-11-12 [email protected] [flutter_tools] Add `Cache-Control` headers for web test assets (flutter/flutter#196414)
2026-11-12 [email protected] Roll Skia from 3b71ec08218f to 0c5ce4960cef (16 revisions) (flutter/flutter#196472)
2026-11-12 [email protected] [web] Render bounded ImageFilter.blur on wimp (flutter/flutter#196081)
2026-11-12 [email protected] Roll Dart SDK from 69567bd3c427 to a8b961fd48bb (2 revisions) (flutter/flutter#196464)
2026-11-12 [email protected] [engine] Release the Skia OpenGL resource context on shutdown (flutter/flutter#193592)
2026-11-12 [email protected] [web] Fix decoding of still AVIF images on Chrome (flutter/flutter#195958)
2026-11-12 [email protected] Gate SurfaceControl context setting on API 34+ (flutter/flutter#196394)
2026-11-12 [email protected] [flutter_tools] Only pass on a valid root tool in DASH__TOOL (flutter/flutter#196228)
2026-11-12 [email protected] Support GL_TEXTURE_EXTERNAL_OES embedder textures in Impeller (flutter/flutter#195857)
2026-11-12 [email protected] Stop building linux/wasm_release in local_engine_builds (flutter/flutter#196345)
2026-11-12 [email protected] Split flame out of Linux customer_testing (flutter/flutter#196347)
2026-11-12 Jiwon Lee [Windows] Fix Space input after Alt+Space with previous Microsoft IME (flutter/flutter#192105)
2026-11-12 [email protected] [flutter_tools] Add ToolExtensionException, exit() guard, graceful shutdown, and base modifiers (flutter/flutter#195908)
2026-11-12 [email protected] Roll Packages from 653628e to 14f9933 (9 revisions) (flutter/flutter#196450)
2026-11-12 [email protected] Roll Dart SDK from e5add7a25b32 to 69567bd3c427 (2 revisions) (flutter/flutter#196437)
2026-11-12 [email protected] Roll Skia from 9aa2513a4ac9 to 3b71ec08218f (1 revision) (flutter/flutter#196436)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android][PlatformViews] Flutter 3.44.0 regression: TextureView/OpenGL PlatformView stays blank or freezes on Huawei Android 10

5 participants