eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

[win] Scale with large maximum freeze UI

Open laeubi opened this issue 1 year ago • 3 comments

Consider the following code:

public class Snippet1 {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setSize(200, 200);
		shell.setLayout(new FillLayout());
		shell.setText("Snippet 1");
		Scale scale = new Scale(shell, SWT.NONE);
		scale.setMinimum(0);
		scale.setMaximum(100000000);
		long start = System.currentTimeMillis();
		System.out.println("Open Shell");
		shell.open();
		System.out.println("Open returned after " + ((System.currentTimeMillis() - start) / 1000d) + "s");
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

Running this under Windows 11 gives the following output and makes the CPU heating up, UI is reported as "unresponsive":

Open Shell
Open returned after 16.504s

Even for smaller numbers one can observe this, e.g. without the scale it take 20 ms to bring up the UI, using the scale with any number < 10.000 it is about 30 ms from 100.00 it already takes 100ms and from 10.000.000 it is already > 3 seconds.

While for a single scale this is often not noticable, if many are used that can change their min/max values dynamically this can easily lead to the user things the UI is lagging or even froozen.

laeubi avatar Jul 06 '24 09:07 laeubi

On linux the same snippet gives this outupt:

Open Shell
Open returned after 0.057s

laeubi avatar Jul 06 '24 09:07 laeubi

On Mac M1 Mini:

Open Shell
Open returned after 0.005s

On Windows, try resizing the Shell...

Phillipus avatar Jul 06 '24 21:07 Phillipus

On Windows 10 it is slow

Open Shell
Open returned after 10.938s

lathapatil avatar Apr 09 '25 10:04 lathapatil