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

Cursor disappears after changing it with a new ImageCursor many times

XMLWordPrintable

    • x86_64
    • windows

      ADDITIONAL SYSTEM INFORMATION :
      x86_64/Windows/17.0.5+8-LTS

      A DESCRIPTION OF THE PROBLEM :
      I discovered that changing Scene's cursor using ImageCursor many times (about 3k+ times on my setup depending on image size) leads to complete disappearance of the cursor and high memory consumption. Tested on several machines using javafx 17, 21 , 23 and on Windows(10/11) the problem reproduces every time. I couldn't reproduce it on MacOS or Linux.


      ---------- BEGIN SOURCE ----------
      package com.example.demo;

      import javafx.animation.AnimationTimer;
      import javafx.application.Application;
      import javafx.scene.ImageCursor;
      import javafx.scene.Scene;
      import javafx.scene.image.Image;
      import javafx.scene.layout.Pane;
      import javafx.stage.Stage;

      import java.io.IOException;

      public class HelloApplication extends Application {
          private int count = 0;
          private long lastUpdate = 0;

          @Override
          public void start(Stage stage) throws IOException {
              Pane pane = new Pane();
              Scene scene = new Scene(pane, 300.0, 200.0);
              stage.setScene(scene);
              AnimationTimer timer = new AnimationTimer() {
                  @Override
                  public void handle(long now) {
                      if (now - lastUpdate >= 1_000_000_0) {
                          Image image;
                          if (count % 2 == 0) {
                              image = new Image(HelloApplication.this.getClass().getResourceAsStream("/com/example/demo/1.png"));
                          } else {
                              image = ne
      ---------- END SOURCE ----------

      FREQUENCY : always


            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: