samvera / serverless-iiif

IIIF Image API 2.1 & 3.0 server in an AWS Serverless Application
https://samvera.github.io/serverless-iiif/
Apache License 2.0
69 stars 21 forks source link

image dimension errors #120

Closed t4k closed 1 year ago

t4k commented 1 year ago

likely related to my previous issue #116

I'm now using 4.3.3 and found another situation where errors are occurring.

https://bfp3moalhxhpcrwmztmhq6z27e0fkeok.lambda-url.us-west-2.on.aws/iiif/2/collections/Palomar/PP18_v01_1936-1937/output_image_vips/full/full/0/default.jpg does not work: The image “…” cannot be displayed because it contains errors. (Meanwhile, smaller versions work fine: 100px, 1000px)

Relevant CloudWatch entries:

2023-08-10T17:42:48.472Z d8596df6-5377-4055-be0a-cc11ee6133bb WARN Unable to get dimensions for collections/Palomar/PP18_v01_1936-1937/output_image_vips using custom function. Falling back to sharp.metadata().

2023-08-10T17:42:49.764Z    d8596df6-5377-4055-be0a-cc11ee6133bb    ERROR   TypeError: Cannot read properties of undefined (reading 'toString')
    at /var/task/cache.js:31:54
    at new Promise (<anonymous>)
    at makeCache (/var/task/cache.js:29:10)
    at handleImageRequestFunc (/var/task/index.js:70:13)
    at async handleResourceRequestFunc (/var/task/index.js:49:14)
    at async Runtime.handleRequestFunc [as handler] (/var/task/index.js:24:16)

VIPS-encoded pyramid TIFF: https://test-alchemist-betawork.s3.us-west-2.amazonaws.com/collections/Palomar/PP18_v01_1936-1937/output_image_vips.ptif Original TIFF: https://test-alchemist-betawork.s3.us-west-2.amazonaws.com/collections/Palomar/PP18_v01_1936-1937/source_image.tif

This occurs with an ImageMagick-encoded pyramid TIFF as well.

I first noticed there was an issue when the right column of tiles were not rendering correctly in my viewer: image

mbklein commented 1 year ago

Interesting. If it were having issues getting the dimensions, nothing would work (up to and including the info.json request. So that doesn't seem to be it. I'm out of the office today, but I'll take a look at this as soon as I can. Thanks for sharing the image files. It'll be a huge help.

mbklein commented 1 year ago

@t4k There was a bug in the code that checks the response size. The image that's erroring is 10409107 bytes, which exceeds the 6MB intrinsic Lambda Function URL maximum. Since you're not using the cloudfront-enabled version of the application that includes the workaround for that limit, it's trying to display an error, but the code was trying to get the size from the wrong place.

I've just deployed v4.3.4 with a fix for the issue – you'll get a more useful error message on that request now. You could switch over to the CloudFront version with the workaround, but I'd hold off for the moment. serverless-iiif v5.0 is currently in review and will be able to deliver responses >6MB directly from the lambda.

t4k commented 1 year ago

Thanks for looking into this! I've been evaluating both setups, standalone & CloudFront, and I'll likely use the CloudFront one for the custom domain capability.

That's great news about the standalone version coming soon!

gb5256 commented 10 months ago

Hi @t4k : it looks like you use the Univerisal-Viewer to display files from the servless-iiif. Would you mind sharing the config you used in calling the viewer? I do not get it to work...