Closed Poker-sang closed 7 months ago
There isn’t enough here to reproduce a potential issue I’m afraid. We’d need a reduced sample running within an application with an image known to trigger the exception.
I am sorry but this issue does not always happen. I am trying to find a way to reproduce the problem consistently.
Looks like AsStreamForRead()
accidentally makes Stream.Position
negative sometimes. It's not a bug from ImageSharp actually. Should we check Stream.Position
positive in Image.Load
to avoid this, and better help users locate bugs?
In the years I’ve been developing the library, I’ve never seen a negative stream position before.
Me neither. However it actually happened in my screenshot.
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.1.1
Other ImageSharp packages and versions
No
Environment (Operating system, version and so on)
Windows 11 (22631.2861)
.NET Framework version
8.0
Description
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.IO.BufferedStream.set_Position(Int64 value) at SixLabors.ImageSharp.Image.InternalDetectFormat(Configuration configuration, Stream stream) at SixLabors.ImageSharp.Image.DiscoverDecoder(DecoderOptions options, Stream stream) at SixLabors.ImageSharp.Image.DecodeAsync[TPixel](DecoderOptions options, Stream stream, CancellationToken cancellationToken) at SixLabors.ImageSharp.Image.<>c__DisplayClass86_0`1.b0(Stream s, CancellationToken ct)
at SixLabors.ImageSharp.Image.d 88`1.MoveNext()
at Pixeval.Util.IO.IoHelper.d__39.MoveNext() at C:\WorkSpace\Pixeval\src\Pixeval\Util\IO\IOHelper.Imaging.cs: Line 187
Steps to Reproduce
imageStream
isWindows.Storage.Streams.IRandomAccessStream
The Exception is not always thrown.
Images
No response