From 87932873f7a1dd598a014af8f7ec073fe5727275 Mon Sep 17 00:00:00 2001 From: Pawel Lipski Date: Thu, 24 Aug 2023 22:20:00 +0200 Subject: [PATCH] Move all action updates from EDT to BGT --- CHANGE-NOTES.md | 1 + .../actions/base/BaseProjectDependentAction.java | 15 ++++++--------- .../GitRepositoryComboBox.java | 3 ++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGE-NOTES.md b/CHANGE-NOTES.md index 6bf1ac22d0..bc3d66f79f 100644 --- a/CHANGE-NOTES.md +++ b/CHANGE-NOTES.md @@ -1,6 +1,7 @@ # Changelog ## v4.0.3 +- Fixed: all `com.intellij.diagnostic.PluginException: ... ms to call on EDT ...#update@...` errors, hopefully for good (reported by @itxshakil) ## v4.0.2 - Fixed: more `com.intellij.diagnostic.PluginException: ... ms to call on EDT ...#update@...` errors (reported by @itxshakil) diff --git a/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/base/BaseProjectDependentAction.java b/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/base/BaseProjectDependentAction.java index 7492d58d06..7f6b59c16d 100644 --- a/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/base/BaseProjectDependentAction.java +++ b/frontend/actions/src/main/java/com/virtuslab/gitmachete/frontend/actions/base/BaseProjectDependentAction.java @@ -22,17 +22,14 @@ @ExtensionMethod({GitMacheteBundle.class}) public abstract class BaseProjectDependentAction extends DumbAwareAction implements IWithLogger { - // Let's eagerly load these classes so that they do NOT end up loaded from an action `update` method. - // See issues #1692, #1694, #1713. - static { - @SuppressWarnings("nullness:argument") val dummyService = new SideEffectingActionTrackingService(null); - - @SuppressWarnings("nullness:argument") val dummyId = new SideEffectingActionTrackingService.SideEffectiveActionId(null); - } - @Override public final ActionUpdateThread getActionUpdateThread() { - return ActionUpdateThread.EDT; + // This is questionable, as update()/onUpdate() methods are supposed to be `@UIEffect` (able to touch UI directly). + // Still, using ActionUpdateThread.EDT here led to issues like #1692, #1694, #1713: + // update() taking more than 300ms on UI thread due to loading classes and other surprisingly heavyweight operations. + // Let's instead use BGT... somehow this doesn't lead to errors so far + // (but it might cause race conditions at some point (?)). + return ActionUpdateThread.BGT; } @UIEffect diff --git a/frontend/ui/impl/src/main/java/com/virtuslab/gitmachete/frontend/ui/impl/gitrepositoryselection/GitRepositoryComboBox.java b/frontend/ui/impl/src/main/java/com/virtuslab/gitmachete/frontend/ui/impl/gitrepositoryselection/GitRepositoryComboBox.java index fd6605f21c..c192f8ad16 100644 --- a/frontend/ui/impl/src/main/java/com/virtuslab/gitmachete/frontend/ui/impl/gitrepositoryselection/GitRepositoryComboBox.java +++ b/frontend/ui/impl/src/main/java/com/virtuslab/gitmachete/frontend/ui/impl/gitrepositoryselection/GitRepositoryComboBox.java @@ -5,6 +5,7 @@ import com.intellij.dvcs.DvcsUtil; import com.intellij.dvcs.repo.VcsRepositoryManager; +import com.intellij.dvcs.repo.VcsRepositoryMappingListener; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.Project; @@ -46,7 +47,7 @@ public GitRepositoryComboBox(Project project) { val messageBusConnection = project.getMessageBus().connect(); messageBusConnection - .subscribe(VcsRepositoryManager.VCS_REPOSITORY_MAPPING_UPDATED, () -> { + .subscribe(VcsRepositoryManager.VCS_REPOSITORY_MAPPING_UPDATED, () -> { LOG.debug("Git repository mappings changed"); ModalityUiUtil.invokeLaterIfNeeded(ModalityState.NON_MODAL, () -> updateRepositories()); });