Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313231

Summary: [Performances][CopyPaste] Editing becomes unresponsive after diagram copy/paste
Product: [Modeling] Papyrus Reporter: Ansgar Radermacher <ansgar.radermacher>
Component: CoreAssignee: Project Inbox <mdt-papyrus-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: b_m_lamine, kai.ford, nifauvergue, papyrus-bugs, Patrick.Tessier, rschnekenburger, yann.tanguy
Version: unspecifiedKeywords: performance, plan
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Workaround for the bug on Linux systems
none
Revised patch
none
mylyn/context/zip none

Description Ansgar Radermacher CLA 2010-05-17 15:49:51 EDT
Build Identifier: Build id: 20100506-2000

If a profile (with <100 elements) is edited, the response times are very bad: after a click on a stereotype within a profile diagram, it takes 5-30 seconds before the object is actually selected.
During this delay, there is apparently no CPU consumption, might be an unnecessary network request.

Reproducible: Always

Steps to Reproduce:
1. Open a UML profile.
2. Select different stereotypes successively within a diagram.
3.
Comment 1 Yann Tanguy CLA 2010-05-19 03:16:32 EDT
(In reply to comment #0)
> Build Identifier: Build id: 20100506-2000
> 
> If a profile (with <100 elements) is edited, the response times are very bad:
> after a click on a stereotype within a profile diagram, it takes 5-30 seconds
> before the object is actually selected.
> During this delay, there is apparently no CPU consumption, might be an
> unnecessary network request.
> 
> Reproducible: Always
> 
> Steps to Reproduce:
> 1. Open a UML profile.
> 2. Select different stereotypes successively within a diagram.
> 3.

Could not reproduce on Helios M7, this may have been solved or may be a linux specific issue.
Comment 2 Ansgar Radermacher CLA 2010-06-15 11:53:34 EDT
(In reply to comment #1)
> (In reply to comment #0)
> > Build Identifier: Build id: 20100506-2000
> > 
> > If a profile (with <100 elements) is edited, the response times are very bad:
> > after a click on a stereotype within a profile diagram, it takes 5-30 seconds
> > before the object is actually selected.
> > During this delay, there is apparently no CPU consumption, might be an
> > unnecessary network request.
> > 
> > Reproducible: Always
> > 
> > Steps to Reproduce:
> > 1. Open a UML profile.
> > 2. Select different stereotypes successively within a diagram.
> > 3.
> 
> Could not reproduce on Helios M7, this may have been solved or may be a linux
> specific issue.

I can reproduce it here with the latetest nightly build and Helios RC3. However, 1. it does not happen right from the start. It is apparently triggered by executing a copy-paste operation on the diagram.
2. It is not limited to the profile diagram, once the paste-operation (in any diagram) has been done, it affects all diagrams. The editor becomes unusable until a restart
Comment 3 Ansgar Radermacher CLA 2010-06-15 16:19:18 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > Build Identifier: Build id: 20100506-2000
> > > 
> > > If a profile (with <100 elements) is edited, the response times are very bad:
> > > after a click on a stereotype within a profile diagram, it takes 5-30 seconds
> > > before the object is actually selected.
> > > During this delay, there is apparently no CPU consumption, might be an
> > > unnecessary network request.
> > > 
> > > Reproducible: Always
> > > 
> > > Steps to Reproduce:
> > > 1. Open a UML profile.
> > > 2. Select different stereotypes successively within a diagram.
> > > 3.
> > 
> > Could not reproduce on Helios M7, this may have been solved or may be a linux
> > specific issue.
> 
> I can reproduce it here with the latetest nightly build and Helios RC3.
> However, 1. it does not happen right from the start. It is apparently triggered
> by executing a copy-paste operation on the diagram.
> 2. It is not limited to the profile diagram, once the paste-operation (in any
> diagram) has been done, it affects all diagrams. The editor becomes unusable
> until a restart

This seems to be a KDE4/eclipse issue: the editor behaves "normal" again, after the Klipper (KDE clipboard tool) history is cleared. Deactivating the klipper tool does not solve the issue.

Lamine: can you confirm that there is no problem on Ubuntu (gnome instead of KDE)?
Comment 4 Mohamed-Lamine BOUKHANOUFA CLA 2010-06-22 03:48:31 EDT
In my machine there are no problem for the selection of different stereotypes within a profile diagram.

I use gnome (ubuntu 10.04) and Papyrus: 0.7.0v201006161830 
and eclipse : Version: Helios Release (3.6.0) Build id: 20100603-0907
Comment 5 Ansgar Radermacher CLA 2010-07-05 04:36:58 EDT
I finally traced down this bug.

It is caused by a deadlock of the GUI thread:

The operation getPasteViewCommand in DefaultPasteCommand.java (within the papyrus pastemanager plugin) retrieves the available data flavors (formats) from the clipboard.

	DataFlavor[] dataFlavors = Toolkit.getDefaultToolkit().getSystemClipboard().getAvailableDataFlavors();

In case of Linux, I traced down this call to a call of the operation XConvertSelection (by using the complete Java sources which are not part of the default JDK). Afterwards, the threads waits for a response from X11 in a polling loop with a timeout of 10s. This timeout may vary on different systems.

The problem is that XConvertSelection (see extract from the manual page below) does not know itself which data formats are available but demands the application which has deposited the selection to the clipboard, i.e. Papyrus. Papyrus would normally handle this request using its GUI thread (I guess, it's an incoming GTK event handled by the SWT main loop - though I have not checked it), but this thread is busy waiting for the reply within getAvailableDataFlavors, i.e. the polling loop will not exit before the timeout is passed. This is very criticil for the user, since the whole eclipse application is stalled for 10s.

PLEASE GIVE FEEDBACK, if you have this problem

(1) in GNOME based applications (which is likely) as the JDK and/or GTK implementation is the same.
(2) in Windows

Notice however that the default timeout might be much smaller than those I have on my system, i.e. try if the reactivity is a bit worse after copying a selection.

There is a simple workaround of not calling getAvailableDataFlavors in the
pastemanager. Another workaround would be to copy a selection only to the clipboard of the editing domain, i.e. do not copy in addition to the system clipboard (btw: the EMF command CopyToClipboard does only that, the Papyrus model explorer uses this command and does therefore not copy a selection into the System clipboard - it gets copied to the system clipboard however, once a selection is done in the graphical editor).

Other ideas?

----
man page from XConvertSelection:

XConvertSelection requests that the specified selection be converted to the specified target type:

  o    If the specified selection has an owner, the X server
       sends a SelectionRequest event to that owner.

  o    If no owner for the specified selection exists, the X
       server generates a SelectionNotify event to the
       requestor with property None.

The arguments are passed on unchanged in either of the events.  There are two predefined selection atoms: PRIMARY and SECONDARY.
Comment 6 Ansgar Radermacher CLA 2010-07-07 04:12:04 EDT
Created attachment 173622 [details]
Workaround for the bug on Linux systems
Comment 7 Ansgar Radermacher CLA 2010-07-07 05:08:21 EDT
Raised importance, since the error is not specific to KDE, but happens on all
Linux systems (re-tested with Ubuntu distribution). The error does not occur on
MAC-OS.
Comment 8 Ansgar Radermacher CLA 2010-07-09 10:31:31 EDT
Created attachment 173868 [details]
Revised patch

Replaces earlier patch which does not activate the workaround in case of the paste operation itself.
Comment 9 Patrick Tessier CLA 2010-07-09 11:32:09 EDT
Created attachment 173875 [details]
mylyn/context/zip

impacted classes
Comment 10 Remi Schnekenburger CLA 2010-07-19 11:34:08 EDT
(In reply to comment #8)
> Created an attachment (id=173868) [details]
> Revised patch
> 
> Replaces earlier patch which does not activate the workaround in case of the
> paste operation itself.

fixed in r2366
Comment 11 Ansgar Radermacher CLA 2010-09-06 11:10:00 EDT
The fix is merely a workaround which does not handle all possibly affected platforms (all X11 based, patch only handles Linux).
Comment 12 fordkp Mising name CLA 2011-03-05 23:35:09 EST
I am having a similar problem with Helios Service Release 2
Build id: 20110218-0911 on Linux (2.6.9-89.33.1.ELsmp) RH Enterprise Linux WS release 4 (Nahant Update 7) with KDE (3.3.1-17.el4_8.1 Red Hat) or Gnome. SR 1 also had the problem.  

After saving or frequently during routine editing eclipse freezes for something like 10 seconds. Problem began about a week ago with previous Helios version, but I don't know what triggered it.  Problem persisted after restarting eclipse, KDE, and even Linux, and installing Helios SR 1 and 2.
Comment 13 Toni Siljamäki CLA 2013-10-10 08:30:32 EDT
Is this one still valid, after all this time of inactivity?
Comment 14 Nicolas FAUVERGUE CLA 2018-06-01 10:01:15 EDT
This works fine in Photon RC2.