Bug 573016 - Rendering glitches on code mining when the file is small
Summary: Rendering glitches on code mining when the file is small
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.20   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.21 M1   Edit
Assignee: Gayan Perera CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-20 13:23 EDT by Gayan Perera CLA
Modified: 2021-06-07 09:47 EDT (History)
4 users (show)

See Also:


Attachments
rendering issue 1 (375.03 KB, image/png)
2021-04-20 13:23 EDT, Gayan Perera CLA
no flags Details
rendering issue 2 (366.46 KB, image/png)
2021-04-20 13:24 EDT, Gayan Perera CLA
no flags Details
codemining rendering issue screencast (455.51 KB, video/mp4)
2021-04-20 13:25 EDT, Gayan Perera CLA
no flags Details
simple test (9.75 KB, image/png)
2021-05-06 09:45 EDT, Gayan Perera CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gayan Perera CLA 2021-04-20 13:23:20 EDT
Take the following example

package app;

import java.io.File;
import java.nio.file.Paths;
import java.util.Set;

public class HelloTest {
	
	private File file;
	
	@org.junit.Test
	public void testHello() {
		Set<String> strings;
		this.file = new File("");
		Paths
	}
}


Now make sure your imports are collapase, and then remove the "Paths" reference and organize imports.

The source code rendering is not done properly to reflect the changes. This happens on when codeminings are available. I will attache a video which shows it in action
Comment 1 Gayan Perera CLA 2021-04-20 13:23:53 EDT
Created attachment 286179 [details]
rendering issue 1
Comment 2 Gayan Perera CLA 2021-04-20 13:24:10 EDT
Created attachment 286180 [details]
rendering issue 2
Comment 3 Gayan Perera CLA 2021-04-20 13:25:25 EDT
Created attachment 286181 [details]
codemining rendering issue screencast
Comment 4 Gayan Perera CLA 2021-04-28 08:13:10 EDT
Is there any activity on this Bug, right now on 4.20 having code minings on new files cause code mining and editor unusable.
Comment 5 Mickael Istria CLA 2021-04-28 10:35:33 EDT
(In reply to Gayan Perera from comment #4)
> Is there any activity on this Bug, right now on 4.20 having code minings on
> new files cause code mining and editor unusable.

Not from my side. While I can reproduce some issues wth code minings locally, the ones I see are not causing loss as you experience on macOS. I guess this issue is probably caused by some lower-level bug in macOS rendering. I usually can't fix macOS specific things.
Comment 6 Gayan Perera CLA 2021-04-28 11:29:58 EDT
Even though i recorded in MacOS, this happens on Windows 10 as well. This is prominent when the file is small, fit into the editor view port without needing to scroll.
Comment 7 Gayan Perera CLA 2021-05-03 08:32:49 EDT
New finding: This only happens for only for LineHeaderCodeMining implementations. Seems like the problem is with the reconcilers. May be the code mining reconciler is executed before source reconciler (just assuming) ?
Comment 8 Gayan Perera CLA 2021-05-04 11:17:26 EDT
I think I found the problem. Seems like this is cause by the NPE in one of annotation marker which cause the Java Reconciler to throw errors. I will do some testing without that Marker and close this issue.
Comment 9 Gayan Perera CLA 2021-05-06 09:43:55 EDT
I retested and found that the Marker issue not causing this. I have more data now.

Create simple project with this class

package workbench;

public class TestCase
{

  public void testFoo()
  {
    new TestCase();
  }

  public void testBoo() {
    testFoo();
  }
}


Enable reference codemining for Type, Field and Method in JDT preferences.

Now make a syntax error at testFoo method declaration by changing the code like

public void testFoo(Li)

Now you will have the rendering issues in JDT Editor.
Comment 10 Gayan Perera CLA 2021-05-06 09:45:58 EDT
Created attachment 286333 [details]
simple test
Comment 11 Gayan Perera CLA 2021-05-06 15:17:50 EDT
The problem seems to be that the first cycle of codemining painting is not down due to the minings are not resolved, then later after the source code/semantic painter has paint the styling of the source, the minings will get redrawn, but the source code is not repainted to adjust the mining.

I think its probably the SemanticHighlightingReconciler which doesn't run again after code minings are drawn
Comment 12 Gayan Perera CLA 2021-05-06 15:18:37 EDT
@Noopur has there any JDT UI changes recently which can cause this ?
Comment 13 Gayan Perera CLA 2021-05-07 15:00:45 EDT
Something i found out is if i execute getViewer().invalidateTextPresentation();

at org.eclipse.jface.internal.text.codemining.CodeMiningLineHeaderAnnotation.draw(GC, StyledText, int, int, Color, int, int)

after minings are drawn and when a mining is not drawn at all fix the issue, but it puts the editor to a redraw loop. 

What could be the issue which is getting fixed by invalidateTextPresentation ?
Comment 14 Gayan Perera CLA 2021-05-08 05:42:14 EDT
I tried with the modified CodeMiningDemo to hide minings when there is no refCount and i can see the same problem there as well.
Comment 15 Gayan Perera CLA 2021-05-08 10:06:35 EDT
The problems start with Bug569550 and it is their through the fixes done in Bug 570208,Bug 570342.

The problem is in SWT StyledText class in LineVerticalIndent feature.
Comment 16 Eclipse Genie CLA 2021-05-08 15:00:41 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/180382
Comment 17 Gayan Perera CLA 2021-05-08 15:03:10 EDT
I did a very novice patch which solves the issue described here, but i'm pretty sure i'm not fixing using the optimum solution. But i will use this patch for now to fix my eclipse installation until we have a good fix.
Comment 19 Mickael Istria CLA 2021-06-07 09:47:16 EDT
Thanks Gayan!
Anyone feel free to reopen if this fix is not sufficient. If no-one sees the issue before M1, we'll assume it's verified/fixed.