Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[win] Scale with large maximum freeze UI #1325

Open
laeubi opened this issue Jul 6, 2024 · 2 comments
Open

[win] Scale with large maximum freeze UI #1325

laeubi opened this issue Jul 6, 2024 · 2 comments
Labels
Windows Happens on Windows OS

Comments

@laeubi
Copy link
Contributor

laeubi commented Jul 6, 2024

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
Copy link
Contributor Author

laeubi commented Jul 6, 2024

On linux the same snippet gives this outupt:

Open Shell
Open returned after 0.057s

@laeubi laeubi added the Windows Happens on Windows OS label Jul 6, 2024
@Phillipus
Copy link
Contributor

Phillipus commented Jul 6, 2024

On Mac M1 Mini:

Open Shell
Open returned after 0.005s

On Windows, try resizing the Shell...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Happens on Windows OS
Projects
None yet
Development

No branches or pull requests

2 participants