geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
878 stars 183 forks source link

blockedsource.js?2917:142 Uncaught (in promise) AggregateError: Request failed #318

Closed RoymanLuo closed 1 year ago

RoymanLuo commented 2 years ago

when I use a tif file which height is 1401, it would console this error when readRasters at BlockedSource.fetch (blockedsource.js?2917:142:1) at async GeoTIFFImage.getTileOrStrip (geotiffimage.js?ae25:384:1) at async Promise.all (:8080/index 1) at async GeoTIFFImage._readRaster (geotiffimage.js?ae25:516:1) at async GeoTIFFImage.readRasters (geotiffimage.js?ae25:610:1) at async readGeotiff (useGeotiff.js?9243:11:1) What can I do to solve this problem ? const tif = await GeoTIFF.fromUrl('./dem.tif') const tifImage = await tif.getImage() const image = { width: tifImage.getWidth(), height: tifImage.getHeight() } const pool = new GeoTIFF.Pool(); const data = await tifImage.readRasters({ interleave: true, pool })

ahocevar commented 2 years ago

I did some research on this, and it is a regression introduced by #284. Also, running the test page (npm run dev) on http://localhost:8090/test/ shows the same error messages, as well as an OpenLayers example (https://github.com/geotiffjs/geotiff.js/pull/284#issuecomment-1120473072).

It turns out that as soon as the block cache is full, this issue occurs. A workaround is to set a huge cacheSize, but that's not a solution.

This means that since #284, geotiff.js is seriously broken.

ahocevar commented 2 years ago

The reason is that pending block loads are not protected from being evicted from the cache. I'm trying to fix this right now, hoping to have a pull request ready soon.

The missing blocks that trigger the error were indeed evicted from the cache before being used. See #336 for the fix.