Skip to content

Commit 2677cd7

Browse files
author
Jonah Williams
authored
[CP] fix memory leak in host buffer reset. (flutter#55056)
Always resets host buffer, since each overlay context has its own host buffer
1 parent 1c80ab6 commit 2677cd7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

shell/gpu/gpu_surface_metal_impeller.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,12 @@
187187
impeller::DlDispatcher impeller_dispatcher(cull_rect);
188188
display_list->Dispatch(impeller_dispatcher, sk_cull_rect);
189189
auto picture = impeller_dispatcher.EndRecordingAsPicture();
190-
const bool reset_host_buffer = surface_frame.submit_info().frame_boundary;
191190

192191
return renderer->Render(
193192
std::move(surface),
194-
fml::MakeCopyable([aiks_context, picture = std::move(picture),
195-
reset_host_buffer](impeller::RenderTarget& render_target) -> bool {
196-
return aiks_context->Render(picture, render_target, reset_host_buffer);
193+
fml::MakeCopyable([aiks_context, picture = std::move(picture)](
194+
impeller::RenderTarget& render_target) -> bool {
195+
return aiks_context->Render(picture, render_target, /*reset_host_buffer=*/true);
197196
}));
198197
#endif
199198
});

shell/gpu/gpu_surface_metal_impeller_unittests.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
9797
ASSERT_TRUE(frame->Submit());
9898
}
9999

100-
TEST(GPUSurfaceMetalImpeller, ResetHostBufferBasedOnFrameBoundary) {
100+
TEST(GPUSurfaceMetalImpeller, DoesNotResetHostBufferBasedOnFrameBoundary) {
101101
auto delegate = std::make_shared<TestGPUSurfaceMetalDelegate>();
102102
delegate->SetDevice();
103103

@@ -115,13 +115,13 @@ GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override
115115
frame->set_submit_info({.frame_boundary = false});
116116

117117
ASSERT_TRUE(frame->Submit());
118-
EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 0u);
118+
EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 1u);
119119

120120
frame = surface->AcquireFrame(SkISize::Make(100, 100));
121121
frame->set_submit_info({.frame_boundary = true});
122122

123123
ASSERT_TRUE(frame->Submit());
124-
EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 1u);
124+
EXPECT_EQ(host_buffer.GetStateForTest().current_frame, 2u);
125125
}
126126

127127
} // namespace testing

0 commit comments

Comments
 (0)