Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset is outside the bounds of the DataView #52

Open
skynice opened this issue Jul 3, 2018 · 11 comments
Open

Offset is outside the bounds of the DataView #52

skynice opened this issue Jul 3, 2018 · 11 comments

Comments

@skynice
Copy link

skynice commented Jul 3, 2018

`[Violation] 'setTimeout' handler took 62ms
lzw.js?8b40:17 ran off the end of the buffer before finding EOI_CODE (end on input code)
getByte @ lzw.js?8b40:17
geotiffimage.js?5c03:327 Uncaught (in promise) RangeError: Offset is outside the bounds of the DataView
at DataView.getFloat32 ()
at eval (geotiffimage.js?5c03:327)

source.js?c402:32 Uncaught (in promise) RangeError: Invalid typed array length: -610682
at typedArrayConstructByArrayBuffer ()
at new Uint8Array (native)
at readRangeFromBlocks (webpack-internal:///143:116:23)
at BlockedSource._callee3$ (webpack-internal:///143:454:51)
at tryCatch (webpack-internal:///94:63:40)
at Generator.invoke [as _invoke] (webpack-internal:///94:337:22)
at Generator.prototype.(anonymous function) [as next] (webpack-internal:///94:96:21)
at step (webpack-internal:///29:17:30)
at eval (webpack-internal:///29:28:13)
at
readRangeFromBlocks @ source.js?c402:32
source.js?c402:32 Uncaught (in promise) RangeError: Invalid typed array length: -620184
at typedArrayConstructByArrayBuffer ()
at new Uint8Array (native)
at readRangeFromBlocks (webpack-internal:///143:116:23)
at BlockedSource._callee3$ (webpack-internal:///143:454:51)
at tryCatch (webpack-internal:///94:63:40)
at Generator.invoke [as _invoke] (webpack-internal:///94:337:22)
at Generator.prototype.(anonymous function) [as next] (webpack-internal:///94:96:21)
at step (webpack-internal:///29:17:30)
at eval (webpack-internal:///29:28:13)
at `

@constantinius
Copy link
Member

Hi @skynice

Thanks for submitting this issue. This seems like an error with LZW decoding. Could you please provide the TIFF file where this error occurs? Maybe I can have a look at it.

@skynice
Copy link
Author

skynice commented Jul 3, 2018

@constantinius please download in http://182.92.155.46:81/geotiff.tif

@constantinius
Copy link
Member

hm... when I try to open it with the basic testing html file it seems to load correctly (see image below; it is colorized using a color scale). What version of geotiff.js have you installed? Can you show me some code how you use it?

image

@skynice
Copy link
Author

skynice commented Jul 4, 2018

@constantinius i clone the git project , in my project ,i use like this:

    
    <title>Title</title>
    <script src="./geotiff.bundle.js"   type="text/javascript"></script>


<script>
    let  filename = "geotiff.tif";
    let pool  = new GeoTIFF.Pool();


    GeoTIFF.fromUrl(filename).then(function(tiff){
        tiff.readRasters({interleave:true},pool).then(function(raster){
            console.log('a')
        });

    }).catch(function(error){
        console.error(error)
    });
</script>

my browser is chrome 61.0.3163.79

please download in http://182.92.155.46:81/localhost.zip .see my chrome request deatials

@skynice
Copy link
Author

skynice commented Jul 4, 2018

@constantinius if i use like this, the worked...

<title>Title</title>
<script src="./geotiff.bundle.js"   type="text/javascript"></script>
<script>
    let  filename = "geotiff.tif";

    var xhr = new XMLHttpRequest();
    xhr.open('GET', filename, true);
    xhr.responseType = 'arraybuffer';
    xhr.onload = function(e) {
        let arrayBuffer = this.response;

        GeoTIFF.fromArrayBuffer(arrayBuffer).then(function(tiff ){
            tiff.getImage(0).then(function(image){
                let bbox = image.getBoundingBox();
                console.log(bbox);

                let width  = image.getWidth();
                let height = image.getHeight()
                image.readRasters().then(function(rasters){
                    console.log('a')
                });

            }).catch(function(error){
                console.log(error)
            })
        })

    }

    xhr.send();
/*
    GeoTIFF.fromUrl(filename).then(function(tiff){
        tiff.getImage(0).then(async function(image){
            let bbox = image.getBoundingBox();
            console.log(bbox);

            let width  = image.getWidth();
            let height = image.getHeight()
            let data = await image.readRasters();

            console.log(data.length)
        }).catch(function(error){
            console.log(error)
        })


    }).catch(function(error){
        console.error(error)
    });*/
</script> 

@constantinius
Copy link
Member

Alright, I see, I'll investigate further!

@constantinius
Copy link
Member

constantinius commented Jul 4, 2018

@skynice
Okay, I think I now know what the issue is.

The problem seems to be twofold.

First: your server does not seem to understand HTTP Range requests, as it seems to answer with the complete file, when it actually only should respond with a portion of it.

Second: there seems to be a bug in handling exactly that case in the fromUrl method within geotiff.js

If you are looking for a solution right now, you can use your second approach (downloading beforehand and using fromArrayBuffer) or use a different server that understands HTTP Range requests.

In any case, I'll try to fix the issue, but I cannot promise that it will be in the near future, as I'm quite involved in other tasks.

Please let me know if you have found a suitable solution. Thanks again for reporting this issue!

@skynice
Copy link
Author

skynice commented Jul 5, 2018

@constantinius thank you very much. i use webstorm nesting web server found the problem.today i receiver your reply ,i try iis or node express ,the function correctly

@jukkatolonen
Copy link

Hi @constantinius,

Do you have an estimate when this issue with fromUrl method will be fixed?

@constantinius
Copy link
Member

Hi @jukkatolonen

Do you have the same issue? If yes, you could mitigate it by switching to a server that properly supports range requests and the issue should not arise.

Regarding the issue itself: the response size is not actively enforced, but it is handled in a more robust way when unexpectedly the whole file is returned.

I think there need to be more configuration options for those cases (like raising errors, when the whole file is returned unexpectedly or just continue).

There is currently no direct plan to fix the issue, as there are currently no resources to address this issue.

@jukkatolonen
Copy link

Ok, thanks. I have some what similar issue but nothing that can't be worked around. Was just curious about the plans regarding this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants