Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Reduce built bundle size #398

Open
3 tasks
Xazin opened this issue Apr 4, 2023 · 4 comments
Open
3 tasks

[FEATURE]: Reduce built bundle size #398

Xazin opened this issue Apr 4, 2023 · 4 comments

Comments

@Xazin
Copy link
Member

Xazin commented Apr 4, 2023

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)

@wizlif
Copy link
Collaborator

wizlif commented Apr 10, 2023

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

@wizlif
Copy link
Collaborator

wizlif commented Apr 10, 2023

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
Copy link
Member Author

Xazin commented Apr 10, 2023

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
Copy link
Member Author

Xazin commented Apr 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants