Skip to content

Commit

Permalink
don't report GPU image size (#35473)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams committed Aug 17, 2022
1 parent fbbd8c6 commit 61d6874
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/ui/painting/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,9 @@ void CanvasImage::dispose() {
}

size_t CanvasImage::GetAllocationSize() const {
auto size = sizeof(this);
if (image_) {
size += image_->GetApproximateByteSize();
}
// The VM will assert if we set a value larger than or close to
// std::numeric_limits<intptr_t>::max().
// https://github.com/dart-lang/sdk/issues/49332
return std::clamp(
size, static_cast<size_t>(0),
static_cast<size_t>(std::numeric_limits<intptr_t>::max() / 10));
// We don't actually want Dart's GC to use the size of this object to make GC
// decisions, as it is generally both created and disposed in the framework.
// This is similar to why we do not report the sizes of engine layers.
return sizeof(*this);
}
} // namespace flutter
1 change: 1 addition & 0 deletions lib/ui/painting/image_encoding_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ TEST_F(ShellTest, EncodeImageAccessesSyncSwitch) {
image_handle, tonic::DartWrappable::kPeerIndex, &peer);
ASSERT_FALSE(Dart_IsError(result));
CanvasImage* canvas_image = reinterpret_cast<CanvasImage*>(peer);
ASSERT_EQ(canvas_image->GetAllocationSize(), sizeof(*canvas_image));

int64_t format = -1;
result = Dart_IntegerToInt64(format_handle, &format);
Expand Down

0 comments on commit 61d6874

Please sign in to comment.