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

OutOfMemoryError with FadeTransition under certain circumstances

    XMLWordPrintable

    Details

    • Type: Backport
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8, 8u20
    • Fix Version/s: 7u111
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b05

      Description

      Animation + resizing leads to OOM error in javafx2, so it's partial backport of 8096749 to javafx2.

      test case:

      import javafx.animation.Animation;
      import javafx.animation.AnimationTimer;
      import javafx.animation.FadeTransition;
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.StackPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;
      import javafx.stage.StageStyle;
      import javafx.util.Duration;

      public class TransparentStage extends Application {

          public static final int MAX_WIDTH = 1920;
          public static final int MAX_HEIGHT = 1080;
          public static final int MIN_WIDTH = 10;
          public static final int MIN_HEIGHT = 10;

          @Override
          public void start(final Stage stage) {
              stage.initStyle(StageStyle.TRANSPARENT);
              Text text = new Text("Transparent!");
              text.setFont(new Font(40));

              VBox box = new VBox();
              box.getChildren().add(text);
              final Scene scene = new Scene(box, MAX_WIDTH, MAX_HEIGHT);
              scene.setFill(null);
              stage.setScene(scene);
              stage.show();

              Rectangle rect = new Rectangle(MAX_WIDTH, MAX_HEIGHT);
              rect.setFill(Color.SALMON);
              rect.setOpacity(0);
              box.getChildren().add(rect);


              AnimationTimer animationTimer = new AnimationTimer() {
                  @Override
                  public void handle(long now) {
                      final double width = stage.getWidth();
                      final double height = stage.getHeight();

                      final double newWidth = (MIN_WIDTH + width + 10)% MAX_WIDTH;
                      final double newHeight = (MIN_HEIGHT + height + 10)% MAX_HEIGHT;
                      stage.setWidth(newWidth);
                      stage.setHeight(newHeight);
                  }
              };
              animationTimer.start();
              FadeTransition ft = new FadeTransition(Duration.seconds(5), rect);
              ft.setToValue(1);
              ft.setCycleCount(100);
              ft.play();
          }

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

      To reproduce the issue you need to run jvm with the following args: -Xms1000m -Xmx1000m

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mcherkas Mikhail Cherkasov (Inactive)
              Reporter:
              mberryjfx Michael Berry (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: