Bug 16622 - Cascading Rebuild due to using Libraries with Android Resources
Summary: Cascading Rebuild due to using Libraries with Android Resources
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 4.10.1
Hardware: PC Mac OS
: --- normal
Target Milestone: 4.12.0 (KitKat)
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-12-05 14:42 UTC by Jonathan Pryor
Modified: 2013-12-17 02:21 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Jonathan Pryor 2013-12-05 14:42:18 UTC
This is like Bug #15162 but different.

In general, rebuilds-with-no-changes should be FAST. ("FAST" defined as "< 5s, if not instantaneous.")

Repro:

  $ git clone https://github.com/perpetual-mobile/SlowAndroidDeploymentWithXamarin.git
  $ cd SlowAndroidDeploymentWithXamarin

  $ time xbuild /v:diag > b1.txt
  real	0m24.908s
  user	0m29.762s
  sys	0m1.366s

  $ time xbuild /v:diag > b2.txt
  real	0m13.946s
  user	0m27.321s
  sys	0m0.977s

  $ time xbuild /v:diag > b3.txt

  real	0m11.642s
  user	0m26.210s
  sys	0m0.944s

So things DID speed up between the initial build and rebuild, but ~14s is way too slow.

Why? Rebuild cascade:

> 		Target _CompileJava needs to be built as input file 'obj/Debug/android/src/com/google/android/gms/R.java' is newer than output file 'obj/Debug/android/bin/classes.dex'
> 		Target _CompileDex needs to be built as input file 'obj/Debug/android/bin/classes/mono/android/support/v4/view/ViewPager_OnPageChangeListenerImplementor.class' is newer than output file 'obj/Debug/android/bin/classes.dex'
>   1246.726 ms  _CompileJava                                            1 calls
>   7929.759 ms  _CompileDex                                             1 calls

_CompileDex is ~8s, and _CompileJava is ~1.2s. Together, that's ~9s of the ~12s build time, entirely avoidable because gms/R.java shouldn't be changing.
Comment 1 Jonathan Pryor 2013-12-06 15:53:32 UTC
The problem is `aapt` and the _GenerateJavaDesignerForComponent Target :

> 				Tool /opt/android/sdk/build-tools/19.0.0/aapt execution started with arguments: package --non-constant-id -f -m -M /opt/android/sdk/extras/google/google_play_services/libproject/google-play-services_lib/AndroidManifest.xml -J obj/Debug/android/src -S obj/Debug/res/ -S /opt/android/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res -I /opt/android/sdk/platforms/android-19/android.jar --auto-add-overlay 

The above command generates the the obj/Debug/android/src/com/google/android/gms/R.java file, and every time `aapt` executes the timestamp is updated.

> $ ls -l obj/Debug/android/src/com/google/android/gms/R.java
> -rw-r--r--  1 jon  staff  27119 Dec  6 15:50 obj/Debug/android/src/com/google/android/gms/R.java
> $ /opt/android/sdk/build-tools/19.0.0/aapt package --non-constant-id -f -m -M /opt/android/sdk/extras/google/google_play_services/libproject/google-play-services_lib/AndroidManifest.xml -J obj/Debug/android/src -S obj/Debug/res/ -S /opt/android/sdk/extras/google/google_play_services/libproject/google-play-services_lib/res -I /opt/android/sdk/platforms/android-19/android.jar --auto-add-overlay
> $ ls -l obj/Debug/android/src/com/google/android/gms/R.java
> -rw-r--r--  1 jon  staff  27119 Dec  6 15:52 obj/Debug/android/src/com/google/android/gms/R.java
Comment 2 Jonathan Pryor 2013-12-09 22:31:42 UTC
Fixed in monodroid/aa304cdf.
Comment 3 Jonathan Pryor 2013-12-16 12:16:39 UTC
Marking as fixed as per Comment #2.
Comment 4 Prashant manu 2013-12-17 02:21:16 UTC
I have checked this issue with following builds:
X.S 4.2.3(build 20)
Mono 3.2.6
X.Android 4.11.0-210


This is my output:
nischals-Mac-mini:~ nischal$ git clone https://github.com/perpetual-mobile/SlowAndroidDeploymentWithXamarin.git
Cloning into SlowAndroidDeploymentWithXamarin...
remote: Counting objects: 27, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 27 (delta 3), reused 27 (delta 3)
Unpacking objects: 100% (27/27), done.
nischals-Mac-mini:~ nischal$ cd SlowAndroidDeploymentWithXamarin
nischals-Mac-mini:SlowAndroidDeploymentWithXamarin nischal$ time xbuild /v:diag > b1.txt

real 0m17.588s
user 0m34.424s
sys 0m1.107s
nischals-Mac-mini:SlowAndroidDeploymentWithXamarin nischal$ $ time xbuild /v:diag > b2.txt
-bash: $: command not found
nischals-Mac-mini:SlowAndroidDeploymentWithXamarin nischal$ time xbuild /v:diag > b2.txt

real 0m2.017s
user 0m1.811s
sys 0m0.227s
nischals-Mac-mini:SlowAndroidDeploymentWithXamarin nischal$ time xbuild /v:diag > b3.txt

real 0m2.014s
user 0m1.807s
sys 0m0.225s