don't report GPU image size (flutter/engine#35473)

This commit is contained in:
Jonah Williams
2022-08-17 14:55:06 -07:00
committed by GitHub
parent 5da65cec98
commit 9faf3b6746
2 changed files with 5 additions and 10 deletions

View File

@@ -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

View File

@@ -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);