JDK-8248381 : Create a daemon thread for MonocleTimer
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: openjfx15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2020-06-25
  • Updated: 2020-07-22
  • Resolved: 2020-07-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx15Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
$ uname -a
Linux touchc 2.6.35.3-850-gbc67621+ #619 PREEMPT
    Thu Dec 22 15:29:00 CST 2016 armv7l armv7l armv7l GNU/Linux

$ ldd --version
ldd (Ubuntu EGLIBC 2.19-0ubuntu6.15) 2.19

$ getconf GNU_LIBPTHREAD_VERSION
NPTL 2.19

$ ~/opt/jdk-14.0.1+7/bin/java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)

Additional:
Affects Version/s: openjfx15 (the JDK was version 14.0.1)
CPU: arm (32-bit ARMv7 "armhf")

I believe the bug is a regression error, if there's a place to add that, too. (It did not occur in JavaFX 14.)

A DESCRIPTION OF THE PROBLEM :
JavaFX applications on the Monocle platform do not terminate after a call to Platform.exit. Instead, they hang because the pulse timer created by MonocleTimer is a non-daemon thread.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the JavaFX application included below on a Monocle platform.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The program should terminate after printing three non-daemon threads, as shown below:

ubuntu@touchc:~/src/exitfx$ sudo $HOME/opt/jdk-14.0.1+7/bin/java \
    --add-modules=javafx.controls --module-path=$HOME/lib/armv6hf-sdk/lib \
    -Dglass.platform=Monocle -Dmonocle.platform=EPD -Dprism.order=sw \
    -Dmonocle.input.18/0/0/0.maxX=800 -Dmonocle.input.18/0/0/0.maxY=600 \
    -jar dist/exitfx.jar
Thread[JavaFX Application Thread,5,Event]
Thread[JavaFX-Launcher,5,main]
Thread[main,5,main]
ubuntu@touchc:~/src/exitfx$

ACTUAL -
The program hangs after printing four non-daemon threads, as shown below:

ubuntu@touchc:~/src/exitfx$ sudo $HOME/opt/jdk-14.0.1+7/bin/java \
    --add-modules=javafx.controls --module-path=$HOME/lib/armv6hf-sdk/lib \
    -Dglass.platform=Monocle -Dmonocle.platform=EPD -Dprism.order=sw \
    -Dmonocle.input.18/0/0/0.maxX=800 -Dmonocle.input.18/0/0/0.maxY=600 \
    -jar dist/exitfx.jar
Thread[JavaFX Application Thread,5,Event]
Thread[pool-2-thread-1,5,Event]
Thread[JavaFX-Launcher,5,main]
Thread[main,5,main]


---------- BEGIN SOURCE ----------
package org.status6.exitfx;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class ExitFX extends Application {

    @Override
    public void start(Stage stage) {
        Button button = new Button("Exit");
        button.setOnAction(e -> Platform.exit());
        StackPane root = new StackPane(button);

        Scene scene = new Scene(root, 800, 600);
        stage.setTitle("Exit App");
        stage.setScene(scene);
        stage.show();
    }

    @Override
    public void stop() {
        Thread.getAllStackTraces().keySet().forEach(thread -> {
            if (!thread.isDaemon()) {
                System.out.println(thread);
            }
        });
    }

    public static void main(String[] args) {
        launch(args);
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
The source-code workaround is to call System.exit in the stop method of the JavaFX application. The command-line workaround is to press Ctrl-C to cancel the program when it hangs.


FREQUENCY : always



Comments
Changeset: 5f60ea5d Author: John Neffenger <john@status6.com> Committer: Kevin Rushforth <kcr@openjdk.org> Date: 2020-07-21 12:26:07 +0000 URL: https://git.openjdk.java.net/jfx/commit/5f60ea5d
21-07-2020

Additional Information from submitter: =========================== Thank you for creating the report on the JDK Bug System so quickly. Could you make the following fixes to the Details section? Affects Version/s: openjfx15 (the JDK was version 14.0.1) CPU: arm (32-bit ARMv7 "armhf") I believe the bug is a regression error, if there's a place to add that, too. (It did not occur in JavaFX 14.)
29-06-2020

This is a pretty serious bug and should be fixed for JavaFX 15.
27-06-2020

This regression was caused by the fix for JDK-8176499.
27-06-2020

Updated description with additional details from submitter.
26-06-2020