Skip to content

Commit

Permalink
Move all action updates from EDT to BGT
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Aug 24, 2023
1 parent 5cdae91 commit 8793287
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGE-NOTES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,7 +47,7 @@ public GitRepositoryComboBox(Project project) {

val messageBusConnection = project.getMessageBus().connect();
messageBusConnection
.subscribe(VcsRepositoryManager.VCS_REPOSITORY_MAPPING_UPDATED, () -> {
.<VcsRepositoryMappingListener>subscribe(VcsRepositoryManager.VCS_REPOSITORY_MAPPING_UPDATED, () -> {
LOG.debug("Git repository mappings changed");
ModalityUiUtil.invokeLaterIfNeeded(ModalityState.NON_MODAL, () -> updateRepositories());
});
Expand Down

0 comments on commit 8793287

Please sign in to comment.