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

Difficulty Running Android Studio Sync Benchmark in Headless Docker Environment #542

Open
denzap opened this issue Feb 14, 2024 · 2 comments
Labels

Comments

@denzap
Copy link

denzap commented Feb 14, 2024

Hello,

I am currently working on implementing an automatic benchmark run in our project to compare two builds before and after making any changes. The benchmarking process takes place on our Continuous Integration (CI) platform without a display.

While regular scenarios with Gradle tasks are working fine, I encountered an issue when trying to implement the android-studio-sync scenario. Running sync requires Android Studio, and since it is a GUI application, it needs to be somehow launched in headless mode.

I have attempted to start the studio with -Djava.awt.headless=true and used Xvfb to create a virtual display, but these approaches did not resolve the issue. The benchmark run fails with the error java.lang.IllegalStateException: Timeout waiting for incoming connection from plugin.

Is there currently a way to achieve this idea in a Docker environment with a headless setup?

Thank you for your assistance.

@asodja
Copy link
Member

asodja commented Feb 14, 2024

There is a system property flag that can be used-Dstudio.tests.headless=true:

private static final boolean SHOULD_RUN_HEADLESS = Boolean.getBoolean("studio.tests.headless");

This flag has to be passed to gradle-profiler Java process.

Note: It's not documented so it's considered internal. So we might change it in the future.

@denzap
Copy link
Author

denzap commented Feb 20, 2024

Thank you! That's exactly what I needed.

In case anyone else encounters a similar setup, to ensure that the gradle-profiler --benchmark ... command with the android-studio-sync scenario runs successfully, you need to:

  1. Make sure to add the path to the Android SDK in the local.properties file - sdk.dir=....
  2. To set the system property studio.tests.headless=true, I used export JAVA_TOOL_OPTIONS=-Dstudio.tests.headless=true before running gradle-profiler --benchmark ....
  3. Keep in mind that you won't be able to run the benchmark in headless mode on Android Studio Hedgehog - please use Android Studio Iguana 2023.2.1.15 or newer. Sync profiling with Android Studio fails in the headless mode with Hedgehog and Iguana #517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants