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

[cloud_firestore] Xcode build extremely slow #349

Closed
kroikie opened this issue Oct 13, 2019 · 134 comments
Closed

[cloud_firestore] Xcode build extremely slow #349

kroikie opened this issue Oct 13, 2019 · 134 comments
Labels
impact: critical Usually a production crash with high user impact. (P1) impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) platform: ios Issues / PRs which are specifically for iOS. plugin: cloud_firestore type: bug Something isn't working

Comments

@kroikie
Copy link
Collaborator

kroikie commented Oct 13, 2019


EDIT (@Salakar): See #2751 for a solution.


Summary of Issue

Simply adding cloud_firestore to pubspec.yaml results in a huge increase in iOS xcode build times. The issue can be recreate with nothing more than a simple flutter create application and minor changes to pubspec.yaml.

MacOS Mojave 10.14.6
Xcode 10.3
> flutter --version
Flutter 1.8.4-pre.91 • channel master • https://github.com/flutter/flutter.git
Framework • revision 8fdd759225 (11 hours ago) • 2019-08-04 00:56:23 -0400
Engine • revision c8f4f5d5cc
Tools • Dart 2.5.0 (build 2.5.0-dev.1.0 9bb446aae1)
> flutter create test_cloud_firestore
> cd test_cloud_firestore

Without cloud_firestore

Just to show that it is specifically the cloud_firestore plugin that causes this issue I will add some other firebase plugins to pubspec.yaml:

firebase_core: ^0.4.0+1
firebase_analytics: ^4.0.2

Now we build the app:

> flutter packages get
> time flutter build ios
....
Xcode build done. 
real	0m41.014s

Okay that looks reasonable.

With cloud_firestore

Simply add the latest version of cloud_firestore plugin to pubspec.yaml (no other changes):

cloud_firestore: ^0.12.9

Now we build the application again:

> flutter packages get
> time flutter build ios
....
Xcode build done. 
real	6m40.982s

Yes... that is right. A six minute increase in iOS build times just from adding the cloud_firestore plugin to pubspec.yaml. Again, no changes were made to the flutter create generated application, this is simply changes to pubspec.yaml.

Logs

I did confirm that this issue persists on other flutter channels as well as other later versions of cloud_firestore plugin.

> flutter doctor -v
[✓] Flutter (Channel master, v1.8.4-pre.91, on Mac OS X 10.14.6 18G84, locale en-US)
    • Flutter version 1.8.4-pre.91 at /Users/taza/Applications/flutter
    • Framework revision 8fdd759225 (11 hours ago), 2019-08-04 00:56:23 -0400
    • Engine revision c8f4f5d5cc
    • Dart version 2.5.0 (build 2.5.0-dev.1.0 9bb446aae1)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at /Users/taza/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.36.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.3.0
@kroikie
Copy link
Collaborator Author

kroikie commented Oct 13, 2019

@walsha2

The issue at flutter/flutter#37582 has been closed and moved here. Future collaboration on this issue will be done here.

@walsha2
Copy link

walsha2 commented Oct 13, 2019

@kroikie Ok. So does this new issue lose all the traction of flutter/flutter#37582 in terms of user reaction and up votes. From what I gather, that is what determines what gets worked on in the priority queue.

I just want this "new" issue to have the same level of priority as the previous one did, which seemed to be a concern that was pretty widespread in the community.

@kroikie
Copy link
Collaborator Author

kroikie commented Oct 13, 2019

@walsha2 no we will still refer to the linked issue for reference during triage. The goal is to collect all future FlutterFire collaboration in a single place.

@rdmo94
Copy link

rdmo94 commented Oct 16, 2019

@kroikie Still no solution for this? I have been struggling with this issue for days...

@kroikie kroikie added the impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) label Oct 16, 2019
@iapicca iapicca changed the title Xcode build extremely slow - only when using cloud_firestore plugin [cloud_firestore] Xcode build extremely slow Oct 23, 2019
@iapicca iapicca added the type: bug Something isn't working label Oct 23, 2019
@kbrmimbyl
Copy link

Not sure if others have noticed: this whole "extremely slow" issue didn't exist in Flutter 1.0.0.

@rdmo94
Copy link

rdmo94 commented Oct 24, 2019

Update: Building my application in an iOS Simulator is still very slow (sometimes above 500 seconds) and the problem seems to arise when using cloud_firestore plugin. So now i use my device instead. I build it through Xcode and attach flutter afterwards with "flutter attach -d device name" in terminal.

@orestesgaolin
Copy link

orestesgaolin commented Oct 27, 2019

I also encounter this problem on i7 MacBook Pro. Adding cloud_firestore increased my build time to simulator from 1-2 minutes (60-120 sec) to more than 7-10 minutes and release build on CI to over 15-20 minutes.

Sample output from deploying to simulator:

Launching lib/main_dev.dart on iPhone 11 in debug mode...
Xcode build done.                                           458,6s

This was not clean build but some changes to dart code have been made. Previous clean build with pod install took over 600 sec.


Edit: switching to current master dropped this number to about 250-270 sec on a clean build!

[✓] Flutter (Channel master, v1.10.15-pre.271, on Mac OS X 10.15 19A602, locale pl-PL)

@kbrmimbyl
Copy link

kbrmimbyl commented Oct 28, 2019 via email

@rdev-software
Copy link

Same here, I started considering buying new machine...but i see that thats not really the case. Any workaround ? is there any chance to include firestore as pre-compiled binary ?

@FaisalAbid
Copy link

FaisalAbid commented Nov 1, 2019

Here is my flutter doctor and pubspec if its useful, the same issue is happening to me. Very slow to build on iOS

[✓] Flutter (Channel master, v1.10.15-pre.362, on Mac OS X 10.15.1 19B88, locale
    en-US)
 
[✓] Android toolchain - develop for Android devices (Android SDK version
    29.0.0-rc2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2)
[✓] Chrome - develop for the web
[!] Android Studio (version 3.5)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Android Studio (version 3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.8)
[✓] VS Code (version 1.39.2)
[✓] Connected device (3 available)
dependencies:
  flutter:
    sdk: flutter
  fluro: "^1.5.1"
  flutter_secure_storage: ^3.3.1+1
  firebase_core: ^0.4.0+9
   # Add the dependency for the FlutterFire plugin for Google Analytics
  firebase_analytics: ^5.0.2

  # Add the dependencies for any other Firebase products you want to use in your app
  # For example, to use Firebase Authentication and Cloud Firestore
  firebase_auth: ^0.14.0+5
  google_sign_in: ^4.0.11
  cloud_firestore: ^0.12.9+5

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  avatar_glow: ^1.0.0

Screen Shot 2019-11-01 at 1 23 29 PM

@logemann
Copy link

logemann commented Nov 3, 2019

Can confirm the super ugly build times with Firestore too. Sometimes getting like peak 230 seconds on a quite fast Macbook Pro. This is really barely usable at this point. Unfortunately we need Firestore.

This was my latest build
Running Xcode build...

├─Assembling Flutter resources... 4,5s
└─Compiling, linking and signing... 12,5s
Xcode build done. 130,7s

@csells
Copy link
Contributor

csells commented Nov 14, 2019

adding @collinjackson for his thoughts on this issue

@alevinetx
Copy link

I found this thread, and its source, having encountered the same problem -- ios build time dramatically escalated after adding cloud_firestore. I didn't clock it, but I know it was well over 10 minutes, perhaps bordering on 20.

Is there anything I can do to assist, keeping in mind I know very little on objc/swift/pods ? Compounded with having to randomly create bridge files and adding/removing use_frameworks, neither of which do I understand when and why and what and just follow whatever google shows me, ios building is becoming frustrating. So, instead of being afraid to look at the code in fear it may break and never build again, what can I offer?

@rdev-software
Copy link

@alevinetx @csells From what I observed, main problem is constant rebuilding. And those firebase libs are compiling huge amount of some C files. I have Core I7 8700, 32GB, NVME hackintosh which is really snappy...but with this, sometimes it takes minutes to build. On my macbook 15" pro late...its kind of impossible to develop, at is so frustrating

@snadal
Copy link

snadal commented Nov 19, 2019

Worst thing is that bitrise or codemagic can not be used with cloud_firestore, as it crosses the 20 minutes build time :(

I tried many things but no significant improves. Every archive operation takes forever.

@orestesgaolin
Copy link

@snadal @rdev-software @alevinetx maybe try to switch to dev channel for now, build times are a bit shorter there. I also couldn't stand so long build times and switched to Android device.

@logemann
Copy link

Yeah dev channel is way better currently when it comes to build times.

@alevinetx
Copy link

I also noticed my IPA is significantly larger, 16M -> ~50M, and I haven't changed the way I'm doing the build. I could assume a correlation, but I'm honestly lost right now.

@csells csells added impact: critical Usually a production crash with high user impact. (P1) customer: product labels Nov 19, 2019
@ro0t
Copy link

ro0t commented Nov 19, 2019

I also noticed my IPA is significantly larger, 16M -> ~50M, and I haven't changed the way I'm doing the build. I could assume a correlation, but I'm honestly lost right now.

So bad that an uploading plugin takes around 35M 😅this really needs to be fixed. Getting build times up to 300 seconds on a 2018 Macbook Pro...

@LinusU
Copy link
Contributor

LinusU commented Nov 20, 2019

Would just like to chime in and say that I think that in addition to it taking long time to build, it seems like something is broken with the caching as well. If I plug out my phone and then come back to my computer and run "Start debugging" in VS Code again it takes minutes for the "Running Xcode build" step to complete. It's really a productivity killer 😞

@wwwdata
Copy link

wwwdata commented Nov 20, 2019

Would just like to chime in and say that I think that in addition to it taking long time to build, it seems like something is broken with the caching as well. If I plug out my phone and then come back to my computer and run "Start debugging" in VS Code again it takes minutes for the "Running Xcode build" step to complete. It's really a productivity killer 😞

Yes for me too :( This is why I use the flutter attach command a lot more often nowadays 😄

@LinusU
Copy link
Contributor

LinusU commented Nov 20, 2019

This is why I use the flutter attach command a lot more often nowadays

I can only use the attach command from VS Code when I'm working on my Add2App Flutter app, it doesn't work for the normal Flutter app I'm working on.

Is there any trick to getting this working?

@fredriccliver
Copy link

Yes for me too :( This is why I use the flutter attach command a lot more often nowadays 😄

Is that makes could be reconnected with vscode with the device?
but I was stuck on here.

➜ flutter-test git:(master) ✗ flutter attach
Checking for advertised Dart observatories...
Waiting for a connection from Flutter on MyDevice...

@shaimo
Copy link

shaimo commented May 14, 2020

@mzkai you think this is slow?? On my Mac it takes over 2000 seconds (yes, more than 30 minutes). Luckily there is hot load. But each time something goes wrong and I need to rebuild I have to go do other things while it compiles...

@thomaslecoeur
Copy link

Same issue on empty flutter project with cloud_firestore: ^0.13.5, build time was over than 15 minutes (surrendered after 15 minutes)

@shahzadc
Copy link

man using firebase in flutter causes a lot more issues than i thought it would.

@transmissions11
Copy link

Still having this issue, its nuts!

@transmissions11
Copy link

transmissions11 commented May 24, 2020

300+ Seconds to Build for a Hello World app!

@shahzadc
Copy link

I'm not sure what changed but all of a sudden my builds went from taking 300 seconds to anywhere between 40 seconds to 150 seconds.

Not ideal, but way better than before. The only thing i changed was i removed the 'ios' folder and ran 'flutter create ios .' because there was a separate issue I was facing.

If someone else wants to try this and see if they get the same result, maybe there's something here.

@KeenStratium
Copy link

I'm not sure what changed but all of a sudden my builds went from taking 300 seconds to anywhere between 40 seconds to 150 seconds.

Not ideal, but way better than before. The only thing i changed was i removed the 'ios' folder and ran 'flutter create ios .' because there was a separate issue I was facing.

If someone else wants to try this and see if they get the same result, maybe there's something here.

Can you verify on your Xcode if you're using the new build system or the legacy build system? re-creating the iOS part would use the default settings and the build system is defaulted to new. However, before I've been experiencing issues using the new system but maybe something has changed now.

@KeenStratium
Copy link

I am planning to drop direct firebase integration on my app and instead use cloud functions, however, we're using semi-realtime-chat functionality and media uploads. These are hard to do with just cloud functions.

I'm still hoping i could trim down the build time from 30-60 mins to 10mins and hoping too there are no issues with OneSignal and Firebase as I do have a ton of issues before when I use them together.

@shahzadc
Copy link

I'm not sure what changed but all of a sudden my builds went from taking 300 seconds to anywhere between 40 seconds to 150 seconds.
Not ideal, but way better than before. The only thing i changed was i removed the 'ios' folder and ran 'flutter create ios .' because there was a separate issue I was facing.
If someone else wants to try this and see if they get the same result, maybe there's something here.

Can you verify on your Xcode if you're using the new build system or the legacy build system? re-creating the iOS part would use the default settings and the build system is defaulted to new. However, before I've been experiencing issues using the new system but maybe something has changed now.

It's using the new build system

@shahzadc
Copy link

I'm not sure what changed but all of a sudden my builds went from taking 300 seconds to anywhere between 40 seconds to 150 seconds.
Not ideal, but way better than before. The only thing i changed was i removed the 'ios' folder and ran 'flutter create ios .' because there was a separate issue I was facing.
If someone else wants to try this and see if they get the same result, maybe there's something here.

What is the Flutter channel that you used to run flutter create ios?

i'm using the stable channel

@MauScheff
Copy link

MauScheff commented May 28, 2020 via email

@transmissions11
Copy link

@shahzadc My build time went down to 40 seconds as well (from 300), but I have made 0 changes to my flutter environment or anything!

@jmagman
Copy link
Contributor

jmagman commented May 28, 2020

This comment was buried (note these changes are now on all channels):

iOS development only (not yet implemented for macOS): If you are on v1.15.4 or later (master and dev at the moment), flutter/flutter#51453 will allow you to remove install! 'cocoapods', :disable_input_output_paths => true in your ios/Podfile. The first build will still be slow, but CocoaPods will cache these frameworks more aggressively for subsequent builds.

@lunedam-git
Copy link

This comment was buried (note these changes are now on all channels):

iOS development only (not yet implemented for macOS): If you are on v1.15.4 or later (master and dev at the moment), flutter/flutter#51453 will allow you to remove install! 'cocoapods', :disable_input_output_paths => true in your ios/Podfile. The first build will still be slow, but CocoaPods will cache these frameworks more aggressively for subsequent builds.

Still rubbish on v1.18.0-11.1.pre (beta) for me ...

@mafreud
Copy link
Contributor

mafreud commented Jun 2, 2020

My production app was...
EZMRl8lU4AUxjT0

@nilsreichardt
Copy link
Contributor

macOS and iOS builds need 20 - 30 Min. (MacBook Pro 2017) :(

@Ehesp
Copy link
Member

Ehesp commented Jun 4, 2020

We're actively investigating this as part of #2582 - we're working on Firestore right now, so we'll get it sorted.

@Salakar
Copy link
Member

Salakar commented Jun 12, 2020

Hey everyone, we have something for you to try that we hope will help (showing a 60-80% reduction in build times in some of our tests) ⚡

Please see the update issue I've created for this specifically to learn more: #2751

Lets discuss trying out the solution over there, thanks

@jonmountjoy
Copy link

jonmountjoy commented Jun 27, 2020

I appreciate that solution @Salakar - thank you! I wonder if there's also something going on with compilation caching, in general. Xcode doesn't usually rebuild the world every time anything changes for a Swift app, and React Native apps don't seem to rebuild Firebase every time either. The solution above may work for Firebase (at a third-party dependency cost), but I wonder if there's something else that can cache all parts of a build process instead?

@Salakar
Copy link
Member

Salakar commented Jul 3, 2020

@jonmountjoy I appreciate that solution @Salakar - thank you! I wonder if there's also something going on with compilation caching, in general. Xcode doesn't usually rebuild the world every time anything changes for a Swift app, and React Native apps don't seem to rebuild Firebase every time either. The solution above may work for Firebase (at a third-party dependency cost), but I wonder if there's something else that can cache all parts of a build process instead?

There could be potential issues with caching, but in the scope of FlutterFire/RNFirebase this isn't something we ourselves can address really. I spent several days looking into/debugging Xcode build performance for this issue and there was nothing left in the way of optimisation other than the pre-compiled frameworks unfortunately. There may very well be some underlying issue with the tooling that's aggressively clearing cache or something similar - something I didn't have a chance to look into, but even then it won't solve the first time build uncached slowness either.


I'm going to go ahead and close this issue, it's been a few weeks now and there's not been any major push back against the posted solution above and it has also shown promising results for a lot of people 🎉 We can always discuss this further on #2751 if needed.

Thank you everyone for participating

@Salakar Salakar closed this as completed Jul 3, 2020
@ollyde
Copy link

ollyde commented Aug 11, 2020

@Salakar why was this closed? The Flutter/React native libs simply build this lib with a wrapper layer to connect to it; nothing special.

This plugin is the main reason why we dislike Firestore and try to migrate away from it. Still, on our Flutter projects, it's extremely slow. Not only building but the pod install step now takes over 5 minutes for Installing gRPC-Core..

Why is it that the web version works perfectly well with a light JS library but the mobile versions (React Native, Flutter, Native) have this awful library?

@nilsreichardt
Copy link
Contributor

Flutter macOS is still effected by this issue. Should we create a new issue for Flutter macOS?

@nilsreichardt
Copy link
Contributor

I created a new issue for Flutter macOS XCode problem (#3185), because this issue only deals with iOS XCode problem (pls update, if you also use Flutter macOS and cloud_firestore)

@firebase firebase locked and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: critical Usually a production crash with high user impact. (P1) impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) platform: ios Issues / PRs which are specifically for iOS. plugin: cloud_firestore type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests