This commit is contained in:
Dan Field
2022-09-06 13:50:04 -07:00
committed by GitHub
parent 7cea2d1361
commit c2a098c593
23 changed files with 3 additions and 137 deletions

View File

@@ -1074,7 +1074,6 @@ FILE: ../../../flutter/lib/ui/painting/single_frame_codec.h
FILE: ../../../flutter/lib/ui/painting/single_frame_codec_unittests.cc
FILE: ../../../flutter/lib/ui/painting/vertices.cc
FILE: ../../../flutter/lib/ui/painting/vertices.h
FILE: ../../../flutter/lib/ui/painting/vertices_unittests.cc
FILE: ../../../flutter/lib/ui/platform_dispatcher.dart
FILE: ../../../flutter/lib/ui/plugins.dart
FILE: ../../../flutter/lib/ui/plugins/callback_cache.cc

View File

@@ -228,7 +228,6 @@ if (enable_unittests) {
"painting/image_generator_registry_unittests.cc",
"painting/path_unittests.cc",
"painting/single_frame_codec_unittests.cc",
"painting/vertices_unittests.cc",
"semantics/semantics_update_builder_unittests.cc",
"window/platform_configuration_unittests.cc",
"window/platform_message_response_dart_unittests.cc",

View File

@@ -23,7 +23,6 @@ namespace flutter {
static const tonic::DartWrapperInfo kDartWrapperInfo_ui_FragmentShader = {
"ui",
"_FragmentShader",
sizeof(FragmentShader),
};
const tonic::DartWrapperInfo& FragmentShader::dart_wrapper_info_ =
kDartWrapperInfo_ui_FragmentShader;

View File

@@ -21,7 +21,6 @@ typedef CanvasImage Image;
static const tonic::DartWrapperInfo kDartWrapperInfo_ui_Image = {
"ui",
"_Image",
sizeof(Image),
};
const tonic::DartWrapperInfo& Image::dart_wrapper_info_ =
kDartWrapperInfo_ui_Image;
@@ -39,10 +38,4 @@ void CanvasImage::dispose() {
ClearDartWrapper();
}
size_t CanvasImage::GetAllocationSize() const {
// 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

@@ -37,8 +37,6 @@ class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
void set_image(sk_sp<DlImage> image) { image_ = image; }
size_t GetAllocationSize() const override;
private:
CanvasImage();

View File

@@ -114,10 +114,6 @@ class ImageDescriptor : public RefCountedDartWrappable<ImageDescriptor> {
ClearDartWrapper();
}
size_t GetAllocationSize() const override {
return sizeof(ImageDescriptor) + sizeof(SkImageInfo) + buffer_->size();
}
private:
ImageDescriptor(sk_sp<SkData> buffer,
const SkImageInfo& image_info,

View File

@@ -125,7 +125,6 @@ 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);

View File

@@ -77,10 +77,6 @@ Dart_Handle ImmutableBuffer::initFromAsset(Dart_Handle buffer_handle,
return Dart_Null();
}
size_t ImmutableBuffer::GetAllocationSize() const {
return sizeof(ImmutableBuffer) + data_->size();
}
#if FML_OS_ANDROID
// Compressed image buffers are allocated on the UI thread but are deleted on a

View File

@@ -75,8 +75,6 @@ class ImmutableBuffer : public RefCountedDartWrappable<ImmutableBuffer> {
ClearDartWrapper();
}
size_t GetAllocationSize() const override;
private:
explicit ImmutableBuffer(sk_sp<SkData> data) : data_(std::move(data)) {}

View File

@@ -308,11 +308,4 @@ void CanvasPath::clone(Dart_Handle path_handle) {
path->mutable_path() = this->path();
}
// This is doomed to be called too early, since Paths are mutable.
// However, it can help for some of the clone/shift/transform type methods
// where the resultant path will initially have a meaningful size.
size_t CanvasPath::GetAllocationSize() const {
return sizeof(CanvasPath) + path().approximateBytesUsed();
}
} // namespace flutter

View File

@@ -111,8 +111,6 @@ class CanvasPath : public RefCountedDartWrappable<CanvasPath> {
const SkPath& path() const { return tracked_path_->path; }
size_t GetAllocationSize() const override;
private:
CanvasPath();

View File

@@ -40,7 +40,7 @@ class Picture : public RefCountedDartWrappable<Picture> {
void dispose();
size_t GetAllocationSize() const override;
size_t GetAllocationSize() const;
static void RasterizeToImageSync(sk_sp<DisplayList> display_list,
uint32_t width,

View File

@@ -113,8 +113,4 @@ Dart_Handle SingleFrameCodec::getNextFrame(Dart_Handle callback_handle) {
return Dart_Null();
}
size_t SingleFrameCodec::GetAllocationSize() const {
return sizeof(*this);
}
} // namespace flutter

View File

@@ -32,9 +32,6 @@ class SingleFrameCodec : public Codec {
// |Codec|
Dart_Handle getNextFrame(Dart_Handle args) override;
// |DartWrappable|
size_t GetAllocationSize() const override;
private:
enum class Status { kNew, kInProgress, kComplete };
Status status_;

View File

@@ -25,8 +25,6 @@ TEST_F(ShellTest, SingleFrameCodecAccuratelyReportsSize) {
Dart_Handle result = Dart_GetNativeInstanceField(
handle, tonic::DartWrappable::kPeerIndex, &peer);
ASSERT_FALSE(Dart_IsError(result));
SingleFrameCodec* codec = reinterpret_cast<SingleFrameCodec*>(peer);
ASSERT_EQ(codec->GetAllocationSize(), sizeof(SingleFrameCodec));
};
auto finish = [message_latch](Dart_NativeArguments args) {
message_latch->Signal();

View File

@@ -80,13 +80,6 @@ bool Vertices::init(Dart_Handle vertices_handle,
return true;
}
size_t Vertices::GetAllocationSize() const {
if (!vertices_) {
return sizeof(*this);
}
return vertices_->size();
}
void Vertices::dispose() {
vertices_.reset();
ClearDartWrapper();

View File

@@ -28,8 +28,6 @@ class Vertices : public RefCountedDartWrappable<Vertices> {
const DlVertices* vertices() const { return vertices_.get(); }
size_t GetAllocationSize() const override;
void dispose();
private:

View File

@@ -1,64 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/lib/ui/painting/vertices.h"
#include <memory>
#include "flutter/common/task_runners.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/runtime/dart_vm.h"
#include "flutter/shell/common/shell_test.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/testing/testing.h"
namespace flutter {
namespace testing {
TEST_F(ShellTest, VerticesAccuratelyReportsSize) {
auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
auto nativeValidateVertices = [message_latch](Dart_NativeArguments args) {
auto handle = Dart_GetNativeArgument(args, 0);
intptr_t peer = 0;
Dart_Handle result = Dart_GetNativeInstanceField(
handle, tonic::DartWrappable::kPeerIndex, &peer);
ASSERT_FALSE(Dart_IsError(result));
Vertices* vertices = reinterpret_cast<Vertices*>(peer);
// GT because we don't want to be too dependent on platform specific
// differences, or minor changes to Skia. The actual value of this on
// macOS as of the test writing is 1441890ul. Just need to assert it's
// big enough to get the Dart GC's attention.
ASSERT_GT(vertices->GetAllocationSize(), 1300000ul);
message_latch->Signal();
};
Settings settings = CreateSettingsForFixture();
TaskRunners task_runners("test", // label
GetCurrentTaskRunner(), // platform
CreateNewThread(), // raster
CreateNewThread(), // ui
CreateNewThread() // io
);
AddNativeCallback("ValidateVertices",
CREATE_NATIVE_ENTRY(nativeValidateVertices));
std::unique_ptr<Shell> shell =
CreateShell(std::move(settings), std::move(task_runners));
ASSERT_TRUE(shell->IsSetup());
auto configuration = RunConfiguration::InferFromSettings(settings);
configuration.SetEntrypoint("createVertices");
shell->RunEngine(std::move(configuration), [](auto result) {
ASSERT_EQ(result, Engine::RunStatus::Success);
});
message_latch->Wait();
DestroyShell(std::move(shell), std::move(task_runners));
}
} // namespace testing
} // namespace flutter

View File

@@ -22,13 +22,6 @@ Paragraph::Paragraph(std::unique_ptr<txt::Paragraph> paragraph)
Paragraph::~Paragraph() = default;
size_t Paragraph::GetAllocationSize() const {
// We don't have an accurate accounting of the paragraph's memory consumption,
// so return a fixed size to indicate that its impact is more than the size
// of the Paragraph class.
return 2000;
}
double Paragraph::width() {
return m_paragraph->GetMaxWidth();
}

View File

@@ -49,8 +49,6 @@ class Paragraph : public RefCountedDartWrappable<Paragraph> {
Dart_Handle getLineBoundary(unsigned offset);
tonic::Float64List computeLineMetrics();
size_t GetAllocationSize() const override;
void dispose();
private:

View File

@@ -38,7 +38,7 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) {
TONIC_DCHECK(!CheckAndHandleError(res));
this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper.
dart_wrapper_.Set(dart_state, wrapper, this, GetAllocationSize(),
dart_wrapper_.Set(dart_state, wrapper, this, sizeof(*this),
&FinalizeDartWrapper);
return wrapper;
@@ -59,7 +59,7 @@ void DartWrappable::AssociateWithDartWrapper(Dart_Handle wrapper) {
this->RetainDartWrappableReference(); // Balanced in FinalizeDartWrapper.
DartState* dart_state = DartState::Current();
dart_wrapper_.Set(dart_state, wrapper, this, GetAllocationSize(),
dart_wrapper_.Set(dart_state, wrapper, this, sizeof(*this),
&FinalizeDartWrapper);
}
@@ -78,10 +78,6 @@ void DartWrappable::FinalizeDartWrapper(void* isolate_callback_data,
wrappable->ReleaseDartWrappableReference(); // Balanced in CreateDartWrapper.
}
size_t DartWrappable::GetAllocationSize() const {
return GetDartWrapperInfo().size_in_bytes;
}
Dart_PersistentHandle DartWrappable::GetTypeForWrapper(
tonic::DartState* dart_state,
const tonic::DartWrapperInfo& wrapper_info) {

View File

@@ -34,11 +34,6 @@ class DartWrappable {
// Implement using IMPLEMENT_WRAPPERTYPEINFO macro
virtual const DartWrapperInfo& GetDartWrapperInfo() const = 0;
// Override this to customize the object size reported to the Dart garbage
// collector.
// Implement using IMPLEMENT_WRAPPERTYPEINFO macro
virtual size_t GetAllocationSize() const;
virtual void RetainDartWrappableReference() const = 0;
virtual void ReleaseDartWrappableReference() const = 0;
@@ -85,7 +80,6 @@ class DartWrappable {
kDartWrapperInfo_##LibraryName_##ClassName = { \
#LibraryName, \
#ClassName, \
sizeof(ClassName), \
}; \
const tonic::DartWrapperInfo& ClassName::dart_wrapper_info_ = \
kDartWrapperInfo_##LibraryName_##ClassName;

View File

@@ -15,7 +15,6 @@ typedef void (*DartWrappableAccepter)(DartWrappable*);
struct DartWrapperInfo {
const char* library_name;
const char* interface_name;
const size_t size_in_bytes;
private:
DartWrapperInfo(const DartWrapperInfo&) = delete;