fix - UI freeze caused by deadlock in EditorsManager#183
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a startup UI freeze caused by a deadlock between a worker thread creating a RenderManager (which performs Display.syncExec()) and the UI thread removing from the same ConcurrentHashMap bucket in EditorsManager.
Changes:
- Replaced
ConcurrentHashMap.computeIfAbsent()withget()+putIfAbsent()soRenderManagerconstruction happens outside CHM’s internal bucket locks. - Added a contention path that disposes the “losing”
RenderManagerinstance and returns the already-registered instance.
Comments suppressed due to low confidence (1)
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/completion/EditorsManager.java:176
- In the putIfAbsent contention path you dispose a freshly-created RenderManager. RenderManager currently subscribes to the Eclipse IEventBroker (NES accept/reject topics) but does not unsubscribe in dispose(), so a “losing” instance can keep receiving events for the same StyledText as the “winning” instance, causing duplicate accept/reject handling and memory leaks. Please ensure RenderManager.dispose() fully unregisters all listeners/subscriptions so disposing a losing instance is safe.
mgr = new RenderManager(this.languageServer, this.nesProvider, editor);
RenderManager existing = nesRenderManagers.putIfAbsent(editor, mgr);
if (existing != null) {
mgr.dispose();
mgr = existing;
jdneo
approved these changes
May 13, 2026
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.
fix #175
Problem
The UI freezes on startup when a user closes an editor tab while Copilot is still initializing.
Deadlock chain:
getOrCreateNesRenderManager()→ConcurrentHashMap.computeIfAbsent()holds an internal bucket lock → inside the lambda,new RenderManager()→registerListeners()→Display.syncExec()blocks waiting for UI threaddisposeNesRenderManager()→ConcurrentHashMap.remove()blocks waiting for the same bucket lockBoth threads wait on each other indefinitely → permanent UI freeze.
Fix
Replace
computeIfAbsent()withget()+putIfAbsent()so that theRenderManagerconstruction (which callssyncExec) happens outside of any map lock. If two threads race to create a manager for the same editor, the loser disposes its instance and uses the winner's.