4

I'm building a Xamarin app, using ImageSharp for image manipulation.

I've noticed that the ImageSharp operations are very slow in the emulator and ridiculously slow when deployed to a physical device (Galaxy Note 8).

Things that are way slow:

// Load image (very slow)
var image = SixLabors.ImageSharp.Image.Load(stream);   

// Manipulate image (equally slow)
image.Mutate(i => i.Resize(new ResizeOptions
                    {
                        Mode = ResizeMode.Pad,
                        Position = AnchorPositionMode.Top,
                        Size = new SixLabors.Primitives.Size(600,400))
                    }));

Note that the image loads fine (albeit slowly) and the resizing works, but it's very slow (30-60 seconds).

Executing the same code from a .NET Core console program reduces the load and manipulation times to about 1-2 seconds.

With the debugger attached, I see a flood of these when ImageSharp operations are running:

GC_MINOR: (Nursery full)

I'm not really sure how to troubleshoot this, is my only option to clone the ImageSharp repo and debug using a custom build?

Edit: Not sure if this may be related to this issue?

Edit #2: I gave up on ImageSharp and also tested OpenCV to no particular avail and then settled on SkiaSharp which works great right out of the box.

Ted Nyberg
  • 7,001
  • 7
  • 41
  • 72
  • 3
    There currently is no SIMD support via Xamarin, you would need a native C/C++/Java implementation : https://stackoverflow.com/questions/50433924/xamarin-no-hardware-acceleration-when-deployin-to-device/50434306?s=1|40.4283#50434306 – SushiHangover Sep 27 '18 at 13:32
  • 1
    Ahh, that explains it. :/ Thanks! – Ted Nyberg Sep 27 '18 at 19:40
  • 3
    Thanks for the heads up on SkiaSharp. I'm also using Imagesharp in a Blazor-app and it's unusably slow. – Jesper Aug 06 '19 at 16:30
  • 2
    Just found out that SkiaSharp only works in Blazor serverside and not client-side – Jesper Aug 07 '19 at 10:28

0 Answers0