From 431d2a40949d859cc335e22ccb14eb442772c523 Mon Sep 17 00:00:00 2001 From: David Schachter Date: Wed, 25 Nov 2026 21:39:26 -0800 Subject: [PATCH 1/2] ADFA-6957: Skip advzip on CI builds of branches other than stage Step 2 of the ADFA-6953 plan. recompressApk ran advzip -3 on every CI build. On the Universal APK job that pass took 209 s in a normal stage build and 307 s in an ADFA-6956 measurement run, the largest single cost in the job. advzip now runs only for release APKs and for CI builds of stage, which most testers install. Feature-branch and PR builds use the Deflater BEST_COMPRESSION path that local builds and advzip-less machines already use. The jar assets stay deflated (ADFA-4188); only the final 7z-level pass is skipped. Size cost, measured on a current CI debug APK (ADFA-6956 run 45761026069, recompressing each deflated entry with zlib level 9, the Deflater path's settings): 77,080,750 bytes with advzip, about 2.88 MB (+3.74%) more without it. The agreed limit was 5%. recompressApk now logs a line when it skips advzip, so the CI log shows which path ran. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw --- app/build.gradle.kts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fb9b1c882f..6038e7494c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1231,10 +1231,15 @@ fun recompressApk( .asFile project.logger.lifecycle("Recompressing APK Dir: ${apkDir.path}") - // advzip runs for release APKs and on CI (including CI debug); a dev - // invoking recompressApk locally against a debug APK skips it. Local debug - // assembles never run this task at all (ADFA-1167). - val useAdvzip = buildName == "release" || isCiCd + // advzip runs for release APKs and for CI builds of stage, the builds most + // testers install. CI builds of other branches skip it: on a debug APK it + // takes 200-300 s and saves only about 3.7% (2.9 MB of 77 MB, ADFA-6957). + // A dev invoking recompressApk locally against a debug APK skips it too, and + // local debug assembles never run this task at all (ADFA-1167). + val useAdvzip = buildName == "release" || (isCiCd && System.getenv("GITHUB_REF_NAME") == "stage") + if (!useAdvzip) { + project.logger.lifecycle("Skipping advzip: only release APKs and CI builds of stage use it (ADFA-6957)") + } // 7z-level deflate (-3) by default; -Pzopfli (-4) buys only ~50 KB more per // release APK at ~4x the CPU time (ADFA-1167). From b58befe6a17ef52d740b773b4db2ffcc52cad8cd Mon Sep 17 00:00:00 2001 From: David Schachter Date: Wed, 25 Nov 2026 21:45:37 -0800 Subject: [PATCH 2/2] ADFA-6957: Let debug.yml ask for advzip with -Padvzip on stage From the independent review: keying advzip on GITHUB_REF_NAME in the build script also kept it in the scheduled analyze and instrumentation builds, which build stage, though nobody installs those APKs. The workflow that publishes the APK now opts in instead. - recompressApk runs advzip for release APKs and for builds run with -Padvzip, read the same way as the existing -Pzopfli. No branch name in the build script. - debug.yml passes -Padvzip only when GITHUB_REF_NAME is stage, and installs advancecomp only then. So stage builds published to App Tester keep advzip, while branch builds and the scheduled analyze and instrumentation builds skip it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw --- .github/workflows/debug.yml | 8 +++++++- app/build.gradle.kts | 13 ++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index ed07b819d8..ff1abe1865 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -228,14 +228,20 @@ jobs: exit "$status" fi + # advzip runs only for stage builds; see the assemble step. - name: Install advancecomp (advzip, used by recompressApk) + if: github.ref_name == 'stage' run: | command -v advzip || { sudo apt-get update && sudo apt-get install -y advancecomp; } - name: Assemble Universal APK run: | set -o pipefail - flox activate -d flox/base -- ./gradlew :app:assembleV8Debug --no-daemon 2>&1 | tee "$RUNNER_TEMP/assemble.log" + # advzip (in recompressApk) only for stage, the debug builds most testers install. Elsewhere + # it costs 200-300 s to save about 3.7% of the APK (ADFA-6957). + advzip=() + if [ "$GITHUB_REF_NAME" = stage ]; then advzip=(-Padvzip); fi + flox activate -d flox/base -- ./gradlew :app:assembleV8Debug --no-daemon "${advzip[@]}" 2>&1 | tee "$RUNNER_TEMP/assemble.log" # D8 logs this (non-fatal) once per class when the pinned R8 is older than the Kotlin # metadata version, burying every real diagnostic. See the `r8` pin in libs.versions.toml. if grep -q "Unexpected error during rewriting of Kotlin metadata" "$RUNNER_TEMP/assemble.log"; then diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6038e7494c..8a9ca2521b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1231,14 +1231,13 @@ fun recompressApk( .asFile project.logger.lifecycle("Recompressing APK Dir: ${apkDir.path}") - // advzip runs for release APKs and for CI builds of stage, the builds most - // testers install. CI builds of other branches skip it: on a debug APK it - // takes 200-300 s and saves only about 3.7% (2.9 MB of 77 MB, ADFA-6957). - // A dev invoking recompressApk locally against a debug APK skips it too, and - // local debug assembles never run this task at all (ADFA-1167). - val useAdvzip = buildName == "release" || (isCiCd && System.getenv("GITHUB_REF_NAME") == "stage") + // advzip runs for release APKs, and for debug APKs only with -Padvzip, which + // debug.yml passes for stage builds, the debug builds most testers install. + // On a debug APK it takes 200-300 s and saves only about 3.7% (2.9 MB of + // 77 MB, ADFA-6957). Local debug assembles never run this task (ADFA-1167). + val useAdvzip = buildName == "release" || project.hasProperty("advzip") if (!useAdvzip) { - project.logger.lifecycle("Skipping advzip: only release APKs and CI builds of stage use it (ADFA-6957)") + project.logger.lifecycle("Skipping advzip: only release APKs and builds with -Padvzip use it (ADFA-6957)") } // 7z-level deflate (-3) by default; -Pzopfli (-4) buys only ~50 KB more per