From 69f6a034c271437a44306b8d6d3aab6b4b7fde20 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 8 Jan 2024 11:57:21 -0800 Subject: [PATCH] [Impeller] Start and end a frame in the RenderTargetCache for each rendering of an entity in the playgrounds (flutter/engine#49576) This fixes the memory leak in the GaussianBlurFilter playground described in https://github.com/flutter/engine/pull/48472 --- .../src/flutter/impeller/entity/entity_playground.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/entity/entity_playground.cc b/engine/src/flutter/impeller/entity/entity_playground.cc index bd13db3c18..3763cac125 100644 --- a/engine/src/flutter/impeller/entity/entity_playground.cc +++ b/engine/src/flutter/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); }