pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 584 forks source link

Adding this plugin makes my build take forever.. Please help me work out why? #228

Closed ZaLiTHkA closed 5 years ago

ZaLiTHkA commented 5 years ago

Please note: the same project on a colleague's computer doesn't take as long as mine does, but it does take notably longer than before we added it.. I'm hoping someone could help me work out what's going on here.

After not finding anything helpful about why the project I'm working on started taking over 10 minutes to build, I decided to create a blank project and start adding Cordova plugins one-by-one, which led me to this specific plugin causing massive delays for my build.

The steps below cover all the custom plugins our project uses, so for simplicity I'm just going to copy/paste the notes I took through my debugging process:


all times listed below are specifically the Cordova build times, as taken from the command ionic cordova build android --verbose. this timer is not affected by the initial Ionic TS and SCSS compilation steps at the start of the process.


Just for reference, before I started checking the plugins, I did a comparison between building our actual project using Ionic CLI wrapper vs the Cordova CLI directly, both with the --verbose flag. The output for both can be seen in this Gist.

For the sake of environment information:

$ ionic info
√ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.2 (C:\Users\agreeff\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.3, (and 7 other plugins)

System:

 (D:\workspace\devkits\android-sdk)
   NodeJS            : v8.11.4 (C:\Program Files\nodejs\node.exe)
   npm               : 5.10.0
   OS                : Windows 10

Note: I use Git Bash as my primary shell, since I'm a Linux man forced to operate in a Windows environment.. So the following output is straight from the standard Windows command prompt, to avoid the Bash env mashing in Windows.

C:\>set
ALLUSERSPROFILE=C:\ProgramData
ANDROID_HOME=D:\workspace\devkits\android-sdk
ANT_HOME=C:\apache-ant
APPDATA=C:\Users\agreeff\AppData\Roaming
asl.log=Destination=file
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=AGREEFF2
ComSpec=C:\WINDOWS\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
ESET_OPTIONS=                                                                                                                                                                                                                                                                                                                                                                                                                                             
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
FP_NO_HOST_CHECK=NO
GOROOT=C:\Go\
GRADLE_HOME=C:\gradle
GYP_MSVS_VERSION=2015
HOME=C:\Users\agreeff
HOMEDRIVE=H:
HOMEPATH=\
HOMESHARE=\\sentinel\agreeff
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_172
LOCALAPPDATA=C:\Users\agreeff\AppData\Local
LOGONSERVER=\\PALADIN
M2_HOME=C:\apache-maven
MAVEN_REPO_PASS=AP794XjMqJNWSjJBbjD4193QXQs
MAVEN_REPO_URL=http://myfootcount.com:8000/artifactory
MAVEN_REPO_USER=agreeff
MOZ_PLUGIN_PATH=C:\PROGRAM FILES (X86)\FOXIT SOFTWARE\FOXIT READER\plugins\
NORTECH_BUILDS_ROOT=Z:\dev-builds
NUMBER_OF_PROCESSORS=8
OneDrive=D:\OneDrive - Nortech International
OPENSSL_CONF=C:\OpenSSL-Win32\bin\openssl.cfg
OS=Windows_NT
Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Oracle\VirtualBox;c:\program files (x86)\graphicsmagick-1.3.21-q8;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\HashiCorp\Vagrant\bin;C:\Go\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Pandoc\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\nodejs\;C:\Users\agreeff\.dnx\bin;C:\Program Files\AutoHotkey;C:\apache-ant\bin;C:\Ruby22\bin;C:\Python27;C:\Python27\Scripts;C:\apache-maven\bin;C:\gradle\bin;C:\Users\agreeff\AppData\Local\Microsoft\WindowsApps;C:\Users\agreeff\.dnx\bin;C:\Program Files\AutoHotkey;C:\Program Files\Oracle\VirtualBox;D:\workspace\devkits\android-sdk\platform-tools;D:\workspace\devkits\android-sdk\tools;C:\apache-ant\bin;C:\Ruby22\bin;C:\Python27;C:\Python27\Scripts;C:\apache-maven\bin;C:\gradle\bin;C:\Users\agreeff\AppData\Local\Microsoft\WindowsApps;D:\workspace\env-tools\scripts-live;C:\Program Files\Heroku\bin;C:\Users\agreeff\AppData\Local\hyper\app-2.0.0\resources\bin;C:\Users\agreeff\AppData\Local\Microsoft\WindowsApps;C:\Users\agreeff\AppData\Local\Yarn\bin;C:\Users\agreeff\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\agreeff\AppData\Roaming\npm
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=3c03
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
PYTHON_HOME=C:\Python27
PYTHON_SCRIPTS=C:\Python27\Scripts
RUBY_HOME=C:\Ruby22
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\agreeff\AppData\Local\Temp
TMP=C:\Users\agreeff\AppData\Local\Temp
USERDNSDOMAIN=NORTECHZA.NET
USERDOMAIN=NORTECHZA
USERDOMAIN_ROAMINGPROFILE=NORTECHZA
USERNAME=agreeff
USERPROFILE=C:\Users\agreeff
VBOX_HOME=C:\Program Files\Oracle\VirtualBox
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
windir=C:\WINDOWS
ZaLiTHkA commented 5 years ago

Just discovered something interesting: the previous version of our app ran on Android 4.4 and higher, so in order to create a build that I could test on an older device, I dropped the ANDROID_SUPPORT_VERSION to 19.+. Now the build completes in 44s.

How would this make a difference here?

shnist commented 5 years ago

hi @ZaLiTHkA , thanks for raising this issue. A new version of the plugin has been release, 2.1.0, which now allows you to specify a compatible android_support_version without the need to use cordova-android-support-gradle-release.

cordova plugin add cordova-plugin-file-opener2  --variable ANDROID_SUPPORT_VERSION=27.+

The reason I suggest this is that it could be a combination of the two plugins that causes your build to be slow. Would be good to know if this is the case or not.

Cheers

ZaLiTHkA commented 5 years ago

After a great deal of trial and error and re-re-configuring my Java environment, I can only put this down to some compatibility between numerous different build tools.. I actually ended up with the same slow build times with a few other Cordova-based projects as well, one of which doesn't need this plugin. Guess that's just the nature of software issues, the root cause for some issues aren't all that clear.

Either way, if anyone else does find this thread looking for help with slow Gradle builds, while I can't pinpoint exactly what caused it, I got my build times back down to the expected one or two minutes by removing my custom installation of Gradle. I suspect this may have been an issue where my custom Gradle installation was conflicting with the Gradle Wrapper, all thanks to MS and their horrid handling of environment configuration in Windows.

Anyways, I don't have much experience with Gradle itself (read lots about it though), so going forward I'll simply rely on the Gradle Wrapper based usage that comes bundled with the Phonegap/Cordova project build process.


@shnist, thanks for the note, I saw your response pop up while I was typing.. Since this doesn't seem to be related to this plugin after all, I don't think there's any need to debug it further. Feel free to open this one again if you would like me to test anything specific, but otherwise I'm closing this one as a non-issue.