mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.5k stars 538 forks source link

[BUG] Unable to allocate pixels for the bitmap in Azure App service #2136

Open DharanitharanA opened 2 years ago

DharanitharanA commented 2 years ago

Description

"Unable to allocate pixels for the bitmap in Azure App service" exception throws, while decoding specific image multiple times using SkiaSharp library in Azure App service

Code

            ```
            FileStream fileStream = new FileStream(Environment.CurrentDirectory + "/wwwroot/images/image126.png", FileMode.Open);
            MemoryStream imageStream = new MemoryStream();
            fileStream.CopyTo(imageStream);
            fileStream.Dispose();
            for (int i = 0; i <= 20; i++)
            {
                imageStream.Position = 0;
                SkiaSharp.SKData skData = SkiaSharp.SKData.Create(imageStream);
                SkiaSharp.SKBitmap.Decode(skData);
                skData.Dispose();
            }
            ```

Expected Behavior

Image should be decoded properly

Actual Behavior

Throws Unable to allocate pixels for the bitmap exception in Azure App service

Basic Information

StackTrace:

System.Exception: Unable to allocate pixels for the bitmap. 
at SkiaSharp.SKBitmap.Decode(SKCodec codec, SKImageInfo bitmapInfo) 
at SkiaSharp.SKBitmap.Decode(SKCodec codec) 
at SkiaSharp.SKBitmap.Decode(SKData data) 
at AzureAppSeviceLinux.Controllers.HomeController.DecodeImage(String button) 

Note: This code works properly in windows

Reproduction Link

Please deploy the below sample in Azure app service to replicate the issue,

AzureAppSeviceLinux-543651564.zip

Ramaraj-Marimuthu commented 2 years ago

Hi Team,

Any update in this. It would be very helpful for us.

Thanks.

Ramaraj-Marimuthu commented 2 years ago

Hi Team,

Any help will be appreciate.

Thanks.

DharanitharanA commented 2 years ago

Hi Team,

Any update in this. It would be very helpful for us.

Thanks.

mattleibow commented 2 years ago

What is the image dimensions? Usually that error means you have exceeded the int.maxvalue somehow.

DharanitharanA commented 2 years ago

Hi @mattleibow,

image126
Ramaraj-Marimuthu commented 2 years ago

Hi @mattleibow,

Any update on this. Still i'm stucked in this issue.

Thanks in advance.

DharanitharanA commented 1 year ago

Hi @mattleibow,

As we have let our product to use in live, we need to resolve this issue immediately. So, your suggestions will be very helpful for us.

Thanks.

SuriyaBalamurugan commented 1 year ago

Hi @mattleibow,

Any update on this.

Thanks.

robbendavid commented 1 year ago

We have the same issue. Any help or workaround would me much appreciated!

Aschonn commented 1 year ago

Any solutions?

m7md7sien commented 1 year ago

I faced the same issue on Windows Azure VM, and it caused "Breakpoint Has Been Reached" Error. Any insights on the root cause of this? Is it related to memory issues?