Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269796

Platform.runLater() can hang forever if Toolkit startup fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: openjfx16
    • Fix Version/s: None
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      A DESCRIPTION OF THE PROBLEM :
      Unhandled exception in Toolkit.getToolkit().startup() causes Platform.runLater() to hang forever. This happens, for example, on headless Linux machines.
      Stack traces and thread dumps can be found here https://github.com/ylexus/jiotty-photos-uploader/issues/115.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      To reproduce, run a javafx program on a headless Linux box.
      1. Call Application.lanuch()
      2. Call Platform.runLater() from another thread - it will block waiting on a CountdownLatch for Platform to fully start
      3. PlatformImpl.startup() calls
      Toolkit.getToolkit().startup(() -> {
                  startupLatch.countDown();
                  r.run();
              });
      4. Toolkit fails before it invokes the runnable:
      2021-06-24T22:09:53,774 ERROR [Thread-2] j.l.Throwable Exception in thread "Thread-2" java.lang.UnsupportedOperationException: Unable to open DISPLAY
      2021-06-24T22:09:53,776 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$new$6(GtkApplication.java:173)
      2021-06-24T22:09:53,777 ERROR [Thread-2] j.l.Throwable at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
      2021-06-24T22:09:53,778 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:171)
      2021-06-24T22:09:53,779 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
      2021-06-24T22:09:53,779 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.glass.ui.Application.run(Application.java:145)
      2021-06-24T22:09:53,780 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:281)
      2021-06-24T22:09:53,781 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:288)
      2021-06-24T22:09:53,782 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:160)
      2021-06-24T22:09:53,783 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
      2021-06-24T22:09:53,784 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
      2021-06-24T22:09:53,785 ERROR [Thread-2] j.l.Throwable at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
      2021-06-24T22:09:53,785 ERROR [Thread-2] j.l.Throwable at java.base/java.lang.Thread.run(Thread.java:831)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Platform.runLater() returns
      ACTUAL -
      Result: the thread that called Platform.runLater() is blocked forever.

      ---------- BEGIN SOURCE ----------
      On a headless Linux box, follow instructions on https://github.com/ylexus/jiotty-photos-uploader to run the GUI.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Be careful not to invoke Platform.runLater() before the platform is fully initialised.

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pnarayanaswa Praveen Narayanaswamy
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: