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

Bug 323430

Summary: Virtual table + lines visible + relatively low number of items scrolls slow
Product: [Eclipse Project] Platform Reporter: Niels Avonds <niels.avonds>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: a_ilyin, ericwill, lufimtse, wywrzal
Version: 3.6Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Bug Depends on:    
Bug Blocks: 519166    

Description Niels Avonds CLA 2010-08-23 14:48:47 EDT
When using a Virtual Table to display data, scrolling becomes very slow and sluggish when setting lines visible. However, this only happens when using a relatively low number of items (in my case between 2000 and 20000 items). The code snippet is a modified version of the one provided on the snippets page:

static final int COUNT = 2000;

public static void main(String[] args) {
	Display display = new Display ();
	final Shell shell = new Shell (display);
	shell.setLayout (new GridLayout());
	final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);
	table.addListener (SWT.SetData, new Listener () {
		public void handleEvent (Event event) {
			TableItem item = (TableItem) event.item;
			int index = table.indexOf (item);
			item.setText (0, "Item " + index);

			for (int i = 1; i <= 10; i++) {
				item.setText(i, index + " test " + i);
			}

		}
	});

	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
	gridData.heightHint = 200;
	table.setLayoutData(gridData);

	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	Button button = new Button (shell, SWT.PUSH);
	button.setText ("Add Items");

	for (int i = 1; i <= 10; i++) {
		TableColumn column = new TableColumn(table, SWT.NONE);
		column.setText("header " + i);
	}


	final Label label = new Label(shell, SWT.NONE);
	button.addListener (SWT.Selection, new Listener () {
		public void handleEvent (Event event) {
			long t1 = System.currentTimeMillis ();
			table.setItemCount (COUNT);
			long t2 = System.currentTimeMillis ();
			label.setText ("Items: " + COUNT + ", Time: " + (t2 - t1) + " (ms)");
			shell.layout ();
		}
	});

	for (TableColumn column: table.getColumns()) {
		column.pack();
	}

	shell.pack ();
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}

Surprisingly, when changing the count to 1000000 the scrolling is a lot more smooth. Setting lines visible to true is essential to create the sluggishness.

(I tested 3.7M1 as well and the problem still exists.)
Comment 1 Michal Niewrzal CLA 2010-09-29 16:24:27 EDT
I had also this problem in Virtual Tree. Problem was with scrolling and columns resizing. On Windows works quite well. This issue occur for me only with viewer with columns.
Comment 2 Eric Williams CLA 2016-10-18 16:20:11 EDT
Running the snippet attached yields a Table with nothing visible. Clicking anywhere inside the table prints the following error:

(SWT:7105): Gtk-CRITICAL **: file a11y/gtktreeviewaccessible.c: line 295 (get_visible_column): should not be reached
Comment 3 Eric Williams CLA 2018-03-20 13:31:51 EDT
(In reply to Eric Williams from comment #2)
> Running the snippet attached yields a Table with nothing visible. Clicking
> anywhere inside the table prints the following error:
> 
> (SWT:7105): Gtk-CRITICAL **: file a11y/gtktreeviewaccessible.c: line 295
> (get_visible_column): should not be reached

I cannot reproduce this any longer: the snippet works as intended. Scrolling is completely smooth.