Weird Grid bug that seems to only affect Chrome...

I’m using the latest version 8.1.4 of Vaadin. The code is simple consists of three columns where one column is an Image component. When that row is selected the Image component changes the image to another row’s image for the grid. Eventually after a number of select and unselect (the image also changes on unselect) the image eventually settles on an image.

public StreamResource getImageForGrid()
{
    StreamResource streamResource = new StreamResource(
        () -> {
            System.out.print("Line is not output sometimes when rendering grid");
            return new ByteArrayInputStream(getConvertedThumbnailImage());
        }, name + ".jpg");
    streamResource.setCacheTime(0);
    return streamResource;
}

For whatever reason the System.out.println line will not be executed in Chrome consistently. In Firefox it’s always called when rendering the grid but in Chrome the System.out.println is often not called which results in the above weird error and behavior. Sometimes it’s not even called at all which makes me confused as to how the thumbnails in the grid are even generated? I have to assume some kind of browser caching?

My grid consists of:

grid.addComponentColumn(gridData -> new Image(gridData.getName(), gridData.getImageForGrid()); Has anyone run into this bug? And if so how do you resolve it?

Also the reason I’m suing an Image in the grid is that I couldn’t find any other way to display thumbnails generated on the fly.

If the image is not big, then one alternative could be to use ExternalResrouce and have image Base64 coded in URL.

I used that approach when I created the BlobImageRenderer: vaadin.com/directory/#!addon/grid-renderers-collection-for-vaadin7

I can’t because I’m creating the images on the fly based what the user is doing. A good example would be generating thumbnails of weather radar images. In fact it’s not that, it’s more pulling data from the database and creating thumbnails based on the data, but nonetheless it’s not an ExternalResource. The key is that I don’t want to manage a URL when one doesn’t exist, the thumbnails are only needed (and generated) when displaying the grid.

Check if the BlobImageRenderer fits you. It reads byte array from Grid property and renders it as image. So if you have thumbnails in your DTO in the Grid as byte array, it works directly.

That actually worked perfectly!! Thanks for the tip.

For those who don’t know the link to the referred add-on is:
https://vaadin.com/directory#!addon/grid-renderers-collection-for-vaadin7