Skip to content

[macOS] Delay when closing dialog #3718

Open

Description

@Phillipus
  • All versions of SWT and JFace
  • macOS 15, 26 or 27
  • Java 25 Temurin
  • This problem has always existed

There can be a delay when closing a Dialog (JFace or SWT) on Mac if it's followed by a long running task. This delay does not occur on Windows or Linux where the dialog is closed immediately.

Run the Snippet. On Windows or Linux the dialog or message box closes immediately. On Mac the dialog only closes when the long running task completes.

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

public class DialogCloseDelay {

    public static void main(String[] args) {
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setText("Dialog Test");
        shell.setLayout(new FillLayout());
        shell.setSize(450, 250);
        shell.open();

        // Same behavior on JFace Dialog or SWT Dialog (MessageBox)
        boolean useDialog = true;
        if(useDialog) {
            Dialog dialog = new Dialog(shell) {};
            dialog.open();
        }
        else {
            MessageBox box = new MessageBox(shell);
            box.open();
        }
        
        // Uncomment this to unfreeze it
        // shell.getDisplay().readAndDispatch();

        // Long running task
        try {
            Thread.sleep(4000);
        }
        catch(InterruptedException e) {}

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

If the following line in the Snippet is uncommented there is no freeze:

shell.getDisplay().readAndDispatch();

Activity

  1. changed the title [-][macOS] Delay/freeze when closing dialog[/-] [+][macOS] Delay when closing dialog[/+] on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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