Skip to content

[CP-stable][Impeller] Wait for the Vulkan device to become idle before destroying Vulkan objects in the AHBSwapchainImplVK destructor - #188531

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
jason-simmons:cp_stable_187477
Jun 30, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
jason-simmons:cp_stable_187477

Conversation

@jason-simmons

Copy link
Copy Markdown
Member

Issue Link:

#187237

Impact Description:

This can cause a crash on Impeller/Vulkan during app lifecycle events (shutdown/rotation/etc.) when using HCPP/AHBSwapchain.

Changelog Description:

[flutter/187237] Fixes a crash that can happen during app shutdown or rotation on some Android devices using Impeller/Vulkan with HCPP.

Workaround:

Disable Impeller or use the Impeller GLES back end

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

Run the AndroidAHBSwapchainTest.AHBSwapchainDtorCallsWaitIdle unit test. Or try reproducing the crash in the #187237 example app and verifying that it is fixed.

…e destroying Vulkan objects in the AHBSwapchainImplVK destructor

AHBSwapchainImplVK holds Vulkan objects such as fences that may be used
by operations submitted to the Vulkan device. The AHBSwapchainImplVK
destructor must wait until the device is no longer using these objects
before destroying them.

Fixes flutter#187237
@jason-simmons jason-simmons added the cp: review Cherry-picks in the review queue label Jun 24, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 24, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 24, 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 refactors SurfaceControl into an abstract interface with a concrete SurfaceControlImpl implementation, updates AHBSwapchainVK to accept a shared pointer to SurfaceControl, and ensures the Vulkan device is idle before destroying AHBSwapchainImplVK. The review feedback recommends using the override specifier for the destructor in SurfaceControlImpl, preferring std::make_unique over explicit new when instantiating SurfaceControl, and optimizing std::shared_ptr parameters by passing them by value and using std::move to avoid unnecessary reference count overhead.

Comment thread engine/src/flutter/impeller/toolkit/android/surface_control_impl.h
Comment thread engine/src/flutter/impeller/toolkit/android/surface_control.cc
@jason-simmons
jason-simmons requested a review from gaaclarke June 24, 2026 22:14

@gaaclarke gaaclarke 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.

This is bringing in more than just #188519

Is this custom integration code, or is this just cherry-picking a few commits?

@jason-simmons

Copy link
Copy Markdown
Member Author

The only part that is required to fix the bug is the change to call WaitIdle in AHBSwapchainImplVK

(58709f2#diff-953ce211fc3866f71b5594b6697f6973b9d9a02309972d4e06960bddd2b9c450R105)

The rest of this PR is a refactoring that is needed to support the unit test (taken from 2c9accd)

@reidbaker
reidbaker requested review from gmackall and reidbaker June 30, 2026 16:52
@reidbaker

Copy link
Copy Markdown
Contributor

@jason-simmons the tense/direction is wrong on your changelog entry we use the state of the code prior to the the cherry pick for descriptions. see: https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 30, 2026
@auto-submit
auto-submit Bot merged commit 97f70d2 into flutter:flutter-3.44-candidate.0 Jun 30, 2026
176 checks passed
Anas-Qasem pushed a commit to Anas-Qasem/flutter that referenced this pull request Aug 11, 2026
…e destroying Vulkan objects in the AHBSwapchainImplVK destructor (flutter#188531)

### Issue Link:

flutter#187237

### Impact Description:

This can cause a crash on Impeller/Vulkan during app lifecycle events (shutdown/rotation/etc.) when using HCPP/AHBSwapchain.

### Changelog Description:

[flutter/187237] Fixes a crash that can happen during app shutdown or rotation on some Android devices using Impeller/Vulkan with HCPP.

### Workaround:

Disable Impeller or use the Impeller GLES back end

### Risk:
What is the risk level of this cherry-pick?

### Test Coverage:
Are you confident that your fix is well-tested by automated tests?

### Validation Steps:

Run the `AndroidAHBSwapchainTest.AHBSwapchainDtorCallsWaitIdle` unit test.  Or try reproducing the crash in the flutter#187237 example app and verifying that it is fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants