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

Java application crashes when I open a DirectoryChooser from WebView

XMLWordPrintable

    • web
    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      JAVA version:
      java version "1.8.0_241"
      Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
      Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

      OS type: 64 bit
      Graphics: Intel® HD Graphics 620 (Kaby Lake GT2)
      Processor: Intel® Core™ i5-7200U CPU @ 2.50GHz × 4
      RAM: 7.7 GiB
      OS: Ubuntu 16.04 LTS

      A DESCRIPTION OF THE PROBLEM :
      Whenever we open javafx.stage.DirectoryChooser and keep it open for 2 minutes, the application crashes.
      I opened a Directory Chooser by binding a JS object with a java object and calling java method from there.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In general:
      1. Open a javafx.scene.web.WebView and bind a js object member in it to a java object with a method to open javafx.stage.DirectoryChooser
      2. Open javafx.stage.DirectoryChooser by calling method in bound java object from javafx.scene.web.WebView.
      3. Wait for 2 minutes

      In the attached file:
      1. Run the attached source.
      2. Click on "Click me!" button. A javafx.stage.DirectoryChooser will open.
      3. Wait for 2 minutes

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The application should not crash
      ACTUAL -
      The java application crashes

      ---------- BEGIN SOURCE ----------
      import java.io.File;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.web.WebView;
      import javafx.stage.DirectoryChooser;
      import javafx.stage.Stage;
      import netscape.javascript.JSObject;


      public class Main extends Application {

      public static Stage stage = null;

          @Override
          public void start(Stage primaryStage) throws Exception {
              final WebView root = new WebView();
              root.getEngine().documentProperty().addListener((obs, oldDoc, newDoc) -> {
                  if (newDoc != null) {
                      JSObject window = (JSObject) root.getEngine ().executeScript ("window");
                      window.setMember ("viewObj", this);
                  }
              });
      // root.getEngine().load(getClass().getResource("view.html").toURI().toString());
              root.getEngine().loadContent("<!DOCTYPE html>"
                      +"<html>"
                      +" <head>"
                      +" <meta charset=\"utf-8\">"
                      +" <link rel=\"stylesheet\" href=\"app.css\" />"
                      +" <link rel=\"stylesheet\" href=\"d3-context-menu.css\" />"
                      +" <link rel=\"stylesheet\" href=\"tab.css\" />"
                      +" </head>"
                      +" <script>"
                      +" function open_file_chooser(){"
                      +" console.log(\"Reached export_data\");"
                      +" viewObj.openFileChooser();"
                      +" }"
                      +" </script>"
                      +" <body>"
                      +" <button type=\"button\" onclick=\"open_file_chooser();\">Click Me!</button>"
                      +" </body>"
                      +"</html>");
              primaryStage.setTitle("TestGetScene");
              primaryStage.setScene(new Scene(root));
              primaryStage.show();
              stage = primaryStage;
          }
         
          public void openFileChooser() {
              DirectoryChooser dirChooser = new DirectoryChooser();
              dirChooser.setTitle("Export Tree");
              File pathTosave = dirChooser.showDialog(null);
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            jbhaskar Jay Bhaskar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: