Skip to content

🚀 Performance freeze in EDT caused by ExecutorService blocking in Flutter plugin #8478

@AlexV525

Description

@AlexV525

(Generated by GPT-5)

Summary

When changing the editor theme in IntelliJ with the Flutter plugin enabled, the IDE experiences a significant UI freeze (21 seconds). The stack trace indicates that the main thread (EDT) is blocked due to improper handling of ExecutorService lifecycle in FlutterInitializer.sendThemeChangedEvent.

Details

  • Stack trace snippet:
com.intellij.diagnostic.Freeze
    at java.base@21.0.7/jdk.internal.misc.Unsafe.park(Native Method)
    at java.base@21.0.7/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269)
    at java.base@21.0.7/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1763)
    at java.base@21.0.7/java.util.concurrent.ThreadPoolExecutor.awaitTermination(ThreadPoolExecutor.java:1475)
    at java.base@21.0.7/java.util.concurrent.Executors$DelegatedExecutorService.awaitTermination(Executors.java:780)
    at java.base@21.0.7/java.util.concurrent.ExecutorService.close(ExecutorService.java:417)
    at io.flutter.FlutterInitializer.sendThemeChangedEvent(FlutterInitializer.java:306)
    at io.flutter.FlutterInitializer.lambda$setUpThemeChangeNotifications$3(FlutterInitializer.java:240)
    at io.flutter.FlutterInitializer$$Lambda/0x0000026c765eaf30.uiSettingsChanged(Unknown Source)
  • Root cause:
    • A new ScheduledExecutorService is created and closed within the EDT every time the theme changes. Since JDK 21's ExecutorService.close() calls awaitTermination, it blocks the EDT if the scheduled task hasn't finished.

Suggested Fix

  • Use a shared, long-lived ScheduledExecutorService (e.g. IntelliJ's AppExecutorUtil.getAppScheduledExecutorService) instead of creating/closing one on each event.
  • Avoid any blocking calls on the EDT.
  • Remove try-with-resources around executor creation in sendThemeChangedEvent.

Impact

This freeze severely affects developer experience in IntelliJ-based IDEs when using the Flutter plugin.

References

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions