I’ve set up a flutter build and all is working fine for both iOS and Android. I was hoping to make the build a bit faster by leveraging caching. However, my attempts so far have just slowed things down. That’s because despite caching, the steps I was hoping would be faster (such as installing flutter) are still the same. That is, they’re not using the cache to avoid the need to re-install.
Is there any guidance on setting up flutter with Bitrise in such a way as to avoid the ~3 mins required to simply install flutter on every build?
For the record, I tried caching these paths:
/Users/vagrant/flutter/
/Users/vagrant/.pub-cache/
/usr/local/Cellar/
/Users/vagrant/Library/Caches/Homebrew/
However, that was far too expensive (~4GB) and was recreating the cache every time due to irrelevant file changes. I also tried toning it right down to just:
/Users/vagrant/flutter/
The cache was still approaching 1GB and it would have been faster, except flutter still insisted on running a full install. My install script for flutter is:
- script:
title: Install flutter
inputs:
- content: |-
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
cd ..
git clone -b alpha https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew install ios-deploy
flutter doctor
Are you sure that’s where flutter installs its actual binaries? bin/flutter in the repository is just a script (https://github.com/flutter/flutter/blob/master/bin/flutter). Not sure where the actual binary is / what should be cached. That always depends on the tool, what worth to cache and which dir(s) should be cached.
Additionally, if most of the flutter install is downloading some pre-compiled binaries then the cache might not even worth it at all, as the cache have to be downloaded as well, which will most likely take about the same time than just downloading from the official source. E.g. brew by default downloads precompiled tools, meaning brew install usually can’t be made faster as it just downloads the binaries/components.
Typically the best candidates for caching are the files/dirs which you can’t just download from an official source but have to be built locally. There you trade the compile time for cache download, which usually is faster, but this also depends on the tool, how fast or slow the compile of the tool is vs the size of the compiled files.
I’m not saying flutter can’t be cached, just wanted to share a couple of notes / things to consider. Unfortunately we’re not familiar with how flutter install works (what would worth or not worth to cache), you might want to ask that on flutter’s forums/support.
Of course if you’d have any questions just let us know!
Another option to speed up Flutter installation process is to include Flutter SDK in the Bitrise stacks. Beta and dev versions are available as archives. Linux version is ~300 MB, macOS one about 600 MB.
So pre-installing Dev versions wouldn’t help much, right? Even for Beta versions I’m not that sure, as we do the updates once a week, so if they release Betas frequently there’s a significant chance that it won’t be the right version for your project, right? I mean it will be either newer or older than the version you develop with but most likely not the exact same version, right?
Flutter have stable version now, and stable versions will be released every quarter, so it is not every week. Let reconsider faster builds.
Current “Flutter Install” step takes over 2 minutes for every builds, so it is better to add Flutter to stacks.
It means that it’s impossible to build even basic Flutter app on free plan.
If you add Firebase to the iOS app it takes almost 30 minutes to complete initial flutter build and then again 20 minutes to archive .ipa. So in other words it’s impossible to build iOS Flutter app with Firebase on Developer plan.
I’m sad to hear you have these hardships, it is kind of hard to make it faster, because this is how flutter works, and it is out of our reach, we are currently trying to find a solution to cache flutter builds so that part could be faster.
Flutter is already installed on current macOS stacks. So we can reduce a time by skipping “Flutter Install” step on Workflow.
Thanks for adding Flutter to macOS stacks!
Hey @viktorbenei i was wondering if you could take a look at my issues:
I seem to have my flutter deployment running continuously but i do not know what the issues are, i was wondering if a second eyes could take a look at it.
I’m having this exact issue, I am very curious if the build speed is quicker after caches are created. Sadly my builds aborts at 45 minutes and the bitrise cache push step is never reached, so I will never know. Its incredibly frustrating “flutter-build” step takes about 60 seconds locally (macbook pro 16 inch) and 32 minutes on the build server. Thats 32 times slower
Information regarding my project:
Bare bone project with a firebase integration, here are the dependencies I’m using.
They do some hotfix releases montly or so, but for mayor versions they take more than that.
I believe that it will be really valuable to have that in bitrise, specialy on flutter because we build iOS and android and removing time in the middle will help the CI process a lot.
Generally we do not have hot fixes or release candidates install on the stack in order to provide a stable environment for the majority of users. If you do need a hotfix release you can easily install it during your build.