Bug 541415 - [code mining] No code mining or other viewportListeners updated when using Ctrl+End
Summary: [code mining] No code mining or other viewportListeners updated when using Ct...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.10   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.11 RC2   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 529127 544708
Blocks: 545006
  Show dependency tree
 
Reported: 2018-11-21 10:52 EST by Dani Megert CLA
Modified: 2021-08-16 14:02 EDT (History)
8 users (show)

See Also:
akurtakov: pmc_approved+
akurtakov: review+


Attachments
Inconsistent code minings (35.17 KB, image/png)
2018-11-27 03:11 EST, Sarika Sinha CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2018-11-21 10:52:31 EST
No code mining when using Ctrl+End.

Open a larger file, e.g. TextViewer and then press Ctrl+End
==> code minings are not shown.
Comment 1 Noopur Gupta CLA 2018-11-23 07:17:02 EST
Code minings are shown in TextViewer but after some time when the calculation is finished. I think it is a duplicate of bug 541441.

*** This bug has been marked as a duplicate of bug 541441 ***
Comment 2 Dani Megert CLA 2018-11-23 12:21:44 EST
(In reply to Noopur Gupta from comment #1)
> Code minings are shown in TextViewer but after some time when the
> calculation is finished. I think it is a duplicate of bug 541441.
> 
> *** This bug has been marked as a duplicate of bug 541441 ***

Nope.
Comment 3 Sarika Sinha CLA 2018-11-26 02:37:33 EST
Yes, this is most strange, On some methods in between reference count come like getModelCoverage, addPainter after 7 minutes of opening this file. 
Is it so slow?

Noopur, how much time did it take for you?
Comment 4 Noopur Gupta CLA 2018-11-26 03:55:06 EST
(In reply to Sarika Sinha from comment #3)
> Noopur, how much time did it take for you?
Steps that I tried:
- Open TextViewer.java.
- Press Ctrl+End.
=> I get the annotations on #setTabsToSpacesConverter, #ensureHyperlinkManagerInstalled etc. in approximately 8 seconds.
Comment 5 Sarika Sinha CLA 2018-11-26 04:11:41 EST
Tried again with having TextViewer java file locally, still on Ctr+End or even scrolling through the file slowly/fast, I see Code Minings selectively. Like I see on KeyPressed but not on mousep/down, After some time I see on ensureHyperlinkManagerInstalled but I never see on setTabsToSpacesConverter.

@Angelo, can you explain the reason.
Comment 6 Angelo ZERR CLA 2018-11-26 04:54:35 EST
It's a bug of CodeMining that I'm trying to fix. The basic explanation is that inlined annotation (like codemining header annotation) checks if the annotation offset is in visibles lines area -> https://github.com/eclipse/eclipse.platform.text/blob/master/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java#L42

The visibles lines uses a IViewportListener to update the start/end offset of visibles lines. The problem with Ctrl+End is that inlined annotations is drawn BEFORE the update of IViewportListener, that's why the annotation is considered as not in visible lines area.

A fix that I have in my mind is to uses a paint listener like we have done with VisibleLinesTracker to track changes of visible lines for *RulerColumn. A clean solution is to reuse this tracker, but we cannot use it, since VisibleLinesTracker  is only visible for org.eclipse.jface.text.source package and fix should be done org.eclipse.jface.text.source.inlined package (InlinedAnnotationSupport).
Comment 7 Eclipse Genie CLA 2018-11-26 05:11:22 EST
New Gerrit change created: https://git.eclipse.org/r/133055
Comment 8 Angelo ZERR CLA 2018-11-26 05:15:26 EST
Please see my gerrit patch at https://git.eclipse.org/r/#/c/133055/ which follows my idea with visible lines tracker. I know this gerrit patch will be refused since I have changed VisibleLinesTracker to public (class and track/untrack methods), but I wanted to open discussion, because I think more and more JFace Text should provide this tracker, which is used in several area. The benefit with this tracker is that compute of bottom index and offset is done ONCE time and not several times (for each classes which needs that like *RulerAnnotation and now InlinedAnnotationSupport).

This gerrit patch should fix this issue with Ctrl+End BUT I don't know why the lines which are below mining to draw are cut -( I think it's a new bug with StyledText?
Comment 9 Dani Megert CLA 2018-11-26 13:37:14 EST
(In reply to Sarika Sinha from comment #5)
> Tried again with having TextViewer java file locally, still on Ctr+End or
> even scrolling through the file slowly/fast, I see Code Minings selectively.
> Like I see on KeyPressed but not on mousep/down, After some time I see on
> ensureHyperlinkManagerInstalled but I never see on setTabsToSpacesConverter.
> 
> @Angelo, can you explain the reason.
Comment 10 Dani Megert CLA 2018-11-26 13:41:37 EST
Strange. Today it seems to work, though with delay towards 10s.
Comment 11 Sarika Sinha CLA 2018-11-26 22:58:19 EST
It works for also with Eclipse SDK

Version: 2018-12 (4.10)
Build id: I20181126-0940
Comment 12 Sarika Sinha CLA 2018-11-26 22:58:39 EST
(In reply to Sarika Sinha from comment #11)
> It works for also with Eclipse SDK
> 
> Version: 2018-12 (4.10)
> Build id: I20181126-0940

works for me.
Comment 13 Sarika Sinha CLA 2018-11-27 03:11:59 EST
Created attachment 276713 [details]
Inconsistent code minings

Adding some use cases to test after the fix is available -
1. As seen in the attachment, Code Minings annotation are sometime very in consistent in display , Just showing references or empty line for annotation which is clickable.
2. In some scenarios, after Ctrl + End, Code Minings appear only if there is a click on the editor.
Comment 14 Dani Megert CLA 2018-11-27 04:54:11 EST
(In reply to Dani Megert from comment #10)
> Strange. Today it seems to work, though with delay towards 10s.

OK, I can consistently reproduce now. It depends on when I press Ctrl+End.

Here it works:
1. Use Open Type to open TextViewer
2. Immediately press Ctrl+End
==> code minings appear

When I now press Ctrl+Home the minings are not shown.


Here it does not work:
1. Use Open Type to open TextViewer
2. Wait until the code minings are visible (also the one above class TextViewer
   This takes about 5s
2. Press Ctrl+End
==> no code minings

When I now click somewhere, the minings appear.
Comment 15 Dani Megert CLA 2018-11-27 04:55:28 EST
(In reply to Dani Megert from comment #14)

Looks like a listener is missing or not checking Ctrl+End and Ctrl+Home.
Comment 16 Dani Megert CLA 2018-11-27 04:56:22 EST
(In reply to Sarika Sinha from comment #13)
> Created attachment 276713 [details]
> Inconsistent code minings
> 
> Adding some use cases to test after the fix is available -
> 1. As seen in the attachment, Code Minings annotation are sometime very in
> consistent in display , Just showing references or empty line for annotation
> which is clickable.
> 2. In some scenarios, after Ctrl + End, Code Minings appear only if there is
> a click on the editor.

This looks like a different bug. Please file a new bug report with steps to reproduce.
Comment 17 Dani Megert CLA 2018-11-27 05:01:27 EST
(In reply to Angelo ZERR from comment #8)
> Please see my gerrit patch at https://git.eclipse.org/r/#/c/133055/ which
> follows my idea with visible lines tracker. I know this gerrit patch will be
> refused.

It depends how you make it API. Let's discuss in the Gerrit itself.
Comment 18 Angelo ZERR CLA 2018-11-27 05:13:09 EST
> When I now press Ctrl+Home the minings are not shown.

You mean https://git.eclipse.org/r/#/c/133055/ doesn't work?
Comment 19 Dani Megert CLA 2018-11-27 05:35:43 EST
(In reply to Angelo ZERR from comment #18)
> > When I now press Ctrl+Home the minings are not shown.
> 
> You mean https://git.eclipse.org/r/#/c/133055/ doesn't work?

No, I didn't use the change as it is not yet "good". I only wanted to provide exact steps to reproduce it consistently. Comments about the change, e.g. whether it works or not, belong into the change and not into this bug report.
Comment 20 Mickael Istria CLA 2019-02-14 10:25:08 EST
(In reply to Dani Megert from comment #15)
> Looks like a listener is missing or not checking Ctrl+End and Ctrl+Home.

This could very well be caused by https://www.eclipse.org/lists/platform-dev/msg01475.html
Comment 21 Dani Megert CLA 2019-02-15 09:42:19 EST
(In reply to Mickael Istria - away until Feb 14th from comment #20)
> (In reply to Dani Megert from comment #15)
> > Looks like a listener is missing or not checking Ctrl+End and Ctrl+Home.
> 
> This could very well be caused by
> https://www.eclipse.org/lists/platform-dev/msg01475.html
Could, but I doubt it. This one is regarding Ctrl+End (makes no selection) not Shift+End (makes selection). Eric did not complain about Ctrl+Home which is the same as Ctrl+End but in the other direction. In addition, when pressing Ctrl+End right at the beginning it does work.
Comment 22 Lars Vogel CLA 2019-02-19 03:31:35 EST
Mass change, please reset target if you still planning to fix this for 4.11.
Comment 23 Mickael Istria CLA 2019-02-19 05:17:37 EST
> Here it works:
> 1. Use Open Type to open TextViewer
> 2. Immediately press Ctrl+End
> ==> code minings appear
> 
> When I now press Ctrl+Home the minings are not shown.

It looks like I can reproduce this one.

> Here it does not work:
> 1. Use Open Type to open TextViewer
> 2. Wait until the code minings are visible (also the one above class
> TextViewer
>    This takes about 5s
> 2. Press Ctrl+End
> ==> no code minings

I couldn't reproduce this one.
Which line range is visible when you open the file and then when you hit Ctrl+End? It seems to me the set of visible lines can have an impact on the results.
Comment 24 Dani Megert CLA 2019-02-19 10:06:21 EST
(In reply to Mickael Istria from comment #23)
> > 2. Wait until the code minings are visible (also the one above class
This is very important. Better wait another few seconds after it appears.


> Which line range is visible when you open the file and then when you hit
> Ctrl+End? It seems to me the set of visible lines can have an impact on the
> results.
Line 93 to 126.
Comment 25 Eclipse Genie CLA 2019-02-21 09:10:43 EST
New Gerrit change created: https://git.eclipse.org/r/137375
Comment 26 Mickael Istria CLA 2019-02-22 06:03:08 EST
This is most likely a symptom of bug 544708 . As a consequence, a sequence of Ctrl+End, (Ctrl+Home | Ctrl+End)* will only send a notification for the first Ctrl+End to ViewportListeners and ignores all other ones.
Comment 27 Mickael Istria CLA 2019-02-25 04:19:10 EST
When codemining is on, other viewportListeners on the SourceViewer don't get notified neither.
Comment 28 Mickael Istria CLA 2019-02-25 04:31:55 EST
The cause is that when codeminings are applied ` fTextWidget.getTopPixel()` returns an erroneous value (-10 in this case) when codeminings are on and prevent further execution of `TextViewer.updateViewportListeners()`.
Comment 29 Eclipse Genie CLA 2019-02-25 15:01:07 EST
New Gerrit change created: https://git.eclipse.org/r/137565
Comment 30 Mickael Istria CLA 2019-02-26 02:40:01 EST
Tentative for 4.11.RC1
Comment 32 Eric Williams CLA 2019-02-26 11:19:07 EST
(In reply to Eclipse Genie from comment #31)
> Gerrit change https://git.eclipse.org/r/137565 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=01afcdc0fb8782ec7a80728fedb1495e0212ed01

In master now, thanks for the fix Mickael.
Comment 33 Mickael Istria CLA 2019-02-26 11:20:34 EST
Thanks for the review.
I'd like to keep this open for some little time to get a change of adding some extra tests to codeminings by the way (see https://git.eclipse.org/r/137375 )
Comment 34 Eclipse Genie CLA 2019-02-26 11:32:38 EST
New Gerrit change created: https://git.eclipse.org/r/137652
Comment 36 Eric Williams CLA 2019-02-26 11:37:20 EST
Why was the fix reverted?
Comment 37 Dani Megert CLA 2019-02-26 11:37:53 EST
(In reply to Mickael Istria from comment #33)
> Thanks for the review.
> I'd like to keep this open for some little time to get a change of adding
> some extra tests to codeminings by the way (see
> https://git.eclipse.org/r/137375 )
I've reverted that since I did not see Alex's +1/+2 on the change. I see he approved in this bug - sorry. However, I've added Lakshmi to review the change and she did not respond yet, so please wait for her review.

Also, this change is at a very delicate position (used at many places by textual editors) and it's probably risky (just my gut feeling). I want at least Lakshmi's review here.
Comment 38 Mickael Istria CLA 2019-02-26 11:46:41 EST
> I've reverted that since I did not see Alex's +1/+2 on the change. I see he approved in this bug - sorry. However, I've added Lakshmi to review the change and she did not respond yet, so please wait for her review.

Ok, no big deal, and Lakshmi review is for sure welcome.

In the meantime, let's defend this patch ;)

> Also, this change is at a very delicate position (used at many places by
> textual editors) and it's probably risky (just my gut feeling).

setLineVerticalIndent() was introduced recently, in 4.10. So I doubt that beyond code minings, there are many editors that use it.
The worst case scenario would be about performance: we reset the value so it needs to be recomputed later and if we reset it very often, it needs to be recomputed very often. But given that a similar line is invoked in resetCache in many cases, I don't think it has a noticeable effect.
Comment 39 Dani Megert CLA 2019-02-26 11:57:35 EST
(In reply to Mickael Istria from comment #38)
> > I've reverted that since I did not see Alex's +1/+2 on the change. I see he approved in this bug - sorry. However, I've added Lakshmi to review the change and she did not respond yet, so please wait for her review.
> 
> Ok, no big deal, and Lakshmi review is for sure welcome.
> 
> In the meantime, let's defend this patch ;)
> 
> > Also, this change is at a very delicate position (used at many places by
> > textual editors) and it's probably risky (just my gut feeling).
> 
> setLineVerticalIndent() was introduced recently, in 4.10. So I doubt that
> beyond code minings, there are many editors that use it.
> The worst case scenario would be about performance: we reset the value so it
> needs to be recomputed later and if we reset it very often, it needs to be
> recomputed very often. But given that a similar line is invoked in
> resetCache in many cases, I don't think it has a noticeable effect.

OK, that sounds less scary then. Performance might be an issue though as Code Mining is already not that fast.
Comment 40 Eclipse Genie CLA 2019-02-26 13:01:14 EST
New Gerrit change created: https://git.eclipse.org/r/137656
Comment 41 Lakshmi P Shanmugam CLA 2019-02-26 13:42:38 EST
@Mickael, @Dani,
Sorry for the delay in review (and reverts), I had to log-out a bit early today.

I'm unable to reproduce the problem with Eclipse, but can reproduce the failure with the JUnit testcase and patch fixes the problem. I've posted my comments on the gerrit patch.
Comment 43 Dani Megert CLA 2019-02-27 03:57:50 EST
Thanks everyone!
Comment 45 Andrey Loskutov CLA 2019-02-28 01:55:37 EST
(In reply to Eclipse Genie from comment #44)
> Gerrit change https://git.eclipse.org/r/137375 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/
> ?id=dc3fc7c378f03dcd8404fd598641aa43a8ab086a

This caused 4 new fails on Mac:

https://download.eclipse.org/eclipse/downloads/drops4/I20190227-1800/testresults/html/org.eclipse.jface.text.tests_ep411I-unit-mac64-java8_macosx.cocoa.x86_64_8.0.html
Comment 46 Eclipse Genie CLA 2019-02-28 02:00:01 EST
New Gerrit change created: https://git.eclipse.org/r/137772
Comment 47 Mickael Istria CLA 2019-02-28 02:00:56 EST
(In reply to Andrey Loskutov from comment #45)
> This caused 4 new fails on Mac:

OK, can someone who has a Mac please give a try to

(In reply to Eclipse Genie from comment #46)
> New Gerrit change created: https://git.eclipse.org/r/137772
Comment 48 Andrey Loskutov CLA 2019-02-28 02:34:20 EST
(In reply to Andrey Loskutov from comment #45)
> (In reply to Eclipse Genie from comment #44)
> > Gerrit change https://git.eclipse.org/r/137375 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/
> > ?id=dc3fc7c378f03dcd8404fd598641aa43a8ab086a
> 
> This caused 4 new fails on Mac:
> 
> https://download.eclipse.org/eclipse/downloads/drops4/I20190227-1800/
> testresults/html/org.eclipse.jface.text.tests_ep411I-unit-mac64-java8_macosx.
> cocoa.x86_64_8.0.html

And one fail on Linux:

https://download.eclipse.org/eclipse/downloads/drops4/I20190227-1800/testresults/html/org.eclipse.jface.text.tests_ep411I-unit-cen64-gtk3-java8_linux.gtk.x86_64_8.0.html
Comment 49 Lakshmi P Shanmugam CLA 2019-02-28 03:42:17 EST
(In reply to Mickael Istria from comment #47)
> (In reply to Andrey Loskutov from comment #45)
> > This caused 4 new fails on Mac:
> 
> OK, can someone who has a Mac please give a try to
> 
> (In reply to Eclipse Genie from comment #46)
> > New Gerrit change created: https://git.eclipse.org/r/137772

The patch fixes the test failures on Mac locally.
Comment 51 Andrey Loskutov CLA 2019-02-28 04:03:36 EST
Windows tests are also failed.
Comment 52 Dani Megert CLA 2019-03-01 06:02:41 EST
Ping! Tests still fail in I20190228-0300.
Comment 53 Mickael Istria CLA 2019-03-01 06:51:43 EST
(In reply to Dani Megert from comment #52)
> Ping! Tests still fail in I20190228-0300.

I'm waiting for the current build to complete to have a look at the screenshot generated by the failures, but I'm really not able to reproduce any of those failures locally, and the Linux tests passed on Gerrit. So if anyone else can give a hand and at least run the tests locally and report whether they work or not on their machine, this would be pretty useful.
Comment 54 Andrey Loskutov CLA 2019-03-01 07:40:06 EST
I believe we see only 3 tests succeeding on linux, and all four failing for Mac / Windows. Given that I would disable all 4 tests, close this bug and open a new one to fix tests.
Comment 55 Mickael Istria CLA 2019-03-01 10:15:53 EST
The Unit tests are supposed to create screenshots on failure (they do with the Gerrit build) nearby the log location. I couldn't find those screenshots in https://ci.eclipse.org/releng/view/Automated%20tests/job/ep411I-unit-cen64-gtk3-java8/ws/ . Does anyone know where those could be?

(In reply to Andrey Loskutov from comment #54)
> I believe we see only 3 tests succeeding on linux, and all four failing for
> Mac / Windows. Given that I would disable all 4 tests, close this bug and
> open a new one to fix tests.

As you wish. In any case, without any 3rd pary assistance, those tests will never be fixed anyway and regressions will happen.
Comment 56 Eclipse Genie CLA 2019-03-02 18:07:39 EST
New Gerrit change created: https://git.eclipse.org/r/137927
Comment 57 Andrey Loskutov CLA 2019-03-02 18:18:03 EST
(In reply to Mickael Istria from comment #55)
> (In reply to Andrey Loskutov from comment #54)
> > I believe we see only 3 tests succeeding on linux, and all four failing for
> > Mac / Windows. Given that I would disable all 4 tests, close this bug and
> > open a new one to fix tests.
> 
> As you wish. In any case, without any 3rd pary assistance, those tests will
> never be fixed anyway and regressions will happen.

Mickael, it does not make sense to create tests that fail from very beginning. Such tests will never catch any regression, because no one will ever notice that (look, they fail already on other platforms, so what?). Additionally, they cause a bad habit: https://en.wikipedia.org/wiki/Broken_windows_theory. If there are 10 tests failing, 4 more failing tests aren't that bad...

(In reply to Eclipse Genie from comment #56)
> New Gerrit change created: https://git.eclipse.org/r/137927

I believe I have a fix. Looks like display.post() did not work as expected for the new tests. At least on Windows they do not fail for me anymore.
Comment 59 Eclipse Genie CLA 2019-03-03 17:02:25 EST
New Gerrit change created: https://git.eclipse.org/r/137952
Comment 60 Andrey Loskutov CLA 2019-03-03 17:03:29 EST
(In reply to Eclipse Genie from comment #59)
> New Gerrit change created: https://git.eclipse.org/r/137952

This patch disables new tests on Mac. Previous one fixed them on Windows/Linux.
Comment 62 Mickael Istria CLA 2019-03-04 01:12:16 EST
Thanks a lot Andrey!
Do you think Display.post(...) is buggy here?
Comment 63 Andrey Loskutov CLA 2019-03-04 01:46:49 EST
(In reply to Mickael Istria from comment #62)
> Thanks a lot Andrey!
> Do you think Display.post(...) is buggy here?

I think either our Linux test environment is "different" (like this SWT test fail [1] saying "Display#post failed, probably because screen is not rendered (bug 407862)"), or display.post() *behavior*, triggered from inside the test, is not same as real keyboard input.

At least on Windows on my notebook with "usual" environment I could see that the post() is not triggering same chain of events as real user. Unfortunately I have no Mac, so no idea what is going wrong there.

[1] https://download.eclipse.org/eclipse/downloads/drops4/I20190303-0600/testresults/html/org.eclipse.swt.tests_ep411I-unit-win32-java8_win32.win32.x86_64_8.0.html

I'm resolving this bug now.

Mickael, could you please create a bug to investigate & re-enable Mac tests?