Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 564f53f

Browse files
authored
Revert "Improve caching limits for Skia (#9503)" (#9740)
This reverts commit 63c2c33.
1 parent b453d3c commit 564f53f

File tree

4 files changed

+4
-44
lines changed

4 files changed

+4
-44
lines changed

shell/common/rasterizer.cc

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Rasterizer::Rasterizer(
4343
: delegate_(delegate),
4444
task_runners_(std::move(task_runners)),
4545
compositor_context_(std::move(compositor_context)),
46-
user_override_resource_cache_bytes_(false),
4746
weak_factory_(this) {
4847
FML_DCHECK(compositor_context_);
4948
}
@@ -412,15 +411,7 @@ void Rasterizer::FireNextFrameCallbackIfPresent() {
412411
callback();
413412
}
414413

415-
void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) {
416-
user_override_resource_cache_bytes_ |= from_user;
417-
418-
if (!from_user && user_override_resource_cache_bytes_) {
419-
// We should not update the setting here if a user has explicitly set a
420-
// value for this over the flutter/skia channel.
421-
return;
422-
}
423-
414+
void Rasterizer::SetResourceCacheMaxBytes(int max_bytes) {
424415
GrContext* context = surface_->GetContext();
425416
if (context) {
426417
int max_resources;
@@ -429,16 +420,6 @@ void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) {
429420
}
430421
}
431422

432-
size_t Rasterizer::GetResourceCacheMaxBytes() const {
433-
GrContext* context = surface_->GetContext();
434-
if (context) {
435-
size_t max_bytes;
436-
context->getResourceCacheLimits(nullptr, &max_bytes);
437-
return max_bytes;
438-
}
439-
return 0;
440-
}
441-
442423
Rasterizer::Screenshot::Screenshot() {}
443424

444425
Rasterizer::Screenshot::Screenshot(sk_sp<SkData> p_data, SkISize p_size)

shell/common/rasterizer.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,7 @@ class Rasterizer final : public SnapshotDelegate {
9292
return compositor_context_.get();
9393
}
9494

95-
// Sets the max size in bytes of the Skia resource cache. If this call is
96-
// originating from the user, e.g. over the flutter/skia system channel,
97-
// set from_user to true and the value will take precedence over system
98-
// generated values, e.g. from a display resolution change.
99-
void SetResourceCacheMaxBytes(size_t max_bytes, bool from_user);
100-
101-
size_t GetResourceCacheMaxBytes() const;
95+
void SetResourceCacheMaxBytes(int max_bytes);
10296

10397
private:
10498
Delegate& delegate_;
@@ -107,7 +101,6 @@ class Rasterizer final : public SnapshotDelegate {
107101
std::unique_ptr<flutter::CompositorContext> compositor_context_;
108102
std::unique_ptr<flutter::LayerTree> last_layer_tree_;
109103
fml::closure next_frame_callback_;
110-
bool user_override_resource_cache_bytes_;
111104
fml::WeakPtrFactory<Rasterizer> weak_factory_;
112105

113106
// |SnapshotDelegate|

shell/common/shell.cc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -610,16 +610,6 @@ void Shell::OnPlatformViewSetViewportMetrics(const ViewportMetrics& metrics) {
610610
FML_DCHECK(is_setup_);
611611
FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread());
612612

613-
// This is the formula Android uses.
614-
// https://android.googlesource.com/platform/frameworks/base/+/master/libs/hwui/renderthread/CacheManager.cpp#41
615-
int max_bytes = metrics.physical_width * metrics.physical_height * 12 * 4;
616-
task_runners_.GetGPUTaskRunner()->PostTask(
617-
[rasterizer = rasterizer_->GetWeakPtr(), max_bytes] {
618-
if (rasterizer) {
619-
rasterizer->SetResourceCacheMaxBytes(max_bytes, false);
620-
}
621-
});
622-
623613
task_runners_.GetUITaskRunner()->PostTask(
624614
[engine = engine_->GetWeakPtr(), metrics]() {
625615
if (engine) {
@@ -873,8 +863,7 @@ void Shell::HandleEngineSkiaMessage(fml::RefPtr<PlatformMessage> message) {
873863
[rasterizer = rasterizer_->GetWeakPtr(),
874864
max_bytes = args->value.GetInt()] {
875865
if (rasterizer) {
876-
rasterizer->SetResourceCacheMaxBytes(static_cast<size_t>(max_bytes),
877-
true);
866+
rasterizer->SetResourceCacheMaxBytes(max_bytes);
878867
}
879868
});
880869
}

shell/gpu/gpu_surface_gl.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ static const int kGrCacheMaxCount = 8192;
2828

2929
// Default maximum number of bytes of GPU memory of budgeted resources in the
3030
// cache.
31-
// The shell will dynamically increase or decrease this cache based on the
32-
// viewport size, unless a user has specifically requested a size on the Skia
33-
// system channel.
34-
static const size_t kGrCacheMaxByteSize = 24 * (1 << 20);
31+
static const size_t kGrCacheMaxByteSize = 512 * (1 << 20);
3532

3633
GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate)
3734
: delegate_(delegate), weak_factory_(this) {

0 commit comments

Comments
 (0)