apache / cordova-cli

Apache Cordova CLI
Apache License 2.0
940 stars 340 forks source link

'cordova build ios' taking over 5 minutes to compile and displaying verbose info in terminal #608

Open rolinger opened 1 year ago

rolinger commented 1 year ago

Bug Report

cordova build ios is displaying verbose info even though --verbose is not used. Its like its on by default for iOS.

Problem

Something has to have changed or isn't working as expected. I just upgraded to Cordova 11 and my projects that used to take 30-45 to compile with cordova build ios are now taking 5 to 6 minutes. As well, I am seeing all the verbose info when I am not using the --verbose option which is making me think its specifically the verbose that is causing the slowness. It's like --verbose is on by default on iOS. Granted, I have always seen verbose info when using cordova build ios but its never bothered me as much because my app would usually compile in 30 seconds. But now i am seeing its thousands of useless terminal messages just soaking up buffer and slowing things down as each 5,000 character path call is being written to the terminal.

On my windows machine: cordova build android takes about 10 seconds AND only spits out about 60 lines of terminal messages. So something def keeps going the wrong direction with iOS.

What is expected to happen?

Compile in 30 seconds and not show thousands of lines of terminal messages.

What does actually happen?

Compiles in nearly 6 minutes and show thousands of lines of terminal messages.

Information

Command or Code

cordova build ios

Environment, Platform, Device & version info

Mac: 3.6Ghz quad Core i3, 8Gb memory MacOS: 13.2.1 Ventura Xcode 14.2 Cordova@11 Cordova-ios@6.2.0

Checklist

breautek commented 1 year ago

But now i am seeing its thousands of useless terminal messages just soaking up buffer.

What I believe you're seeing is the stdout underlying tool xcodebuild (maybe confirm?), which is quite spammy. I'm not too familiar with this repo but what we could probably unhook the stdout pipe to avoid it's stdout from going to the console (since we spawn it, I assume) and only pipe the stdout our verbose flag is enabled. But if a compilation error should occur, the feedback information will be lost (and quite often the real error causing the compilation can be pages up in the stdout from when the process exits) and you'll be required to rerun the build with --verbose.

I don't have access to a mac machine, but xcodebuild does have a -quiet flag, which supposedly hides all stdout except for warnings and errors. That sounds like the best path forward imo, and we can omit the flag if our --verbose flag is enabled.

rolinger commented 1 year ago

Thanks. quite spammy is a bit of an understatement. lol.

Is there no way to pass that flag from the existing cordova cli? Or at least temporarily turn it off in the background before running cordova build ios? With almost 6 minute build times I am really hoping disabling verbose or turning on -quiet will greatly speed up my build compiles.

It was about 1 minute (which was tolerable) with Cordova 10, and except for two or three plugin updates, my app is identical on @11 as it was on @10, but now it is a quite painful process.

breautek commented 1 year ago

For the time being, you can try utilising Build Flag to pass the -quiet flag through...

cordova build ios --buildFlag="-quiet"

I believe this gets passed to the xcodebuild command.

If you use the build.json file, you might be able to add it there as well...

rolinger commented 1 year ago

I did a few test and found something interesting:

`ionic cordova build ios --buildFlag="-quiet"` - 
   -quiet is ignored, there is no xcodeBuildArg displayed in the terminal
   - and all the verbose info is sent to console, overflowed with over 30,000 lines
   - takes nearly 6 minutes to complete
`cordova build ios --buildFlag="-quiet" 
  - I see : Adding xcodebuildArg: [ '-quiet'] in the terminal
  - And it works, it quiets the noise down...ALOT...but still over 1000 lines
  - And unfortunately, it did not reduce the build time, this one was longer at 6min 30 seconds

So even if you implemented a fix for the Cordova CLI that somehow invokes or interpets the -quiet flag, I am not certain Ionic will honor it. I am going to file a bug with Ionic-CLI now.

Regardless of verbose output or not, the build process is painfully, and consistently, slow - taking 6+ minutes on every build. What changed that caused a 500% in build time? Is everyone seeing this, or am I just special?

breautek commented 1 year ago

Regardless of verbose output or not, the build process is painfully, and consistently, slow - taking 6+ minutes on every build. What changed that caused a 500% in build time? Is everyone seeing this, or am I just special?

I can't really answer this, but I can say that cordova-ios hasn't had any significant changes in awhile (6.2.0 was released ~Feburary 2021). It was built originally for XCode 11 support. There hasn't been any changes in all the XCode versions since that warranted an update to cordova-ios.

I can also say that an i3/8gb machine isn't really a workstation. How is your memory pressure? Are you sure you're not using swap? If you're memory pressure is high and is heavily using your swapfile, everything is going to run sluggish since it's effectively using your hard drive as ram which will be incredibly slow. Compiling, and more specifically the linking step is generally pretty resource hungry task. If you're consuming 6gb/8gb before you even start the build process, you'll likely going to be swapping ram a lot.

rolinger commented 1 year ago

@breautek - I just upgraded my Mac Mini from 8gb to 64Gb. One of the modules is bad so its only 32Gb at the moment. However, even with 32Gb of RAM the ionic cordova build ios still takes a full 6 minutes. Zero improvement over 8Gb of RAM. I doubt when I get the full 64Gb installed that there will be any difference. Cordova 11 is just a hog....the same Mac mini with 8gb RAM on Cordova 10 only took about 2minutes to build. Its 3 times longer now...even with 4x the memory.