Skip to content

Virtual table is slow with many items #286

@kenwenzel

Description

@kenwenzel

I encounter exactly this (closed) issue with RAP 3.29.0:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396172

The problem is that Table.updateScrollBars() is called for each item that is disposed via Table.destroyItem():
Image

After investigating

I've come up with the following workaround:

Field styleField;
try {
	styleField = Widget.class.getDeclaredField("style");
	styleField.setAccessible(true);
} catch (NoSuchFieldException e) {
	styleField = null;
}

var table = ((TableViewer) viewer).getTable();

int style = table.getStyle();
boolean resetStyle = false;
try {
	// this is a hack to fix performance issues with RAP
	// by prevent scrollbar updates for each destroyed item
	if (styleField != null && (style & SWT.NO_SCROLL) == 0) {
		try {
			styleField.set(table, table.getStyle() | SWT.NO_SCROLL);
			resetStyle = true;
		} catch (IllegalAccessException e) {
			// ignore
		}
	}
	table.setItemCount(children.length);
} finally {
	if (resetStyle) {
		try {
			styleField.set(table, style);
		} catch (IllegalAccessException e) {
			// ignore
		}
	}
}

Is there anything that can be done to prevent updating the scrollbar state in this situation for each item?

I would propose to simply add some kind of flag isUpdatingItemCount = true that can be checked in Table.updateScrollBars() additionally to the style flag SWT.NO_SCROLL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions