CollActionteam / collaction_app

CollAction cross-platform mobile application for iOS and Android
https://collaction.org
GNU General Public License v3.0
34 stars 12 forks source link

[FEATURE]: Reduce built bundle size #398

Open Xazin opened 1 year ago

Xazin commented 1 year ago

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

To complete this task please do the following:

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)

wizlif commented 1 year ago

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

wizlif commented 1 year ago

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.

Xazin commented 1 year ago

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 commented 1 year ago

Some comments here that I noticed:

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.