collaction_app icon indicating copy to clipboard operation
collaction_app copied to clipboard

[FEATURE]: Reduce built bundle size

Open Xazin opened this issue 2 years ago • 4 comments

Description: We should make an effort to optimize our application size.

To complete this task please do the following:

  • [ ] Investigate what files take up what size, and if any can be removed
  • [ ] Remove unnecessary files
  • [ ] Consider how we could further decrease the bundle size, eg. by taking out non-critical files etc. (Submit an issue with your findings, and we will consider what we can do)

Note: We currently build with --no-tree-shake-icons for both iOS and Android!

These are the commands used in CICD:

IOS: flutter build ipa --release --export-options-plist=ExportOptions.plist --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons
ANDROID: flutter build appbundle --release --build-number $GITHUB_RUN_NUMBER --no-tree-shake-icons

References: https://docs.flutter.dev/perf/app-size https://medium.com/gytworkz/how-to-decrease-app-size-in-flutter-10461f91f168

https://itnext.io/flutter-minimizing-tips-42113f02b678 (Some tips)

Xazin avatar Apr 04 '23 16:04 Xazin

Addding --obfuscate --split-debug-info=build-info/ reduces by about 2MB

wizlif avatar Apr 10 '23 16:04 wizlif

Any reason why we are not tree shaking icons

  static IconData fromString(String iconName) {
    return ioniconsMapping[iconName] != null
        ? int.tryParse(ioniconsMapping[iconName]!) != null
            ? IoniconsData(int.tryParse(ioniconsMapping[iconName]!)!)
            : CollactionIcons.collaction
        : CollactionIcons.collaction;
  }

We can actually extract only the icons we need from both.

wizlif avatar Apr 10 '23 16:04 wizlif

Any reason why we are not tree shaking icons

  static IconData fromString(String iconName) {
    return ioniconsMapping[iconName] != null
        ? int.tryParse(ioniconsMapping[iconName]!) != null
            ? IoniconsData(int.tryParse(ioniconsMapping[iconName]!)!)
            : CollactionIcons.collaction
        : CollactionIcons.collaction;
  }

We can actually extract only the icons we need from both.

You can play around with it, but the reason is quite simple.

How will you know which icons the backend will want to display on a Commitment? You can't, therefore them all.

Xazin avatar Apr 10 '23 20:04 Xazin

Some comments here that I noticed:

  • We only use Rive for 1 RiveAnimation in our App, we could consider taking it out (~620 kb)
  • Clean unused images:
    • arrow_fwd.png
    • diet.png
    • user.png
    • logo.svg
    • profile.svg

Also noticed mocktail should be moved to dev_dependencies, not sure why it's not there already.

We might also be able to take out rxdart, our usage is quite limited, and we could definitely do without it.

I guess, all of this along with at least --obfuscate should be enough.

Xazin avatar Apr 10 '23 20:04 Xazin