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

QuantumRenderer hangs with D3DERR_OUTOFVIDEOMEMORY exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • 9
    • 8u25, 8u40
    • javafx
    • None

      Dear JavaFX team,

      after running a small test application for about 20 seconds on a Windows 8.1 machine (see environment), the QuantumRenderer won't update / refresh the application anymore and a D3DERR_OUTOFVIDEOMEMORY exception occurs in the console.

      I've created a small application which displays 250 TextFields with different background styles and an animated image. The following traces will be shown in the console after the application locks:

      C:\tmp>java -Dprism.verbose=true -jar JFXDemo.jar 250
      Prism pipeline init order: d3d sw
      Using platform text rasterizer
      Using native-based Pisces rasterizer
      Using dirty region optimizations
      Not using texture mask for primitives
      Not forcing power of 2 sizes for textures
      Using hardware CLAMP_TO_ZERO mode
      Opting in for HiDPI pixel scaling
      Prism pipeline name = com.sun.prism.d3d.D3DPipeline
      Loading D3D native library ...
              succeeded.
      D3DPipelineManager: Created D3D9Ex device
      Direct3D initialization succeeded
      (X) Got class = class com.sun.prism.d3d.D3DPipeline
      Initialized prism pipeline: com.sun.prism.d3d.D3DPipeline
      Maximum supported texture size: 8192
      Maximum texture size clamped to 4096
      OS Information:
              Windows 8.1 build 9600
      D3D Driver Information:
              Intel(R) HD Graphics 4600
              \\.\DISPLAY2
              Driver igdumdim32.dll, version 10.18.10.3960
              Pixel Shader version 3.0
              Device : ven_8086, dev_0412, subsys_309F17AA
              Max Multisamples supported: 0
       vsync: true vpipe: true
      Testing with 250 textfields
      Loading Prism common native library ...
              succeeded.
      D3D hresult failed :D3DERR_OUTOFVIDEOMEMORY
      java.lang.Exception: Stack trace
              at com.sun.prism.d3d.D3DContext.validate(Unknown Source)
              at com.sun.prism.d3d.D3DContext.validatePresent(Unknown Source)
              at com.sun.prism.d3d.D3DSwapChain.present(Unknown Source)
              at com.sun.javafx.tk.quantum.PresentingPainter.run(Unknown Source)
              at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
              at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
              at com.sun.javafx.tk.RenderJob.run(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
              at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(Unknow
      n Source)
              at java.lang.Thread.run(Unknown Source)

      I've attached the source code of the test program here:
      package demo;
      import java.text.DateFormat;
      import java.text.NumberFormat;
      import java.util.Date;
      import java.util.Random;

      import javafx.animation.ParallelTransition;
      import javafx.animation.RotateTransition;
      import javafx.animation.Timeline;
      import javafx.animation.TranslateTransition;
      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.beans.binding.Bindings;
      import javafx.beans.binding.StringBinding;
      import javafx.beans.property.Property;
      import javafx.beans.property.SimpleLongProperty;
      import javafx.beans.property.SimpleObjectProperty;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.TextField;
      import javafx.scene.image.ImageView;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.FlowPane;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Duration;
      public class JFXDemo extends Application {
      private static int numberTextFields = 20;
      private static int updateDelay = 50;

      public static void main(String[] args) {
      if (args.length >= 1) {
      try {
      numberTextFields = Integer.parseInt(args[0]);
      System.out.println("Testing with "+ numberTextFields +" textfields");
      } catch (NumberFormatException nfe) {
      }
      }
      if (args.length >= 2) {
      try {
      updateDelay = Integer.parseInt(args[0]);
      System.out.println("Updating textfields with a delay of " + updateDelay);
      } catch (NumberFormatException nfe) {
      }
      }
      Application.launch(JFXDemo.class, args);
      }

      private TextField[] fields;

      private SimpleLongProperty numberOfTextFieldUpdates = new SimpleLongProperty(0);
      private Date startedAt = new Date();
      private Property<Date> currentTime = new SimpleObjectProperty<Date>(startedAt);

      private StringBinding currentTimeBinding;

      private StringBinding durationBinding;
      private StringBinding numberOfTextFieldBinding;

      @Override
      public void start(Stage primaryStage) throws Exception {
      BorderPane pane = new BorderPane();

      VBox statisticsPane = new VBox();
      Label textFieldUpdates = new Label();
      numberOfTextFieldBinding = Bindings.createStringBinding(() -> NumberFormat.getInstance().format(numberOfTextFieldUpdates.getValue()), numberOfTextFieldUpdates);
      textFieldUpdates.textProperty().bind(numberOfTextFieldBinding);

      Label startedAtLabel = new Label(DateFormat.getInstance().format(startedAt));
      Label currentTime = new Label();

      currentTimeBinding = Bindings.createStringBinding(() -> DateFormat.getInstance().format(this.currentTime.getValue()), this.currentTime);
      currentTime.textProperty().bind(currentTimeBinding);

      Label durationLabel = new Label();
      durationBinding = Bindings.createStringBinding(() -> (this.currentTime.getValue().getTime() - this.startedAt.getTime()) + "ms", this.currentTime);
      durationLabel.textProperty().bind(durationBinding);

      statisticsPane.setStyle("-fx-background-color: white;");
      statisticsPane.getChildren().addAll(new HBox(new Label("Number of TextField updates: "), textFieldUpdates));
      statisticsPane.getChildren().addAll(new HBox(new Label("Started at: "), startedAtLabel));
      statisticsPane.getChildren().addAll(new HBox(new Label("Current time: "), currentTime));
      statisticsPane.getChildren().addAll(new HBox(new Label("Duration: "), durationLabel));
      pane.setBottom(statisticsPane);


      if (numberTextFields <= 0) {
      numberTextFields = 20;
      }
      fields = new TextField[numberTextFields];

      FlowPane flowPane = new FlowPane();
      String[] styles = new String[] {
      "-fx-background-color: green;",
      "-fx-background-color: red;",
      "-fx-background-color: blue;",
      "-fx-background-color: yellow;",
      "-fx-background-color: orange;",
      "-fx-background-color: brown;",
      };

      for (int i = 0; i < numberTextFields; i++) {
      fields[i] = new TextField();
      fields[i].setStyle(styles[i % styles.length]);
      Label label = new Label();
      label.textProperty().bind(fields[i].textProperty());
      flowPane.getChildren().add(new HBox(label, fields[i]));
      }

      Random r = new Random();

      Thread updater1 = new Thread(() -> {
      try {
      while (true) {
      Thread.sleep(50);
      Platform.runLater(() -> {
      pane.setStyle(styles[r.nextInt(styles.length) % styles.length]);
      numberOfTextFieldUpdates.setValue(numberOfTextFieldUpdates.get() + 1);
      this.currentTime.setValue(new Date());
      });

      for (TextField tf : fields) {
      Platform.runLater(() -> {
      tf.setText(r.nextInt(Integer.MAX_VALUE) + "");
      });
      }
      }
      }
      catch (InterruptedException ie) {
      }
      });
      updater1.setDaemon(true);
      updater1.start();

      ImageView sun = new ImageView(getClass().getResource("sun.jpg").toString());
      Pane sunPane = new Pane();
      sunPane.getChildren().add(sun);
      pane.setRight(sunPane);
      sunPane.prefHeightProperty().bind(pane.heightProperty());

      RotateTransition sunRotation = new RotateTransition(Duration.millis(5000), sun);
      sunRotation.setFromAngle(0);
      sunRotation.setToAngle(360);
      sunRotation.setAutoReverse(true);
      TranslateTransition translateTransition = new TranslateTransition(Duration.millis(5000), sun);
      translateTransition.setFromY(-223);
      translateTransition.setToY(1080);

      ParallelTransition parallel = new ParallelTransition();
      parallel.getChildren().addAll(sunRotation, translateTransition);
      parallel.setCycleCount(Timeline.INDEFINITE);
      parallel.play();

      pane.setCenter(flowPane);
      Scene mainScene = new Scene(pane);
      primaryStage.setScene(mainScene);
      primaryStage.setMaximized(true);
      primaryStage.setTitle("TextField test application");
      primaryStage.show();
      }
      }

      If you want to test this yourself you need to add an image with the name "sun.jpg" to the demo package folder. I am afraid I couldn't figure out how to upload a .zip containing both the sources + a runnable version of this program (if you need it, please tell me how to upload it!).
      In any case you might compile the program with following command:
      javac demo\JFXDemo.java

      To run the program run the following command:
      java -cp . demo.JFXDemo 250


      I've not been able to reproduce this error in a different environment. I ran it on a identical machine and the same error occurs. If you need additional information, please tell me. This bug will occur with any JavaFX application, but it might takes up to two weeks of runtime until the QuanturmRenderer finally stops with the error above.

      I need to know if this is an issue with this hardware configuration or if this is a bug in the JavaFX implementation. Your help is greatly appreciated!

      Best Regards,
      Fabian

            flar Jim Graham
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: