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

Selection of multiple items in ListView hung UI

XMLWordPrintable

    • x86
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      OpenJFX EAP: 13-ea+6

      OpenJDK:
      openjdk version "13-internal" 2019-09-17
      OpenJDK Runtime Environment (build 13-internal+0-jdk13-jpackage.49)
      OpenJDK 64-Bit Server VM (build 13-internal+0-jdk13-jpackage.49, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      I have ListView with several thousands items and enabled multi-select. When I try to select many items in ListView it hung whole application.

      This functionality works fine in JDK 8 (I could select millions of item without any delays) but looks like was broken after this release.

      REGRESSION : Last worked in version 8u192

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run test application (here Maven project for any case: https://github.com/maxd/listview_multiselect_performance ) or from code below.

      Manual steps to reproduce:

      1. Select first item in ListView
      2. Scroll down to last item in ListView
      3. Press `SHIFT` key and select last item

      Steps to reproduce from code:

      1. Click `Select %d items and measure selection time`

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Selected items must be selected without delay
      ACTUAL -
      Selection of multiple items hung application and macOS show mac rainbow wheel (it's mean that application doesn't respond).

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.Alert;
      import javafx.scene.control.Button;
      import javafx.scene.control.ListView;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class App extends Application {
          @Override
          public void start(Stage stage) {
              int itemsCount = 20_000;

              ObservableList<String> list = FXCollections.observableArrayList();

              for (int i = 0; i < itemsCount; i++) {
                  list.add(String.format("%07d", i));
              }

              ListView<String> listView = new ListView<>(list);
              listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

              Button button = new Button(String.format("Select %d items and measure selection time", itemsCount));
              button.setOnAction(actionEvent -> {
                  long timestamp = System.currentTimeMillis();

                  listView.getSelectionModel().selectRange(0, itemsCount - 1); // <== Here `selectRange` take a lot of time to select items

                  String message = String.format("Selection time: %d seconds", (System.currentTimeMillis() - timestamp) / 1000);
                  Alert alert = new Alert(Alert.AlertType.INFORMATION, message);
                  alert.initOwner(stage);
                  alert.showAndWait();
              });

              stage.setScene(new Scene(new VBox(listView, button)));
              stage.show();
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            aghaisas Ajit Ghaisas
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: