question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bitmap.DecodeToWidth() fails in 0.10.11, 0.10.12 and 0.10.13

See original GitHub issue

Describe the bug Fails to load bitmap in 0.10.11, 0.10.12 and 0.10.13. Succeeds in 0.10.10 and earlier.

System.ArgumentNullException: Value cannot be null. (Parameter 'buffer')
   at SkiaSharp.SKManagedStream.OnReadManagedStream(IntPtr buffer, IntPtr size)
   at SkiaSharp.SKManagedStream.OnRead(IntPtr buffer, IntPtr size)
   at SkiaSharp.SKAbstractManagedStream.ReadInternal(IntPtr s, Void* context, Void* buffer, IntPtr size)
   at SkiaSharp.SkiaApi.sk_codec_get_pixels(IntPtr codec, SKImageInfoNative* info, Void* pixels, IntPtr rowBytes, SKCodecOptionsInternal* options)
   at SkiaSharp.SKCodec.GetPixels(SKImageInfo info, IntPtr pixels, Int32 rowBytes, SKCodecOptions options)
   at SkiaSharp.SKCodec.GetPixels(SKImageInfo info, IntPtr pixels)
   at SkiaSharp.SKBitmap.Decode(SKCodec codec, SKImageInfo bitmapInfo)
   at Avalonia.Skia.ImmutableBitmap..ctor(Stream stream, Int32 decodeSize, Boolean horizontal, BitmapInterpolationMode interpolationMode) in /_/src/Skia/Avalonia.Skia/ImmutableBitmap.cs:line 69
   at Avalonia.Skia.PlatformRenderInterface.LoadBitmapToWidth(Stream stream, Int32 width, BitmapInterpolationMode interpolationMode) in /_/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs:line 124
   at Avalonia.Media.Imaging.Bitmap.DecodeToWidth(Stream stream, Int32 width, BitmapInterpolationMode interpolationMode) in /_/src/Avalonia.Visuals/Media/Imaging/Bitmap.cs:line 24

I believe it is due to using SkiaSharp 2.88.0-preview.178 since 0.10.11: https://github.com/mono/SkiaSharp/issues/1752 https://github.com/mono/SkiaSharp/issues/1551

To Reproduce

using (var memoryStream = new MemoryStream(path)) {
    var bitmap = Bitmap.DecodeToWidth(memoryStream, 80); 
}

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 0.10.13

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Gillibaldcommented, May 24, 2022
1reaction
Fusion86commented, Apr 21, 2022

Would it be possible to implement the workaround suggested by @AndersMad in https://github.com/mono/SkiaSharp/issues/1551#issuecomment-756685252? Because that seems to solve the issue, and it doesn’t look like SkiaSharp will fix the underlying bug anytime soon. I didn’t create a PR because I don’t know what (performance) implications this change might have.

Example: https://github.com/Fusion86/Avalonia/commit/fa970142922e9a08c7aa26ce5446deabeab657cb

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found