don't report GPU image size (flutter/engine#35473)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user