org.eclipse.rap
org.eclipse.rap copied to clipboard
Virtual table is slow with many items
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():
After investigating https://github.com/eclipse-rap/org.eclipse.rap/blob/70285aa63c2a4ff312cc27b33df66db1c8990ff3/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java#L2546 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.