Bug 541282 - shell fullscreen hangs when using com.apple.concurrent.Dispatch
Summary: shell fullscreen hangs when using com.apple.concurrent.Dispatch
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.9   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-18 08:35 EST by Al Bundy CLA
Modified: 2020-11-09 05:25 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Al Bundy CLA 2018-11-18 08:35:37 EST
Because -XstartOnFirstThread does not work for webstart-applications on osx I've tried to find another solution.

The DispatchTest is a small example how to start a swt-application without -XstartOnFirstThead.
This seems to work very well (also with rcp applications) but unfortunately the whole application hangs if you try to make the application fullscreen.

Has someone an idea how to get also the fullscrenmode to work?

afaik th package com.apple.concurrent was removed in java 9 - so you can try this example class only with java versions up to 8 or get the source from this classes from here: https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/macosx/classes/com/apple/concurrent/Dispatch.java

<pre>
import java.awt.Toolkit;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.FutureTask;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class DispatchTest
{
  public static void main(String[] args)
    throws Exception
  {
    String osName = System.getProperty("os.name");
    // if not a mac return false
    if (!osName.startsWith("Mac") && !osName.startsWith("Darwin"))
    {
      DispatchTest.run();
    }
    else
    {
      try
      {
        Class<?> _c = Class.forName("com.apple.concurrent.Dispatch");
        final Method _get_instance = _c.getMethod("getInstance", null);
        final Object _instance = _get_instance.invoke(null, null);
        final Method _get_executor = _instance.getClass().getMethod("getNonBlockingMainQueueExecutor", null);
        final Executor _executor = (Executor) _get_executor.invoke(_instance, null);
        Toolkit.getDefaultToolkit();
        final FutureTask<Void> _f = new FutureTask<Void>(new Callable<Void>()
        {
          /**
           * {@inheritDoc}
           */
          @Override
          public Void call()
              throws Exception
          {
            DispatchTest.run();
            return null;
          }
        });
        _executor.execute(_f);
        _f.get();
      }
      catch (final Throwable _e)
      {
        _e.printStackTrace();
      }
    }
  }
  
  private static void run()
  {
    try
    {
      final Display display = new Display();
      final Shell shell = new Shell(display);
      shell.setText("Hello, world!");
      shell.open();

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

      display.dispose();
    }
    catch (Exception _e)
    {
      _e.printStackTrace();
    }
  }
}

</pre>
Comment 1 Eclipse Genie CLA 2020-11-08 00:49:07 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 2 Al Bundy CLA 2020-11-09 05:25:19 EST
This is still an issue when using webstart.