From a37fd606d03231a7f90bf4a5b68aa8aaf1c95ffd Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 5 Jan 2024 18:43:37 -0800 Subject: [PATCH] [Impeller] Start and end a frame in the RenderTargetCache for each rendering of an entity in the playgrounds This fixes the memory leak in the GaussianBlurFilter playground described in https://github.com/flutter/engine/pull/48472 --- impeller/entity/entity_playground.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/impeller/entity/entity_playground.cc b/impeller/entity/entity_playground.cc index bd13db3c18c14..3763cac125780 100644 --- a/impeller/entity/entity_playground.cc +++ b/impeller/entity/entity_playground.cc @@ -50,7 +50,10 @@ bool EntityPlayground::OpenPlaygroundHere(Entity entity) { return false; } SinglePassCallback callback = [&](RenderPass& pass) -> bool { - return entity.Render(*content_context, pass); + content_context->GetRenderTargetCache()->Start(); + bool result = entity.Render(*content_context, pass); + content_context->GetRenderTargetCache()->End(); + return result; }; return Playground::OpenPlaygroundHere(callback); } @@ -70,7 +73,10 @@ bool EntityPlayground::OpenPlaygroundHere(EntityPlaygroundCallback callback) { wireframe = !wireframe; content_context.SetWireframe(wireframe); } - return callback(content_context, pass); + content_context.GetRenderTargetCache()->Start(); + bool result = callback(content_context, pass); + content_context.GetRenderTargetCache()->End(); + return result; }; return Playground::OpenPlaygroundHere(pass_callback); }