Skip to content

Gate SurfaceControl context setting on API 34+ - #196394

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
mboetger:fix-hcpp-api-34-gate
Nov 12, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
mboetger:fix-hcpp-api-34-gate

Conversation

@mboetger

Copy link
Copy Markdown
Contributor

HCPP (EnableHcpp) requires Android 14 (API 34+) and is enabled by default. The Android embedder checked api_level >= 34 before enabling HCPP for platform views, except in CreateContextSettings, where it passed enable_surface_control = true directly to Impeller without checking the API level.

As a result, Impeller Vulkan still used the SurfaceControl swapchain on Android 10-13 (API 29-33). On Android 10 (API 29), that swapchain triggers an Android NDK abort ('ASurfaceControl not found') when the surface is recreated, such as on screen rotation (flutter/flutter#155877).

Fixes: #155877

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

PlatformViewAndroid::PlatformViewAndroid gated android_meets_hcpp_criteria_
on android_get_device_api_level() >= kMinAPILevelHCPP (34), but
CreateContextSettings forwarded Settings::enable_surface_control directly
to AndroidContext::ContextSettings without checking the device API level.

Since EnableHcpp defaults to true, Impeller Vulkan contexts on Android
10-13 (API 29-33) enabled AHBSwapchainVK (SurfaceControl swapchain) by
default even though HCPP itself was disabled, triggering NDK
ASurfaceTransactionStats_getPreviousReleaseFenceFd aborts
('ASurfaceControl not found') during surface recreation and screen
rotation on Android 10.

Gate ContextSettings::enable_surface_control on api_level >= 34 inside
PlatformViewAndroid::CreateContextSettings so SurfaceControl swapchains
are only enabled when HCPP criteria can be met.

Fixes flutter#155877
@mboetger
mboetger requested a review from a team as a code owner November 11, 2026 19:20
@mboetger
mboetger requested review from jesswrd and removed request for a team November 11, 2026 19:20
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Nov 11, 2026
@mboetger
mboetger requested a review from gmackall November 11, 2026 19:20
@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 Nov 11, 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 gates the enablement of SurfaceControl swapchains on Android API level 34 or higher (HCPP) by passing the device API level to CreateContextSettings. It also introduces unit tests to verify this gating behavior across different API levels. The review feedback suggests defining the minimum API level constant kMinAPILevelHCPP as a public static member of PlatformViewAndroid to avoid duplicating state across the source, header, and test files, thereby maintaining a single source of truth.

Comment on lines +30 to +32
// Android 14 (API 34): minimum SDK version supporting HCPP and
// ASurfaceTransaction_fromJava.
constexpr int kApiLevelAndroid14 = 34;

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.

medium

Instead of hardcoding the API level 34 again, define kApiLevelAndroid14 in terms of PlatformViewAndroid::kMinAPILevelHCPP. This ensures that the minimum API level required for HCPP is defined in a single place and prevents future inconsistencies if the minimum version changes.

Suggested change
// Android 14 (API 34): minimum SDK version supporting HCPP and
// ASurfaceTransaction_fromJava.
constexpr int kApiLevelAndroid14 = 34;
// Android 14 (API 34): minimum SDK version supporting HCPP and
// ASurfaceTransaction_fromJava.
constexpr int kApiLevelAndroid14 = PlatformViewAndroid::kMinAPILevelHCPP;
References
  1. Avoid duplicating state: Keep only one source of truth. (link)

gmackall
gmackall previously approved these changes Nov 11, 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.

seems good to me

@mboetger mboetger 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
Merged via the queue into flutter:master with commit 11202c0 Nov 12, 2026
21 of 22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 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.

[Impeller] ASurfaceTransactionStats_getPreviousReleaseFenceFd crashing mysteriously on some API 29 devices.

2 participants