Skip to content

[Impeller] Reset transient HostBuffer on raster snapshots to prevent memory leak - #192937

Draft
andywolff wants to merge 5 commits into
flutter:masterfrom
andywolff:repaintboundary_leak
Draft

andywolff wants to merge 5 commits into
flutter:masterfrom
andywolff:repaintboundary_leak

Conversation

@andywolff

Copy link
Copy Markdown
Contributor

Fixes #192097

When rasterizing offscreen snapshots through RenderRepaintBoundary.toImage(), SnapshotControllerImpeller::DoMakeRasterSnapshot passed /*reset_host_buffer=*/false to impeller::DisplayListToTexture. Because the transient data and index host buffers were never reset upon snapshot completion, each snapshot accumulated vertex and uniform data in HostBuffer which was never cleaned up.

Looking at the history of this file, I don't see anything which suggests a reason why this may have been intentionally set to false, so this PR sets it to true.

I also added a unit test SnapshotControllerImpeller.MakeImpellerSnapshotSyncRecyclesHostBuffer in gpu_surface_metal_impeller_unittests.mm that executes repeated snapshots against a mock delegate and asserts that the total allocated buffer count remains bounded at 1.

Pre-launch Checklist

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

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] Repeated RepaintBoundary.toImage() leaks native memory (snapshot HostBuffer never recycled)

1 participant