question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GridView: infinite calls of updateItem method

See original GitHub issue

We’ve been using: FXControls 8.40.14. (JDK 8) Recently we’ve upgraded to: FXControls 11.0.1. (JDK 11)

After upgrade we’ve noticed issues related to GridView. What’s happening is that GridCell#updateItem is called infinitely.

I’ve searched Google group and Github issue tracker but haven’t found anything related…

After investigating it further it turned out that issues appears when animated GIFs are shown inside GridView.

I’ve prepared SSCCE which can be used to reproduce the issue:

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.controlsfx.control.GridCell;
import org.controlsfx.control.GridView;

import java.util.ArrayList;
import java.util.List;

public class GridViewItemUpdateTest extends Application {

	int gridCellUpdateCounter = 0;

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

	@Override
	public void start(Stage primaryStage) {

		GridView<Image> grid = new GridView<>();
		grid.setCellFactory(param -> new GifImageCell());
		grid.setItems(FXCollections.observableArrayList(getImagesList()));
		grid.setCellHeight(220);
		grid.setCellWidth(220);

		StackPane stackPane = new StackPane(grid);
		stackPane.setPrefSize(260, 440);

		Scene scene = new Scene(stackPane);
		primaryStage.setScene(scene);
		primaryStage.show();
	}

	private class GifImageCell extends GridCell<Image> {

		final StackPane stackPane = new StackPane();
		final	ImageView imageView = new ImageView();

		public GifImageCell() {
			imageView.setFitHeight(200);
			imageView.setFitWidth(200);
			stackPane.setMinWidth(220);
			stackPane.setMinHeight(220);
			stackPane.getChildren().add(imageView);
			stackPane.setPadding(new Insets(10));
		}

		@Override
		protected void updateItem(Image image, boolean empty) {
			super.updateItem(image, empty);

			System.out.println(++gridCellUpdateCounter);

			setText(null);

			if (empty || image == null) {
				setGraphic(null);
			} else {
				imageView.setImage(image);
				setGraphic(stackPane);
			}
		}
	}

	private List<Image> getImagesList() {
		final List<Image> images = new ArrayList<>();

		final Image gifImage = new Image("https://thumbs.gfycat.com/TepidVariableBluetickcoonhound-small.gif", 200, 200, true, false);

		for (int i = 0; i < 10; i++) {
			images.add(gifImage);
		}
		return images;
	}
}

When running this example with:

  • FXControls 8.40.14. (JDK 8), the updateItem will be called 19 times initially
  • FXControls 11.0.1. (JDK 11), the updateItem will be called infinitely

After further investigation I was able to found out that this issue is most probably related to this change (see GridRow.java:106): https://github.com/controlsfx/controlsfx/commit/8f06811e9487fd171eed835c7585c9ef2cf1be76#diff-056220662a7039e7b16736b23e4a7de2R106

Skipping line at GridRow.java:106 when debugging seems to fix the issue with infinite GridCell#updateItem(...) calls.

Unfortunately this issue makes GridView unusable for us.

Are there any workarounds we could apply to overcome this?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
geometrikalcommented, Nov 28, 2020

Same issue with custom GridCell with images. Very weird. I had some nothing code in the updateItem method, simply setting the text of a label. Removing it stopped the infinite spin but it still calls updateItem a lot.

0reactions
gdicristofarocommented, Nov 14, 2022

Hello,

I’ve been examining a similar issue that I have encountered. I believe a GridCell responds to an update in index by updating itself in this code, and I’m seeing my GridCell infinitely call update due to index changes that occur here. Is there any need to call updateIndex(-1) here before calling updateIndex for the correct cell index? Thank you for all the wonderful work on this project!

Read more comments on GitHub >

github_iconTop Results From Across the Web

GridView performance issue due to infinite GridCell ...
After upgrading we've noticed issues related to `GridView`. What's happening is that `GridCell#updateItem` is called infinitely.
Read more >
Infinite loop is occuring when trying to update a row in ... - MSDN
The Updating event fires as a part of the execution of UpdateRow. Calling like that is a recursion without end. When GridView is...
Read more >
A public method with the name '' was either not found
The grid-view uses a 'SelectMethod' in the code behind to generate the data. The problem I'm having is that every time I edit...
Read more >
Bountysource
GridView : infinite calls of updateItem method. ... Help and Information. Frequently Asked Questions · Bugs and Feature Requests · Fees ...
Read more >
Solutions to the SharePoint 5000 item limit using Power ...
Multiple methods to exceed the SharePoint 5000 Item limit using Power Automate. Via the standard Flow methods or the SharePoint API for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found