Skip to content

Resolves a "Slow operations are prohibited on EDT" exceptions #8458

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

Merged
merged 1 commit into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## Unreleased

### Added

### Removed

### Changed

- Resolved a "Slow operations are prohibited on EDT" exception on Flutter Project creation (#8446, #8447, #8448)

## 87.1

- Register VM service with DTD (#8436)
Expand Down
43 changes: 23 additions & 20 deletions src/io/flutter/utils/FlutterModuleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,31 @@ public static void autoCreateRunConfig(@NotNull Project project, @NotNull PubRoo
public static void autoShowMain(@NotNull Project project, @NotNull PubRoot root) {
if (project.isDisposed()) return;

final VirtualFile main = root.getFileToOpen();
if (main == null) return;
// Offload the slow file system lookup to a background thread.
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final VirtualFile main = root.getFileToOpen();

DumbService.getInstance(project).runWhenSmart(() -> {
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
if (fileEditorManager == null) {
return;
}
FileEditor[] editors = fileEditorManager.getAllEditors();
if (editors.length > 1) {
return;
}
for (FileEditor editor : editors) {
if (editor == null) {
return;
}
VirtualFile file = editor.getFile();
if (file != null && file.equals(main) && FlutterUtils.isDartFile(file)) {
return;
}
// If the file is found, switch back to the EDT to safely update the UI.
if (main != null && main.exists() && !main.isDirectory()) {
DumbService.getInstance(project).runWhenSmart(() -> {
if (project.isDisposed()) return;

final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
if (fileEditorManager == null) return;

FileEditor[] editors = fileEditorManager.getAllEditors();
if (editors.length > 1) return;

for (FileEditor editor : editors) {
if (editor == null) return;

VirtualFile file = editor.getFile();
if (file != null && file.equals(main) && FlutterUtils.isDartFile(file)) return;
}

fileEditorManager.openFile(main, editors.length == 0);
});
}
fileEditorManager.openFile(main, editors.length == 0);
});
}

Expand Down