Performance problems with large layouts in RCP application [message #1822735] |
Thu, 12 March 2020 13:48 |
Julia Kurde Messages: 91 Registered: November 2011 Location: Berlin, Germany |
Member |
|
|
Hello,
I asked this question also in the Eclipse 4 forum, but maybe here is the better place.
I'm having some performance problems using large layouts in an RCP application. Consider the following layout snippet:
package test01.test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class MyLayout {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Point size = new Point(2550, 7200);
ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
sc.setLayout (new FillLayout());
Composite content = new Composite(sc, SWT.NONE);
content.setLayout(new FormLayout());
int n = 830;
int w = size.x - 100;
int h = size.y - 100;
FormData data;
Text text;
Label label;
for (int i=0; i<n; i++) {
text = new Text (content, SWT.BORDER);
text.setText ("value " + i);
data = new FormData ();
data.left = new FormAttachment(0, (int) (Math.random()*w));
data.top = new FormAttachment(0, (int) (Math.random()*h));
text.setLayoutData (data);
if (i < 540) {
label = new Label(content, SWT.BORDER);
label.setText("dim");
data = new FormData ();
data.bottom = new FormAttachment(text, 0, SWT.BOTTOM);
data.left = new FormAttachment(text, 0, SWT.RIGHT);
label.setLayoutData(data);
}
}
content.setSize(size);
sc.setContent(content);
shell.setSize(800, 600);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
display.dispose ();
}
}
This layout has a size of 2550 x 7200 pixels and contains about 1300 children.
When this snipped is run as it is, independent of any RCP application there is no problem.
But if an editor in an RCP application is showing this layout it is extremely slow: it takes several seconds to open, it freezes when it is scrolled and when switching between editors it can even cause the whole application to hang itself.
Where I tested this layout so far:
* 3.x RCP in Eclipse for RCP and RAP Developers
Indigo Service Release 2, Build id: 20120216-1857
=> No Problem
* 3.x RCP in Eclipse for RCP and RAP Developers
2019-09 R (4.13.0), Build id: 20190917-1200
=> slow as described above
* 4.x RCP in Eclipse for RCP and RAP Developers
2019-09 R (4.13.0), Build id: 20190917-1200
=> slow as described above
These RCP applications are based on the corresponding Examples available in the New Project Wizard.
So obviously there are some changes between the Eclipse version from 2012 and 2019 (in between versions not tested), and the question is:
What could cause this performance problem and is there a way to improve it?
I'm happy about any ideas!
Julia
PS: In real live this layout represents a schematic drawing having labels for certain values like temperatures, status messages etc. The above layout just shows a simplified generic example.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06053 seconds