UI Freezes in JetBrains IDE Plugins and How to Avoid Them
In a Nutshell
UI freezes in JetBrains IDEs occur when long-running read actions or EDT operations block the write lock needed for UI updates. The fix requires using non-blocking read actions (`readAction.nonBlocking()`), splitting work into small cancellable chunks with `ProgressManager.checkCanceled()` checks, and ensuring background threads don't hold read locks during expensive computations. A long non-cancellable read action freezes the entire IDE.
These notes were generated by AI and may contain inaccuracies.
Patrick introduces Yuri from the platform team to discuss UI freezes in the JetBrains platform, particularly in plugins. The discussion covers freezes that occur even on high-end hardware like beefy MacBooks or PCs, where the UI becomes unresponsive to mouse and keyboard events for brief but annoying periods.
The core issue is the event dispatch thread (UI thread) becoming frozen while performing expensive operations. A common example shown in their internal system called Den demonstrates networking code being executed directly on the dispatch thread, which blocks event processing entirely.
Please never ever ever ever go internet from dispatch thread
The real problem is not that plugins attempt network operations, but that they execute them immediately on the UI thread, blocking everything. The UI thread handles all events and the event queue, so when it performs expensive work like network calls, it cannot dispatch events, repaint, or respond to user input.
The straightforward solution for dispatch thread issues is moving such code to background threads using threads, coroutines, callbacks, futures, or asynchronous frameworks. Many developers already use background threads for project analysis, code loading, reading, and processing.
Newer freeze reports present cryptic stack traces that are difficult to understand and are not obviously related to the event dispatch thread. These freezes don't show the cause directly, requiring deeper analysis.
Sign in to read the full notes
Get access to AI-generated notes, topic timestamps, and more.