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

Simple WebEngine application is undeterministic (works/works very slowly/hangs/throws exception)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u5
    • javafx
    • java version "1.8.0_05"
      Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      Microsoft Windows [Version 6.3.9600]

    • web

      The code in the listing below has 4 possible outcomes. In my opinion, the application should always have outcome 1.

      1) successful run, with loading finished in about a second. Output:
      SCHEDULED
      RUNNING
      SUCCEEDED
      1082

      2) successful run, but with extremely slow loading (in this case over a minute). Output:
      SCHEDULED
      RUNNING
      SUCCEEDED
      60295

      3) the application hangs (or at least doesn't finish within 15 minutes). Output:
      SCHEDULED
      RUNNING

      4) loading succeeds, but an exception is thrown. Output:
      SCHEDULED
      RUNNING
      SUCCEEDED
      1102
      mei 01, 2014 6:24:45 PM com.sun.webkit.network.URLLoader doRun
      WARNING: Unexpected error
      java.lang.IllegalStateException: Attempt to call defer when toolkit not running
      at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:675)
      at com.sun.javafx.webkit.prism.PrismInvoker.invokeOnEventThread(PrismInvoker.java:54)
      at com.sun.webkit.network.URLLoader.callBack(URLLoader.java:847)
      at com.sun.webkit.network.URLLoader.didReceiveResponse(URLLoader.java:714)
      at com.sun.webkit.network.URLLoader.receiveResponse(URLLoader.java:464)
      at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:143)
      at com.sun.webkit.network.URLLoader.access$000(URLLoader.java:43)
      at com.sun.webkit.network.URLLoader$1.run(URLLoader.java:107)
      at com.sun.webkit.network.URLLoader$1.run(URLLoader.java:104)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.webkit.network.URLLoader.run(URLLoader.java:104)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:744)


      code:

      import java.util.concurrent.TimeUnit;
      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.concurrent.Worker;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class WebEngineIssue extends Application {

      private static final String JAVA_API = "http://docs.oracle.com/javase/8/docs/api/";
      private static final String JAVAFX_API = "http://docs.oracle.com/javase/8/javafx/api/";

      @Override
      public void start(final Stage stage) {
      long start = System.nanoTime();
      WebEngine engine = new WebEngine();
      engine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> {
      System.out.println(newState);
      if (newState == Worker.State.SUCCEEDED) {
      System.out.println(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
      Platform.exit();
      }
      });
      engine.load(JAVA_API);

      WebView view = new WebView();
      WebEngine viewEngine = view.getEngine();
      viewEngine.load(JAVAFX_API);
      }

      }

            Unassigned Unassigned
            avanelverjfx Anthony Vanelverdinghe (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Imported: