Skip to content

Commit

Permalink
Merge pull request #498 from gradle/asodja/as-profiler-fix
Browse files Browse the repository at this point in the history
Fix deadlock for Android Studio sync
  • Loading branch information
asodja authored Jun 1, 2023
2 parents 0681bbc + 7b4e509 commit e4bf28b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ Here is an example:
title = "Android Studio Sync"
# Measure an Android studio sync
# Note: Android Studio Bumblebee (2021.1.1) or newer is required
# Note2: If you are testing with Android Studio Giraffe (2022.3) or later
# you need to have local.properties file in your project with sdk.dir set
android-studio-sync {
# Override default Android Studio jvm args
# studio-jvm-args = ["-Xms256m", "-Xmx4096m"]
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ androidStudioTests {
val autoDownloadAndRunInHeadless = providers.gradleProperty("autoDownloadAndRunInHeadless").orNull == "true"
runAndroidStudioInHeadlessMode.set(autoDownloadAndRunInHeadless)
autoDownloadAndroidStudio.set(autoDownloadAndRunInHeadless)
// Giraffe (2022.3.1.2) Canary 2
testAndroidStudioVersion.set("2022.3.1.2")
// Hedgehog (2023.1.1.6) Canary 6
testAndroidStudioVersion.set("2023.1.1.6")
testAndroidSdkVersion.set("7.3.0")
// For local development it's easier to setup Android SDK with Android Studio, since auto download needs ANDROID_HOME or ANDROID_SDK_ROOT
// to be set with an accepted license in it. See https://developer.android.com/studio/intro/update.html#download-with-gradle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public static void waitOnPreviousGradleSyncFinish(Project project) {
* It seems there is no better way to do it atm.
*/
public static void waitOnBackgroundProcessesFinish(Project project) {
DumbService.getInstance(project).runReadActionInSmartMode(() -> {
IdeFrame frame = WindowManagerEx.getInstanceEx().findFrameFor(project);
StatusBarEx statusBar = frame == null ? null : (StatusBarEx) frame.getStatusBar();
if (statusBar != null) {
statusBar.getBackgroundProcesses().forEach(it -> waitOnProgressIndicator(it.getSecond()));
}
});
// Run a dummy read action just so we wait on all indexing done
DumbService.getInstance(project).runReadActionInSmartMode(() -> {});
IdeFrame frame = WindowManagerEx.getInstanceEx().findFrameFor(project);
StatusBarEx statusBar = frame == null ? null : (StatusBarEx) frame.getStatusBar();
if (statusBar != null) {
statusBar.getBackgroundProcesses().forEach(it -> waitOnProgressIndicator(it.getSecond()));
}
}

private static void waitOnProgressIndicator(ProgressIndicator progressIndicator) {
Expand Down

0 comments on commit e4bf28b

Please sign in to comment.