JDK-8202066 : ListView with large number of rows is extremly slow when changing current multiple selection to a subset
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 9,10,openjfx11
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-04-19
  • Updated: 2019-05-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Duplicate :  
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
When having a lot of data and playing with multiple selection there are situations where it could get very very slow, even though in Java8 it was not. In my case I need to have a lot of data in a ListView (~50k), and when I do stuff like first selecting all items, and then shift+clicking to have only a subset selected, it can take a good couple of minutes before finishing, making the program unusable during that time.

It happens with Java9 as well.

REGRESSION : Last worked in version 8u161

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Prepare a list view with a lot of items (the bigger the list, the easier to notice the issue) for example 50_000
2) perfrom ctrl+a on a list to select all it's items
3) while having all items selected, do shift+click on one of the items to reduce the selection (for example click on the 3rd item on the list)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
selection should change to first 3 items only almost instantly
ACTUAL -
selection takes a couple of minutes, making the whole program unreponsive during that time

---------- BEGIN SOURCE ----------
public class StringPlayground2 extends Application {

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

	@Override
	public void start(Stage primaryStage) {
		int ELEMENTS = 55_000;
		List<String> stringList = new ArrayList<>(ELEMENTS);

		for (int i = 0; i < ELEMENTS; i++) {
			stringList.add("" + i);
		}

		ListView<String> listView = new ListView<>(FXCollections.observableArrayList(stringList));
		listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

//		listView.getSelectionModel().getSelectedItems()
//				.addListener((ListChangeListener) c -> System.out.println(c.getList().size()));

		primaryStage.setScene(new Scene(listView, 640, 480));
		primaryStage.show();
	}
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
That's a good observation Kevin. Similarly, JDK-8197991 has been reported for TableView when JDK-8154286 (extension of JDK-8154216) was fixed. The performance impact gets amplified with large number of rows. I acknowledge that it's an issue, but I don't think it is a P2.
23-04-2018

The following fix related to list selection went into jdk-9+115: JDK-8154216: Remove usage of ReadOnlyUnbackedObservableList in selection models for the selectedItems list I suspect that this might be the cause of the regression.
20-04-2018

This issue is regression introduced in 9 ea b115. shift+click takes more than 30 minutes to return selection. 8u172 - Pass 9 ea b114 - Pass 9 ea b115 - Fail --> Regression started from here 9 GA - Fail 10 GA - Fail 11 ea b08 - Fail
20-04-2018