Fix UI freezing by eliminating EDT-blocking patterns#3102
Open
zenisjan wants to merge 1 commit intogephi:masterfrom
Open
Fix UI freezing by eliminating EDT-blocking patterns#3102zenisjan wants to merge 1 commit intogephi:masterfrom
zenisjan wants to merge 1 commit intogephi:masterfrom
Conversation
This commit addresses critical UI responsiveness issues caused by blocking the Event Dispatch Thread (EDT) during long-running operations. ## Critical Issue 1: ProjectControllerImpl Synchronous Execution ### Problem - LongTaskExecutor was configured for synchronous execution (doInBackground=false) - Project operations (open, save, duplicate) blocked the calling thread - Broad synchronized blocks caused unnecessary lock contention ### Solution - Changed LongTaskExecutor to async mode: new LongTaskExecutor(true, "ProjectController", 10) - Refactored openProject() to be non-blocking, returning null immediately - Refactored duplicateWorkspace() to be non-blocking - Refactored saveProject() with proper async pattern - Moved synchronized blocks inside lambdas to only lock during state updates - Callers should use ProjectListener callbacks for completion notification ## Critical Issue 2: Excessive SwingUtilities.invokeAndWait() Usage ### Problem invokeAndWait() blocks the calling thread until EDT completes the runnable, causing UI freezes when called from background threads or during initialization. ### Files Fixed 1. **ReportPanel.java & ProcessorIssuesReportPanel.java** - Changed: Use invokeLater() for deferred UI initialization when not on EDT 2. **EditWindowControllerImpl.java** - Changed: Added AtomicBoolean cache for isOpen() state - Changed: Use invokeLater() instead of invokeAndWait() for state queries 3. **DefaultDataTablesEventListenerBuilder.java** - Changed: Added AtomicReference cache for DataTablesEventListener - Changed: Cache the component reference after first lookup 4. **DesktopImportControllerUI.java** - Changed: Added explicit EDT checks before invokeAndWait calls 5. **ScreenshotTask.java** - Changed: Use CompletableFuture with invokeLater() for file chooser dialog 6. **UIUtils.java** - Changed: Added EDT checks to avoid unnecessary invokeAndWait calls - Changed: Added proper Thread.interrupt() handling ## Test Updates - Updated ProjectControllerImplTest to use CountDownLatch for async operations - Tests now properly wait for ProjectListener callbacks before assertions ## Breaking Changes - openProject(File) now returns null (async) - use ProjectListener.opened() - duplicateWorkspace(Workspace) now returns null (async) - workspace auto-selected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit addresses critical UI responsiveness issues caused by blocking the Event Dispatch Thread (EDT) during long-running operations.
Critical Issue 1: ProjectControllerImpl Synchronous Execution
Problem
Solution
Critical Issue 2: Excessive SwingUtilities.invokeAndWait() Usage
Problem
invokeAndWait() blocks the calling thread until EDT completes the runnable, causing UI freezes when called from background threads or during initialization.
Files Fixed
ReportPanel.java & ProcessorIssuesReportPanel.java
EditWindowControllerImpl.java
DefaultDataTablesEventListenerBuilder.java
DesktopImportControllerUI.java
ScreenshotTask.java
UIUtils.java
Test Updates
Breaking Changes