Bug 92241 - StyledText should not fill the clipboard on every selection change
Summary: StyledText should not fill the clipboard on every selection change
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on: 92404
Blocks: 92209
  Show dependency tree
 
Reported: 2005-04-21 11:23 EDT by Tom Hofmann CLA
Modified: 2007-06-15 10:35 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-04-21 11:23:41 EDT
3.1 stream

See bug 92209. Filling the clipboard with the current selection upon every
selection change *really* hurts one test case: selecting big editor areas and
changing the selection with the arrow keys and holding shift (or selecting large
areas with the mouse).

Note that this happens on Windows as well as GTK.

IMO, copying the entire (almost) document content upon every selection change is
way too expensive. Is there a way to avoid this?
Comment 1 Veronika Irvine CLA 2005-04-21 14:43:20 EDT
I have changed it so that the selection is not calculated for the clipboard
unless you are on GTK or MOTIF.  This will speed up Windows and Carbon.

I am investigating ways to reduce the number of times the selection clipboard is
updated on GTK and Motif without losing functionality.
Comment 2 Veronika Irvine CLA 2005-04-22 11:55:18 EDT
Changed GTK and Motif so that updating the selection clipboard works as follows:

Update on MouseUp - that means if the user selects a large amount of text by
dragging the mouse, the selection clipboard will only be updated when the mouse
is released.  Previously, the selection clipboard was updated every time the
selection changed which was every time the mouse selected a new bunch of text.

Update on KeyUp if the selection has changed since key down,  If the user holds
the arrow key down and selects a large amount of text, repeated key down events
will be sent but only one key up (this is true on most platforms - the only
known exception is Linux Motif - the Xserver there sends repeated KeyDown/KeyUp
events).  This is not the most ideal solution for keyboard selection.  However
there is no reliable way to know when the user is finished selecting - the Shift
 Key is one possibility but it is not completely reliable.
Comment 3 Veronika Irvine CLA 2005-04-22 12:02:30 EDT
Ideally, the Clipboard would provide a lazy mechanism such that ownership of the
clipboard would be cheap (and could be done every time the sleection changed)
and the data would only be provided at the time when someone pasted the data (or
when the application closed).  This is not currently supported by SWT and will
not make it in for 3.1.  It is described in Bug 92404.

When such a mechanism is in place, SytledText could be changed to use it.
Comment 4 Tom Hofmann CLA 2005-04-22 12:39:24 EDT
Cool, though - what you described in comment 2 will get us the largest part of
the way (except Motif). I have just added scrolling performance tests that test
the scenario you described (KeyDown until scrolling is over, then KeyUp) as
opposed to our previous test which would send out zillions of KeyDown/KeyUp pairs.

In the new test, you can literally watch the CPU-usage go up as the selection
grows bigger - your change will show up immediately as performance improvement
once it is in...
Comment 5 Veronika Irvine CLA 2005-04-22 12:44:23 EDT
Actually it is only Motif on Linux that is a problem.  The XServer on most other
Unix operating systems only sends the final KeyUp.
Comment 6 Veronika Irvine CLA 2005-04-22 12:49:09 EDT
Oh yeah, there is one other optimization I added.  Other applications only place
plain text on the selection clipboard. They do not put RTF text.  So I changed
StyledText to only put plain text for the selection clipboard and plain text
plus RTF text for the regular clipboard.  This should save a bunch of conversion
work.
Comment 7 Veronika Irvine CLA 2005-05-16 10:56:49 EDT
Downgrading to normal but leaving open to track using a lazy data collection 
mechanism.
Comment 8 Steve Northover CLA 2007-06-15 10:35:10 EDT
The original problem is fixed and lazy clipboard is tracked elsewhere.  Closing.