Skip to content

[CP-beta] [Impeller] Wait for the Vulkan device to become idle before destroying Vulkan objects in the AHBSwapchainImplVK destructor (#187477)#188588

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.46-candidate.0from
walley892:cp-187477
Jun 26, 2026
Merged

Conversation

@walley892

Copy link
Copy Markdown
Contributor

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.

…g Vulkan objects in the AHBSwapchainImplVK destructor (flutter#187477)

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
@walley892 walley892 requested a review from jason-simmons June 25, 2026 21:59
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 25, 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 25, 2026
@walley892

Copy link
Copy Markdown
Contributor Author

@jason-simmons, re-opened #188519 to target the new beta branch 3.46

@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 updates AHBSwapchainImplVK to call WaitIdle() in its destructor, ensuring the Vulkan device is idle before destroying objects. It also adds a unit test to verify this behavior and mocks vkDeviceWaitIdle for testing. The review feedback suggests upgrading the log level from INFO to ERROR when vkDeviceWaitIdle fails, as a failure indicates a critical device issue.

Comment on lines +131 to +133
if (result != vk::Result::eSuccess) {
FML_LOG(INFO) << "Device waitIdle failed: " << vk::to_string(result);
}

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

A failure in vkDeviceWaitIdle (such as VK_ERROR_DEVICE_LOST) is a serious error that indicates a critical issue with the Vulkan device. Logging this as FML_LOG(INFO) makes it highly likely to be overlooked in production logs. It should be logged as FML_LOG(ERROR) to ensure visibility during debugging and crash analysis.

Suggested change
if (result != vk::Result::eSuccess) {
FML_LOG(INFO) << "Device waitIdle failed: " << vk::to_string(result);
}
if (result != vk::Result::eSuccess) {
FML_LOG(ERROR) << "Device waitIdle failed: " << vk::to_string(result);
}

@walley892 walley892 added autosubmit Merge PR when tree becomes green via auto submit App cp: review Cherry-picks in the review queue labels Jun 25, 2026
@auto-submit

auto-submit Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 25, 2026
@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 26, 2026
@auto-submit auto-submit Bot merged commit a24b1ea into flutter:flutter-3.46-candidate.0 Jun 26, 2026
10 checks passed
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