Land/Sea Mask in graph

Hi, I am trying to do mask area not covered by provided shapefile mask. It is processed 90 % and then in crashes with following error:

Executing processing graph
…10%…20%…30%…40%…50%…60%…70%…80%…90% done.
org.esa.snap.core.gpf.OperatorException: pos < flushedPos!
at org.esa.snap.core.gpf.graph.GraphProcessor$GPFImagingListener.errorOccurred(GraphProcessor.java:373)
at com.sun.media.jai.util.SunTileScheduler.sendExceptionToListener(SunTileScheduler.java:1646)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:921)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at org.esa.snap.core.image.VirtualBandOpImage.addDataToReferredRasterDataSymbols(VirtualBandOpImage.java:309)
at org.esa.snap.core.image.VirtualBandOpImage.computeTile(VirtualBandOpImage.java:235)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.datamodel.Band.readRasterData(Band.java:311)
at org.esa.snap.core.dataio.ProductSubsetBuilder.readBandRasterDataRegion(ProductSubsetBuilder.java:328)
at org.esa.snap.core.dataio.ProductSubsetBuilder.readBandRasterDataImpl(ProductSubsetBuilder.java:297)
at org.esa.snap.core.dataio.AbstractProductReader.readBandRasterData(AbstractProductReader.java:250)
at org.esa.snap.core.gpf.common.SubsetOp.computeTile(SubsetOp.java:269)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:80)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at com.bc.ceres.glevel.MultiLevelImage.getData(MultiLevelImage.java:64)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:407)
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(OperatorContext.java:393)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:73)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at com.sun.media.jai.util.RequestJob.compute(SunTileScheduler.java:247)
at com.sun.media.jai.util.WorkerThread.run(SunTileScheduler.java:468)
Caused by: java.lang.IndexOutOfBoundsException: pos < flushedPos!
at javax.imageio.stream.FileImageInputStream.seek(FileImageInputStream.java:143)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFNullDecompressor.decodeRaw(TIFFNullDecompressor.java:214)
at it.geosolutions.imageio.plugins.tiff.TIFFDecompressor.decodeRaw(TIFFDecompressor.java:2168)
at it.geosolutions.imageio.plugins.tiff.TIFFDecompressor.decode(TIFFDecompressor.java:2625)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFNullDecompressor.decode(TIFFNullDecompressor.java:174)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.decodeTile(TIFFImageReader.java:1505)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:1783)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFRenderedImage.read(TIFFRenderedImage.java:300)
at it.geosolutions.imageioimpl.plugins.tiff.TIFFRenderedImage.getData(TIFFRenderedImage.java:284)
at org.esa.snap.dataio.geotiff.GeoTiffProductReader.readRect(GeoTiffProductReader.java:256)
at org.esa.snap.dataio.geotiff.GeoTiffProductReader.readBandRasterDataImpl(GeoTiffProductReader.java:158)
at org.esa.snap.core.dataio.AbstractProductReader.readBandRasterData(AbstractProductReader.java:250)
at org.esa.snap.core.gpf.common.ReadOp.computeTile(ReadOp.java:140)
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(OperatorImage.java:80)
at javax.media.jai.SourcelessOpImage.computeTile(SourcelessOpImage.java:137)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
… 27 more

Error: pos < flushedPos!

Can someone tell me if this is a memory issue or what is the error related to?

Could it be that there are some topological errors in your polygon?
If you apply a buffer with size 0 on it in a GIS they often are cleared out.

It runs without problems if I try to do the same process using the same data in SNAP GUI, which is little baffling. Therefore I doubt it is invalid geometry but I will try to run it through the buffer anyway and see.

The processing is done in docker image and should be applicable to any input data regardless of location (mask out land), the mask is therefore global ocean mask (simplified, 7 MB and cut to tiles, but in single shapefile). If I subset the image first the process finishes.

I have run the buffer to fix potential topological errors, but the outcome is the same. I still get the same error.

I’ve seen this a few times with tiff data but couldn’t figure out the root cause yet.
Maybe you try a different output format. maybe DIMAP or NetCDF. If this works you can try to convert this to GeoTiff.