SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG]I cannot draw a paint which has a custom SKSL shader, SEHException was thrown

Open martinrhan opened this issue 8 months ago • 1 comments

Description

I have a simple console application which create a bitmap and a canvas, then draw using a paint made from custom sksl shader. However, when canvas.DrawPaint(paint) is called, SEHException is thrown. The error code of is -2147467259, which is 0x80004005. In Common HRESULT Values, it's E_FAIL, Unspecified failure. I have no idea what's happening. The SkiaSharp version is 2.88.8. There's no last known version that make it work.

Code

Simply create a console application with top level statement and add package reference to SkiaSharp. In Program.cs write

using SkiaSharp;

string sksl = """
                    half4 main(float2 fragCoord) { 
                        return half4(0,0,0,1);
                    }
                    """;
string error;
SKRuntimeEffect runtimeEffect = SKRuntimeEffect.Create(sksl, out error);
SKShader shader = runtimeEffect.ToShader(true);
SKPaint paint = new SKPaint() {
    Shader = shader,
};


int width = 1024;
int height = 1024;

SKImageInfo imageInfo = new SKImageInfo(width, height, SKColorType.Rgba8888);
SKBitmap bitmap = new SKBitmap(imageInfo);
SKCanvas canvas = new SKCanvas(bitmap);
canvas.DrawPaint(paint); //SEHException thrown here

Expected Behavior

I should just draw fill the canvas by black color.

Actual Behavior

SEH exception with error code -2147467259 thrown.

Version of SkiaSharp

2.88.8

Last Known Good Version of SkiaSharp

N/A

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows 11

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

martinrhan avatar Jun 20 '24 08:06 martinrhan