Repository navigation
Prevent repaint loops when code minings share a host character - #4588
Open
tobiasmelcher wants to merge 1 commit into
Open
tobiasmelcher wants to merge 1 commit into
tobiasmelcher wants to merge 1 commit into
Conversation
Reserve the combined width of annotations sharing a glyph and draw each mining in its own space. Keep host-character measurement consistent and cover sustained repainting with a bounded UI regression test.
Contributor
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.
Saving a Java editor froze Eclipse while Copilot was showing several long code predictions. The editor kept repainting itself and the save never finished.
Thread dumps
I took ten thread dumps of the frozen IDE. There was no deadlock. The UI thread used almost a full CPU core and was always busy painting the editor. It was running the event loop of the progress dialog that organize imports on save had opened. The dialog's background thread had already finished its work. It was waiting in the empty
Display.syncExecthat ends the operation:On Windows, SWT runs a
syncExeconly when no other events are waiting. Because the editor always had a new paint pending, the save could not complete.Cause
A code mining makes room for itself by widening a character in the editor. Two minings at different positions can choose the same character, for example one at the start of a line and one right after it. Each mining sets that character's width to fit only itself, and every width change triggers another paint:
flowchart TD P[Paint editor] --> A[Mining A sets width to 620 px] A --> B[Mining B sets width to 930 px] B --> C{Width changed?} C -- "yes, every time" --> P C -. never .-> S[Save completes]The width never settles, so the editor never stops painting. The two minings were also drawn on top of each other.
Fix
Minings that share a character are now laid out together. The character gets room for all of them, and each mining is drawn in its own part of that space. Every mining asks for the same width, so painting stops after the first paint:
flowchart TD P[Paint editor] --> A[Minings A and B set width to 620 + 930 px] A --> C{Width changed?} C -- "first paint only" --> P C -- no --> S[Save completes]When a mining is removed, the extra space goes away with it.
The new
CodeMiningRepaintTestreproduces the problem with two long minings on a shared character. Without the fix, the editor repaints several hundred times per second. With the fix, it stops repainting.