Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] tear down swapchain when backgrounding. #165259

Merged
merged 4 commits into from
Mar 18, 2025

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Mar 15, 2025

When we return to the foreground the swapchain is reconstructed anyway. Eagerly tearing the old one down releases memory faster. Highlighted by a regression in a customer: money benchmark.

@github-actions github-actions bot added platform-android Android applications specifically engine flutter/engine repository. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Mar 15, 2025
@jonahwilliams jonahwilliams marked this pull request as ready for review March 17, 2025 15:57
@jonahwilliams
Copy link
Member Author

This should show up in our memory benchmarks

@jonahwilliams jonahwilliams requested a review from gaaclarke March 17, 2025 16:27
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

The code is simple and looks good to me. There is a mechanism outside of this PR that resurrects the swapchain. I'd love to have a test that exercises that. Maybe in the android view level?

At a minimum we should have a comment that explains the mechanism that resurrects the swapchain.

@@ -72,6 +72,10 @@ bool SurfaceContextVK::SetWindowSurface(vk::UniqueSurfaceKHR surface,
return SetSwapchain(SwapchainVK::Create(parent_, std::move(surface), size));
}

void SurfaceContextVK::TeardownSwapchain() {
swapchain_.reset();
Copy link
Member

Choose a reason for hiding this comment

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

Probably worth commenting how this will get resurrected.

@jonahwilliams
Copy link
Member Author

There is a mechanism outside of this PR that resurrects the swapchain. I'd love to have a test that exercises that. Maybe in the android view level?

THe android engine tests background and foreground and test rendering. I think those will cover it

@jonahwilliams
Copy link
Member Author

Added unit test and doc comment.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
Copy link
Contributor

auto-submit bot commented Mar 18, 2025

autosubmit label was removed for flutter/flutter/165259, because - The status or check suite Google testing 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 Mar 18, 2025
@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 18, 2025
Merged via the queue into flutter:master with commit 05c868e Mar 18, 2025
172 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e: impeller Impeller rendering backend issues and features requests engine flutter/engine repository. See also e: labels. platform-android Android applications specifically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants