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.45k stars 539 forks source link

[BUG] SkiaSharp version 2.88.6 has mosaics when loading images in .NET 7 and the background becomes dark. #2650

Closed e8-HaopuWang closed 9 months ago

e8-HaopuWang commented 12 months ago

Description

SkiaSharp version 2.88.6 has mosaics when loading images in .NET 7 and the background becomes dark.

QQ图片20231018151428

Tested SkiaSharp version 2.88.5 without this problem

Code

The best way to share code for larger projects is a link to a GitHub repository: https://github.com/user/repo/tree/bug-123

But, you can also share a short block of code here:

// some C# code here

You can also share some XAML:

<!-- xaml code here -->

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

2.88.2 (Previous)

IDE / Editor

Visual Studio Code (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

QQ图片20231018151428 QQ图片20231018151733

Relevant Log Output

No response

Code of Conduct

NovaKs68 commented 12 months ago

It seems to be the same bug as in this ticket #2643

IainS1986 commented 11 months ago

I might be seeing a similar issues with PDF documents, all DrawBitmap calls are coming out with corrupted images very similar to what you're seeing.

Going to raise a bug tomorrow once I investigate a bit more. Are you using jpgs by any chance? I have my suspicions it's jpg encoding that's broken (and in my case there's no work around as pdf documents convert internal image data to JPGs)

IainS1986 commented 11 months ago

I could be going down a dead end here but do your images above have alpha channels?

I had a test where I saw some images come out fine, and some corrupt. The corrupt images were all RGB and the fine ones were RGBA.

When I saved one of the fine images to just be RGB, they then also appeared corrupt.

Be good to know if you are using RGB images, and if adding an alpha channel makes any difference.

edobnet commented 10 months ago

How do I update?

e1em3ntoDX commented 10 months ago

Hi,

Multiple commercial products at DevExpress also rely on the functionality offered by the SkiaSharp library and we experience similar issues in apps with our tools deployed to macOS/iOS after upgrading to v2.88.6. Downgrading is a no-go for us due to the vulnerability. Is there any ETA of the fix?

@mattleibow any chance you can look into this and share some details/future plans?

jasoncodematic commented 10 months ago

We are using another library which has a dependency on SkiaSharp and this bug is causing lots of issues. Downgrading is also not a great option for us either. Is there anyone currently looking to fix this?

AndyG74 commented 9 months ago

after downgrade to 2.88.5 it works, but there is a security issue: image

e8-HaopuWang commented 9 months ago

This issue was solved after saving the image in PNG format

AndyG74 commented 9 months ago

ok, thats fine but i need the image as JPEG image

IainS1986 commented 9 months ago

@e8-HaopuWang

This is in no way 'closed'.

e8-HaopuWang commented 9 months ago

@AndyG74 I also use JPEG format in versions below 2.88.6, but saving the image as JPEG in version 2.88.6 will be damaged. After testing, there is no problem in using PNG format.

mattleibow commented 9 months ago

I tested 3.0.1 and the latest main and I think this is an issue in libjpeg-turbo. For now I am reverting to the latest 2.x series.

I had a look at the original security issue and it does not affect the 2.x series because 12-bit jpegs are not actually supported in our build. The 2.x series required the entire library to be either 8-bit or 12-bit, and we use 8-bit. The 3.x series allowed for both simultaneously.

The security issue was just reported for 2.1.90 (which seems like a 2.x series but is actually a 3.0 beta). The current stable version is 2.1.5.1 which is on a separate branch.

I have opened an issue in libjpeg-turbo where I will try and determine the real cause and where this issue should live: https://github.com/libjpeg-turbo/libjpeg-turbo/issues/741

mattleibow commented 9 months ago

Duplicate of https://github.com/mono/SkiaSharp/issues/2643