Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't report GPU image size #35473

Merged
merged 5 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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