Skip to content

Commit

Permalink
[cc] Ship smaller interest area on Android
Browse files Browse the repository at this point in the history
On Android, setting a smaller interest area improves memory, without
regressing latency metrics (with even a very small improvement to
INP). Memory savings are 10-20MiB depending on screen resolution, when
tiles are present.

On desktop though, memory savings are small, and likely not worth
potential regressions. Do not enable there.

Bug: 1459256
Change-Id: I9a5c132f588e38fdf38776413323f87405fbded7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4931597
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209854}
  • Loading branch information
Benoit Lize authored and Chromium LUCI CQ committed Oct 14, 2023
1 parent 694c56d commit 442f8af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cc/base/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,17 @@ BASE_FEATURE(kReclaimPrepaintTilesWhenIdle,
"ReclaimPrepaintTilesWhenIdle",
base::FEATURE_DISABLED_BY_DEFAULT);

// This saves memory on all platforms, but while on Android savings are
// significant (~10MiB or more of foreground memory), on desktop they were
// small, so only enable on Android.
BASE_FEATURE(kSmallerInterestArea,
"SmallerInterestArea",
base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(IS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);

const base::FeatureParam<int> kInterestAreaSizeInPixels{
&kSmallerInterestArea, "size_in_pixels", kDefaultInterestAreaSizeInPixels};
Expand Down
1 change: 1 addition & 0 deletions cc/base/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ CC_BASE_EXPORT BASE_DECLARE_FEATURE(kReclaimPrepaintTilesWhenIdle);
CC_BASE_EXPORT BASE_DECLARE_FEATURE(kSmallerInterestArea);

constexpr static int kDefaultInterestAreaSizeInPixels = 3000;
constexpr static int kDefaultInterestAreaSizeInPixelsWhenEnabled = 500;
CC_BASE_EXPORT extern const base::FeatureParam<int> kInterestAreaSizeInPixels;

// Whether images marked "no-cache" are cached. When disabled, they are.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,17 @@ bool IsSmallScreen(const gfx::Size& size) {
#endif

std::pair<int, int> GetTilingInterestAreaSizes() {
int interest_area_size_in_pixels =
::features::kInterestAreaSizeInPixels.Get();
int interest_area_size_in_pixels;

if (base::FeatureList::IsEnabled(::features::kSmallerInterestArea) &&
::features::kInterestAreaSizeInPixels.Get() ==
::features::kInterestAreaSizeInPixels.default_value) {
interest_area_size_in_pixels =
::features::kDefaultInterestAreaSizeInPixelsWhenEnabled;
} else {
interest_area_size_in_pixels = ::features::kInterestAreaSizeInPixels.Get();
}

if (interest_area_size_in_pixels ==
::features::kInterestAreaSizeInPixels.default_value) {
return {
Expand Down

0 comments on commit 442f8af

Please sign in to comment.