sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

[Android]: Report SDK size as a comment in PRs

Open bruno-garcia opened this issue 4 years ago • 10 comments

We'd like to start managing the bundle size of the SDK more actively.

For that, we'd like to start taking some numbers during PRs, and with the end goal of posting as a PR comment the bundle size and a diff to main.

Approaches considered and characteristics of them:

Measuring the aar

  • Either we do a naive measurement solely of our package without considering dependencies. Or we need to recursively find all dependencies and measure their sizes.
  • There are multiple slices on each aar, for each abi.
    • We'd need to compile for a specific one, or peek into the aar to calculate specific architectures.

Measuring the final app

  • We can run proguard on the sample app which has heavy use of our features and measure more realistically the "overhead" in bundle size.

Suggested Phases:

bruno-garcia avatar Mar 03 '21 23:03 bruno-garcia

Some inspiration: https://github.com/firebase/firebase-android-sdk/pull/3011#issuecomment-929768965

romtsn avatar Mar 14 '22 16:03 romtsn

Worth noting that our JavaScript repo already has something like this, see https://github.com/getsentry/sentry-javascript/pull/4993#issuecomment-1110615206.

philipphofmann avatar Apr 27 '22 12:04 philipphofmann

Somehow related https://github.com/getsentry/sentry-java/issues/1411

marandaneto avatar Apr 27 '22 12:04 marandaneto

We could use https://github.com/JakeWharton/diffuse

Diffuse is a tool for diffing APKs, AABs, AARs, and JARs in a way that aims to provide both a high-level view of what changes along with important detailed output.

philipphofmann avatar Apr 27 '22 13:04 philipphofmann

The first goal would be to get the output of diffuse and just add it as a comment to the PR.

Example output of diffuse:

          │          compressed           │          uncompressed
          ├───────────┬───────────┬───────┼───────────┬───────────┬────────
 APK      │ old       │ new       │ diff  │ old       │ new       │ diff
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
      dex │ 664.8 KiB │ 664.8 KiB │ -25 B │   1.5 MiB │   1.5 MiB │ -112 B
     arsc │ 201.7 KiB │ 201.7 KiB │   0 B │ 201.6 KiB │ 201.6 KiB │    0 B
 manifest │   1.4 KiB │   1.4 KiB │   0 B │   4.2 KiB │   4.2 KiB │    0 B
      res │ 418.2 KiB │ 418.2 KiB │ -14 B │ 488.3 KiB │ 488.3 KiB │    0 B
    asset │       0 B │       0 B │   0 B │       0 B │       0 B │    0 B
    other │  37.1 KiB │  37.1 KiB │   0 B │  36.3 KiB │  36.3 KiB │    0 B
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
    total │   1.3 MiB │   1.3 MiB │ -39 B │   2.2 MiB │   2.2 MiB │ -112 B

philipphofmann avatar Apr 27 '22 13:04 philipphofmann

We could also give it a try with https://github.com/Tencent/matrix/tree/master/matrix/matrix-android/matrix-apk-canary

Analyse the APK package, give suggestions of reducing the APK's size; Compare two APK and find out the most significant increment on size

marandaneto avatar Jul 22 '22 07:07 marandaneto

diffuse github action https://github.com/usefulness/diffuse-action

romtsn avatar Jan 31 '23 12:01 romtsn

Here's the relevant github action which already does an APK size diff: https://github.com/getsentry/action-app-sdk-overhead-metrics

markushi avatar Feb 01 '23 15:02 markushi

I thought @vaind added this here, no?

bruno-garcia avatar Feb 23 '23 20:02 bruno-garcia

not the breakdown of what changed, just the raw apk size.

romtsn avatar Feb 24 '23 08:02 romtsn