Bug 55613 - SKBitmap.Decode (SkiaSharp 1.57.0) fails for some type of images
Summary: SKBitmap.Decode (SkiaSharp 1.57.0) fails for some type of images
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2017-04-26 08:58 UTC by Andreas
Modified: 2017-06-26 20:18 UTC (History)
2 users (show)

Tags: bb
Is this bug a regression?: ---
Last known good build:


Attachments
Not Working (4.84 MB, image/jpeg)
2017-04-26 08:58 UTC, Andreas
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED UPSTREAM

Description Andreas 2017-04-26 08:58:06 UTC
Created attachment 21792 [details]
Not Working

Not sure if this is the Place to file this bug, but I give it a shot!
I'm using Montemagnos CrossMedia plugin to pick a photo from my camera roll.
Then I create a byte[] of the photo and use that byte[] to breate a SKBitmap.

var mf = await CrossMedia.Current.PickPhotoAsync();
byte[] bytes;
var s = new MemoryStream()
mf.GetStream().CopyTo(s);
mf.Dispose();
bytes = s.ToArray();
var bm = SKBitmap.Decode(bytes);

This worked perfect in version 1.56.x of SkiaSharp. (On both Android, UWP and iOS).
After updating to 1.57.0 this still works for iOS and UWP.

However, for some images, on Android, it fails with the dump shown below

This seems to be VERY dependent of witch photo I use. I took a photo with my Samsung S7. Worked fine!
Made the photo a bit brighter (in the phone) and saved a copy. The copy DOES NOT work.
Both photos work if I downgrade SkiaSharp to 1.56.x


----
Stacktrace:
at <unknown> <0xffffffff>
04-26 08:30:18.756 E/mono-rt (28205):   at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_codec_get_pixels (intptr,SkiaSharp.SKImageInfo&,intptr,intptr,SkiaSharp.SKCodecOptionsInternal&,intptr,int&) <0x00007>
04-26 08:30:18.756 E/mono-rt (28205):   at SkiaSharp.SKCodec.GetPixels (SkiaSharp.SKImageInfo,intptr,int,SkiaSharp.SKCodecOptions,intptr,int&) [0x00097] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at SkiaSharp.SKCodec.GetPixels (SkiaSharp.SKImageInfo,intptr,int,SkiaSharp.SKCodecOptions,SkiaSharp.SKColorTable,int&) [0x00020] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at SkiaSharp.SKCodec.GetPixels (SkiaSharp.SKImageInfo,intptr,SkiaSharp.SKColorTable,int&) [0x00012] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at SkiaSharp.SKBitmap.Decode (SkiaSharp.SKCodec,SkiaSharp.SKImageInfo) [0x0003d] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at SkiaSharp.SKBitmap.Decode (SkiaSharp.SKCodec) [0x00018] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at SkiaSharp.SKBitmap.Decode (SkiaSharp.SKStream) [0x00026] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at SkiaSharp.SKBitmap.Decode (byte[]) [0x00017] in <f4b7f147247f4a9789d4dbaebc5c8b24>:0
04-26 08:30:18.757 E/mono-rt (28205):   at Sketching.Renderer.BackgroundImageRenderer.ResizeBitmap
Comment 1 Andreas 2017-04-26 09:12:23 UTC
Perhaps this should have been in the SkiaSharp issue tracker. Added it there
https://github.com/mono/SkiaSharp/issues/280

Close this, if it seems irrelevant here
Comment 2 Greg Munn 2017-05-15 18:42:13 UTC
From the addin point of view, I think not relevant. But only someone on the runtime side of things can answer more accurately.
Comment 3 Mark McLemore 2017-06-26 19:20:08 UTC
This appears to be a SkiaSharp issue, which is being addressed in https://github.com/mono/SkiaSharp/issues/280, so closing 55613 as a duplicate (please reopen if you feel that this is a Xamarin.Android issue). Thanks!