Bug 62405 - Editor drop down performance slow on Linux-GTK on mouse move
Summary: Editor drop down performance slow on Linux-GTK on mouse move
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Kevin Barnes CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 62290 104926 148293 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-15 16:19 EDT by Brian Stiles CLA
Modified: 2019-06-19 15:34 EDT (History)
11 users (show)

See Also:


Attachments
attaching some code that I'm experimenting with (18.33 KB, application/octet-stream)
2005-05-03 13:39 EDT, Michael Van Meekeren CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Stiles CLA 2004-05-15 16:19:00 EDT
I wonder if the fix to bug 44915 introduced a performance regression.  I'm using
I20040513 GTK and the UI is sluggish in a number of places.  The most apparent
is when using the "Open Editor Drop Down" command to bring up the list of open
editors.

1.  Open 5 or so files.
2.  Open Editor Drop Down.
3.  Move the mouse cursor up and down over the list of editors quickly a few times.

Notice that the highlighting of the list elements trails behind the mouse
movement significantly.  That is, if I move the mouse over the first, then
second, then third, etc. editor in the list and then reverse the direction back
up to the first editor in the list, the highlight moves from the first to the
second to the third, etc., but it lags behind the mouse.

This kind of behavior seems suspiciously likely to be a result of queuing UI
events, as I understand the fix for 44915 does.
Comment 1 Steve Northover CLA 2004-05-17 09:43:06 EDT
Yes, it does seem very suspicious.  Vikki to investigate.
Comment 2 Veronika Irvine CLA 2004-05-17 11:18:16 EDT
The case listed here is not related to the clipboard fix - 
gtk_clipboard_wait_for_contents is not running at this time.

When the shell with the list of editors is first opened, Shell.setVisible is 
called which uses the "dispatchEvents" mechanism.  However, this completes 
fairly quickly and the mouse movement response is still sluggish.  
No "deferredEvents" behaviour is going on while the mouse is moving around and 
the response is still sluggish.
Comment 3 Veronika Irvine CLA 2004-05-17 12:33:02 EDT
AbstractTableInformationControl$3mouseMove is the place where the work is 
being done.  It is calling Table.getItem(Point) and Table.setSelection([]
TableItem).  I think the performance of Table.setSelection(TableItem[]) is 
slowing this down.
Comment 4 Steve Northover CLA 2004-05-17 12:59:59 EDT
FH changed Table and Tree in this area this recently.  Is the new code really 
slow?
Comment 5 Felipe Heidrich CLA 2004-05-17 13:11:35 EDT
I changed only Tree.getItem(Point) and TreeItem.getBounds(), didn't touch 
Table.
Comment 6 Veronika Irvine CLA 2004-05-17 15:29:42 EDT
*** Bug 62290 has been marked as a duplicate of this bug. ***
Comment 7 Billy Biggs CLA 2004-05-19 11:27:07 EDT
If we do not use the ON_TOP style for the editor drop down then the selection
events seem to be processed speedily.  I believe the bug has to do with ON_TOP
somehow.
Comment 8 Billy Biggs CLA 2004-05-21 14:00:22 EDT
OK, I can reproduce it in cases where the window is not ON_TOP, sorry.
Comment 9 Veronika Irvine CLA 2004-06-04 11:42:13 EDT
I think Billy is onto something with the ON_TOP.

The following code in Display.eventProc is causing the problem:

if (control != null ) {
	shell = control.getShell ();
	if ((shell.style & SWT.ON_TOP) != 0) {
		OS.gtk_grab_add (shell.shellHandle);
	}
}

Silenio, what problem was the gtk_grab_add addressing?  Is there another 
solution?
Comment 10 Steve Northover CLA 2004-06-04 16:02:51 EDT
SSQ, why did we do this silly grab thing (yes, I do remember that it was my 
hack)?
Comment 11 Silenio Quarti CLA 2004-06-07 15:11:31 EDT
If the code is removed, you will not be able to click on ON_TOP shell that is a
child of a modal dialog.

Window->Preferences->Java->Editor->Templates->New Button->Pattern text-><invoke
code assist>
Comment 12 Silenio Quarti CLA 2004-06-07 15:14:52 EDT
I can still reproduce this problem after removing the call
gtk_grab_add()/gtk_grab_remove() in Display.eventProc().
Comment 13 Silenio Quarti CLA 2004-06-07 15:27:44 EDT
Ok, I don't think the problem has anything to do if the code in
Display.eventProc(). Here are two scenarios (both are not affected by the code
in eventProc()).

1) As soon as you click the button, start moving the mouse in circles and never
stop. The selection will not catch up if the mouse ever. If you stop and let all
the outstanding events happen, when you move the mouse again, the selection will
follow the mouse properly.

2) Click the button and do not move the mouse, let the popup appear fully (1 or
2 seconds). Move the mouse, the selection willl follow it properly.
Comment 14 Silenio Quarti CLA 2004-06-07 15:38:17 EDT
More info, if you move the mouse outsize of the popup window and then back,
selection will start to follow the mouse properly.
Comment 15 Billy Biggs CLA 2004-06-18 01:13:58 EDT
Bug 67458 should be marked as a duplicate of this bug.

Silenio and I discovered that mouse move hints are not being correctly handled:
the hints slow down mouse events, but report the original positions when it
started grabbing events, not the most recent position.

The fix is to query the pointer's actual position on a mouse move event if the
motion hints are turned on and the Gdk motion event has its hint flag set to
true.  Using this fix in the Sash code solves bug 54517 about fast view resizing
being slow.  Using the same logic for mouse motion events in
Control.sendMouseEvent fixes this bug about the editor drop down being slow.
Comment 16 Silenio Quarti CLA 2004-06-18 12:59:28 EDT
We released changes that will fix the slowness resizing fast views.

GtkTreeView does not set the pointer motion hint, so it gets all motion events
and that is way it is slow. I don't think we should set the motion hint for this
widget though, because GTK might not handle that properly, since they do not
expect it.
Comment 17 Billy Biggs CLA 2004-06-21 09:07:37 EDT
I opened this bug against GtkTreeView:
http://bugzilla.gnome.org/show_bug.cgi?id=144729
Comment 18 Billy Biggs CLA 2005-02-10 10:23:22 EST
We should probably just work around this bug in the UI code for now by disabling
the selection code on GTK+, since there are no plans to add the motion hint on
the tree view upstream (and it would be too dangerous for SWT to set the hint).
Comment 19 Billy Biggs CLA 2005-03-16 16:15:37 EST
I was able to come up with a small GTK+ test case which exhibits the same weird
performance problem.  Unfortunately, the cause seems to be a complex interaction
with the idle handlers for resizing and validating rows in GtkTreeView:

  http://bugzilla.gnome.org/show_bug.cgi?id=170600

The fix is to run the row validator, but there is no public API to do this and I
cannot find any suitable workaround in SWT.  While the easier workaround is
simply to set the motion hint, which means we don't have to deal with so many
mouse events in the first place, this is dangerous, was rejected upstream, and
the newly reported bug is really what seems to be causing setting the cursor to
be slow in the first place.

Even worse, this bug is also machine and GTK+ version dependent.  It doesn't
happen on Doug's machine (GTK+ 2.6), nor on jrb's machine (also GTK+ 2.6), and
for me it happens more easily on GTK+ 2.6 than GTK+ 2.4.  Furthermore, the
selection is slow in general for me under RHEL3/BlueCurve (GTK+ 2.2), but
generally snappy on FC3/BlueCurve (GTK+ 2.4).

Given that there is a clear bug in GTK+, this problem is not reproducable
everywhere, and there is no good workaround in SWT, I think it is best to close
this as WONTFIX.  I still think it may be worth changing the UI behaviour, but I
will file a new bug for this.
Comment 20 Billy Biggs CLA 2005-03-17 11:27:03 EST
I've had a change of heart and I think I will reopen this bug.  It would be nice
to figure out why it's slow in general on some machines: under RHEL3 and on my
machine at home, it's a lot slower than it should be.  Furthermore, the fix in
GTK+ is strange, so maybe after it's fixed there we could figure out a stable
workaround.  Best to leave this open.
Comment 21 Mike Wilson CLA 2005-04-21 10:22:45 EDT
Finding out what is really wrong, does not preclude putting in a workaround to fix the appearance in 
this particular instance. Can something be done about that? Is this a UI problem or an SWT problem?
Comment 22 Michael Van Meekeren CLA 2005-04-26 11:04:48 EDT
As a rule we never want to have platform code in UI, but I'm afraid this problem
will not get tracked and we will never bring back the feature when GTK does
improve.  I'm going to remove the feature for GTK only in the UI, and leave this
bug open with a reference to it from the code.
Comment 23 Steve Northover CLA 2005-04-26 11:30:00 EDT
That is fine with me.
Comment 24 Steve Northover CLA 2005-05-02 18:29:21 EDT
MVM, did you ever get to this?  It makes a big difference on GTK.
Comment 25 Michael Van Meekeren CLA 2005-05-03 13:39:44 EDT
Created attachment 20651 [details]
attaching some code that I'm experimenting with
Comment 26 Michael Van Meekeren CLA 2005-05-06 12:12:33 EDT
I've put a workaround in the UI in HEAD that optimizes the current code to do a
lot less work during the mouse moves, and secondly for GTK tries to call
setSelection() about %75 less.  This seems to work quite well on my Linux
machine (which WAS exhibiting the slowness).  I'd like to here from Billy if
this makes his test machines usable.
Comment 27 Steve Northover CLA 2005-05-13 17:39:03 EDT
As of I20050510-0010, the code in head isn't fixing the problem (I just tried 
it).  Can I give you a demonstration?
Comment 28 Michael Van Meekeren CLA 2005-05-16 14:00:15 EDT
yes please
Comment 29 Billy Biggs CLA 2005-07-23 15:29:42 EDT
*** Bug 104926 has been marked as a duplicate of this bug. ***
Comment 30 Steve Northover CLA 2005-11-18 15:07:23 EST
Sigh, I am doomed, never to get this worked around in Eclipse, even though the 
work around is trivial and the failure makes Eclipse look horrible.
Comment 31 Billy Biggs CLA 2006-06-25 13:33:10 EDT
*** Bug 148293 has been marked as a duplicate of this bug. ***
Comment 32 Steve Northover CLA 2006-06-26 11:03:20 EDT
Doomed I tell you, doomed ... R2?
Comment 33 Mike Wilson CLA 2006-06-27 08:49:34 EDT
bleep brrrrrrrrr bee-doop.
Comment 34 Steve Northover CLA 2006-10-04 17:13:48 EDT
I've tried for a while to get this worked around in Eclipse and now I'm giving up.  Since it has already fixed in newer versions of GTK, I'm going to have to close it as WONTFIX (really, already fixed in GTK).