briefcase icon indicating copy to clipboard operation
briefcase copied to clipboard

Only run sdkmanager --list_installed when creating a log file

Open mhsmith opened this issue 3 years ago • 1 comments

Currently we run sdkmanager --list_installed within verify_tools in every Briefcase Android command. But this takes at least 1.5 seconds to run on my machine, even in the relatively small SDKs generated by Briefcase itself. When using a user-provided SDK which is affected by this issue, it can take more than 10 seconds.

Since the purpose of this command is to provide information to help diagnose a failure, I've changed it to only run when creating a log file.

PR Checklist:

  • [x] All new features have been tested
  • [x] All new features have been documented
  • [x] I have read the CONTRIBUTING.md file
  • [x] I will abide by the code of conduct

mhsmith avatar Aug 18 '22 21:08 mhsmith

Codecov Report

Merging #832 (a2ee22e) into main (d4dc16d) will increase coverage by 0.13%. The diff coverage is 100.00%.

Impacted Files Coverage Δ
src/briefcase/integrations/android_sdk.py 99.09% <ø> (-0.01%) :arrow_down:
src/briefcase/commands/base.py 98.11% <100.00%> (+0.01%) :arrow_up:
src/briefcase/console.py 100.00% <100.00%> (ø)
src/briefcase/platforms/android/gradle.py 97.14% <100.00%> (+3.93%) :arrow_up:

codecov[bot] avatar Aug 19 '22 02:08 codecov[bot]

Thanks, your changes all look good.

using a single log instance, and passing that through the calls, rather than capturing the log after it has been re-created.

Agreed, and the same is true of the AndroidSDK object, which is currently instantiated multiple times if Briefcase does multiple build / update / run sub-commands. The AndroidSDK currently uses self.command to access various lower-level services like the logger. Refactoring it to bypass the command object and access these things directly would be quite disruptive, so it might be easier to just make sure that there's a single AndroidSDK instance with a reference to the top-level command object.

mhsmith avatar Aug 19 '22 09:08 mhsmith