Skip to content

Commit c9e4ba4

Browse files
authored
fix nes related ui freeze (#183)
1 parent 63b3c1b commit c9e4ba4

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

  • com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/completion

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/completion/EditorsManager.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,21 @@ public RenderManager getOrCreateNesRenderManager(ITextEditor editor) {
162162
return null;
163163
}
164164

165-
return nesRenderManagers.computeIfAbsent(editor,
166-
ed -> new RenderManager(this.languageServer, this.nesProvider, ed));
165+
// Avoid computeIfAbsent() here: the RenderManager constructor calls
166+
// Display.syncExec() via registerListeners(), and computeIfAbsent() holds
167+
// an internal bucket lock during the mapping function. If the UI thread
168+
// concurrently calls remove() on the same bucket, both threads deadlock.
169+
// See https://github.com/microsoft/copilot-for-eclipse/issues/175
170+
RenderManager mgr = nesRenderManagers.get(editor);
171+
if (mgr == null) {
172+
mgr = new RenderManager(this.languageServer, this.nesProvider, editor);
173+
RenderManager existing = nesRenderManagers.putIfAbsent(editor, mgr);
174+
if (existing != null) {
175+
mgr.dispose();
176+
mgr = existing;
177+
}
178+
}
179+
return mgr;
167180
}
168181

169182
/**

0 commit comments

Comments
 (0)