Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bddae911 authored by James O'Leary's avatar James O'Leary
Browse files

Fix boot time regression on Wembley

After a ton of regression testing on Forrest and checking dashboards,
turns out the boot time regression due to new color code only happens
on Wembley in CI.

Wembley in CI has 1 GB of RAM, or at least, it returns true for
`ActivityManager.isLowRamDevice`

To fix the regression, when we're performing clustering
on a low RAM device, we'll use the prior clustering strategy (Kmeans,
5 colors). Net impact is speed improvement + there will be less options
for colors. Kmeans erases less common colors first, and those colors
tend to be good candidates for highly chromatic colors.

Fixes: 181348302
Fixes: 181194430
Test: Did about 50 runs on Forrest, isolated issue. Final Forrest
run showing that startservices_avg decreases to previous levels on
Wembley with this CL is here:
https://android-build.googleplex.com/builds/forrest/run/L87800000829799585
To see the improvement back to baseline (~1350 ms), open that link,
at the table of the bottom of the page, click "asit/perf/boottime_test",
then click Artifacts, then click
test_results15031410639465275315_8163110686177237845.txt, and search
for SystemUIBootTiming_startservices_avg.
Alternatively, here is a direct link to the test results text file:
https://android-build.googleplex.com/builds/I89400007809099518/git_master/P20404532/successiveboottest/inv_17043739560101466259/test_results15031410639465275315_8163110686177237845.txt

Change-Id: I53ee5b5f95e6fd54f1327005e391d428f650dbfa
parent f72cf3cd
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.util.Size;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.graphics.palette.CelebiQuantizer;
import com.android.internal.graphics.palette.Palette;
import com.android.internal.graphics.palette.VariationalKMeansQuantizer;
import com.android.internal.util.ContrastColorUtil;

import java.io.FileOutputStream;
@@ -178,11 +179,20 @@ public final class WallpaperColors implements Parcelable {
                    optimalSize.getHeight(), true /* filter */);
        }

        final Palette palette = Palette
        final Palette palette;
        if (ActivityManager.isLowRamDeviceStatic()) {
            palette = Palette
                    .from(bitmap, new VariationalKMeansQuantizer())
                    .maximumColorCount(5)
                    .resizeBitmapArea(MAX_WALLPAPER_EXTRACTION_AREA)
                    .generate();
        } else {
            palette = Palette
                    .from(bitmap, new CelebiQuantizer())
                    .maximumColorCount(256)
                    .resizeBitmapArea(MAX_WALLPAPER_EXTRACTION_AREA)
                    .generate();
        }
        // Remove insignificant colors and sort swatches by population
        final ArrayList<Palette.Swatch> swatches = new ArrayList<>(palette.getSwatches());
        swatches.sort((a, b) -> b.getPopulation() - a.getPopulation());