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

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'length') #108

Closed
jasonliuplanetart opened this issue Feb 3, 2023 · 9 comments

Comments

@jasonliuplanetart
Copy link

jasonliuplanetart commented Feb 3, 2023

Hi ,when i use the https://dev.azure.com/saucecontrol/PhotoSauce/_artifacts/feed/photosauce_ci in linux, version is: 0.14.0-ci223521 I get this error.

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'length')
at PhotoSauce.NativeCodecs.Libpng.PngContainer.generateIccProfile()
at PhotoSauce.NativeCodecs.Libpng.PngContainer.getIccp()
at PhotoSauce.NativeCodecs.Libpng.PngContainer.PhotoSauce.MagicScaler.IIccProfileSource.get_ProfileLength()
at PhotoSauce.MagicScaler.Transforms.MagicTransforms.AddColorProfileReader(PipelineContext ctx)
at PhotoSauce.MagicScaler.MagicImageProcessor.buildPipeline(PipelineContext ctx, Boolean closedPipeline)
at PhotoSauce.MagicScaler.MagicImageProcessor.ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings)

Cloud you please take a look?

@saucecontrol
Copy link
Owner

Can you share the image? That code path is used only for PNGs using the cHRM and/or gAMA tags but no embedded color profile.

@jasonliuplanetart
Copy link
Author

Thank you for your reply, unfortunately, because I got this exception in the log of the production environment, we didn't encounter it when we were debugging locally, so we couldn't get the image.

@saucecontrol
Copy link
Owner

Ah, ok. That code is getting re-worked as part of the BMP implementation since that decoder also needs to generate ICC profiles on the fly. The extra testing around that might reveal something.

@jasonliuplanetart
Copy link
Author

Thanks,I will be looking forward to the release of the new version.

@jasonliuplanetart
Copy link
Author

I also got the following exception information from our production environment, I hope it will be helpful for your test.

System.InvalidOperationException: Libpng decoder failed. bad adaptive filter value
   at PhotoSauce.NativeCodecs.Libpng.PngContainer.throwPngError(ps_png_struct* handle)
   at PhotoSauce.NativeCodecs.Libpng.PngFrame.PngPixelSource.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsDirect(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.loadBuffer(Int32 first, Int32 lines)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.loadBuffer(Int32 first, Int32 lines)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsBuffered(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsDirect(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.CopyPixels(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.PhotoSauce.MagicScaler.IPixelSource.CopyPixels(Rectangle sourceArea, Int32 cbStride, Span`1 buffer)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.writePixels(IPixelSource src, PixelArea area)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.WriteFrame(IPixelSource source, IMetadataSource metadata, Rectangle sourceArea)
System.NullReferenceException: Object reference not set to an instance of an object.
   at PhotoSauce.MagicScaler.Converters.ConverterToLinear`2.Converter3X.PhotoSauce.MagicScaler.Converters.IConversionProcessor.ConvertLine(Byte* istart, Byte* ostart, IntPtr cb)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsDirect(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.CopyPixels(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ColorMatrixTransformInternal.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsBuffered(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsDirect(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.CopyPixels(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.PhotoSauce.MagicScaler.IPixelSource.CopyPixels(Rectangle sourceArea, Int32 cbStride, Span`1 buffer)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.writePixels(IPixelSource src, PixelArea area)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.WriteFrame(IPixelSource source, IMetadataSource metadata, Rectangle sourceArea)
   at PhotoSauce.MagicScaler.MagicImageProcessor.WriteOutput(PipelineContext ctx, Stream ostm)
   at PhotoSauce.MagicScaler.MagicImageProcessor.ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings)
System.InvalidOperationException: Libpng encoder failed. Write failed.
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.checkResult(Int32 res)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.writePixels(IPixelSource src, PixelArea area)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.WriteFrame(IPixelSource source, IMetadataSource metadata, Rectangle sourceArea)
   at PhotoSauce.MagicScaler.MagicImageProcessor.WriteOutput(PipelineContext ctx, Stream ostm)
   at PhotoSauce.MagicScaler.MagicImageProcessor.ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings)
System.InvalidOperationException: Libpng decoder failed. Not enough image data
   at PhotoSauce.NativeCodecs.Libpng.PngContainer.throwPngError(ps_png_struct* handle)
   at PhotoSauce.NativeCodecs.Libpng.PngFrame.PngPixelSource.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsDirect(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.loadBuffer(Int32 first, Int32 lines)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.CopyPixels(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ColorMatrixTransformInternal.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.loadBuffer(Int32 first, Int32 lines)
   at PhotoSauce.MagicScaler.Transforms.ConvolutionTransform`3.CopyPixelsInternal(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsBuffered(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.Transforms.ConversionTransform.copyPixelsDirect(PixelArea& prc, Int32 cbStride, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.CopyPixels(PixelArea& prc, Int32 cbStride, Int32 cbBufferSize, Byte* pbBuffer)
   at PhotoSauce.MagicScaler.PixelSource.PhotoSauce.MagicScaler.IPixelSource.CopyPixels(Rectangle sourceArea, Int32 cbStride, Span`1 buffer)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.writePixels(IPixelSource src, PixelArea area)
   at PhotoSauce.NativeCodecs.Libpng.PngEncoder.WriteFrame(IPixelSource source, IMetadataSource metadata, Rectangle sourceArea)
   at PhotoSauce.MagicScaler.MagicImageProcessor.WriteOutput(PipelineContext ctx, Stream ostm)
   at PhotoSauce.MagicScaler.MagicImageProcessor.ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings)

@jasonliuplanetart
Copy link
Author

I noticed that you released a new version on azure nuget on March 1st. The version we are using is still last year's version. Can this update fix the above issues?

@saucecontrol
Copy link
Owner

The new packages are just updates of the native libraries, which do have some small fixes but don't look to be related to any of the exceptions you've shared. Some of those appear to be usage issues, so without a reproducible test case, there won't be anything I can do about them.

@saucecontrol
Copy link
Owner

I just had another look through these exceptions, and it looks like they're the same as reported in #140

There's a new set of packages on the CI feed that should fix all of the decoder exceptions. I still have no clue on the one encoder exception you included, but I have improved handling of Stream-related exceptions, which I believe should be the only failures possible on write. Those are now properly re-thrown Linux.

@jasonliuplanetart
Copy link
Author

Sorry for the delayed response. After upgrading to the latest version of the package, we not see this exception in the production environment. Thank you for your help. I will close 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

2 participants