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.54k stars 542 forks source link

[BUG] .NET9 SkiaSharp.Views.Blazor my app won't start #3068

Open Frostchi opened 1 week ago

Frostchi commented 1 week ago

Description

After upgrading my previously working .NET 8 app to .NET 9 using Blazor WASM, it fails to run in both Debug/Release builds.

Code

    <div class="canvas-wrapper">
        <SkiaSharp.Views.Blazor.SKCanvasView OnPaintSurface="OnPaintSurface" class="skia-canvas" EnableRenderLoop="true" />
    </div>

Expected Behavior

App should start.

Actual Behavior

App fails to start due to unhandled exception:

System.DllNotFoundException: libSkiaSharp at SkiaSharp.SKData..cctor()

The page loading progress bar stays stuck at 100% and my Page won't load at all.

Version of SkiaSharp

2.88.9 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows/Browser

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

similar-issues-ai[bot] commented 1 week ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

Frostchi commented 1 week ago

I also tried 3.118.0-preview.1.2 and had the same issue.

Unhandled Exception:
System.DllNotFoundException: libSkiaSharp
   at SkiaSharp.SKData..cctor()
18779758522 commented 1 week ago

.NET9 I encountered this problem:Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Could not set up parent class, due to: Could not load type of field 'SkiaSharp.Views.Blazor.Internal.JSModuleInterop:moduleTask' (0) due to: Could not resolve type with token 01000039 from typeref (expected class 'Microsoft.JSInterop.IJSUnmarshalledObjectReference' in assembly 'Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 type:Microsoft.JSInterop.IJSUnmarshalledObjectReference member:(null) assembly:SkiaSharp.Views.Blazor.dll type:JSModuleInterop member:(null) System.TypeLoadException: Could not set up parent class, due to: Could not load type of field 'SkiaSharp.Views.Blazor.Internal.JSModuleInterop:moduleTask' (0) due to: Could not resolve type with token 01000039 from typeref (expected class 'Microsoft.JSInterop.IJSUnmarshalledObjectReference' in assembly 'Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60') assembly:Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 type:Microsoft.JSInterop.IJSUnmarshalledObjectReference member:(null) assembly:SkiaSharp.Views.Blazor.dll type:JSModuleInterop member:(null) at SkiaSharp.Views.Blazor.SKCanvasView.OnAfterRenderAsync(Boolean firstRender)

capdiem commented 1 week ago

I also have this issue using 3.116.0-preview.6.1

var imageInfo = new SKImageInfo(...)
System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
 ---> System.DllNotFoundException: libSkiaSharp
   at SkiaSharp.SKImageInfo..cctor()
TRSkillman commented 4 days ago

This is quite a serious issue for us too as we couldn't get 2.88.9 or 3.118.0-preview.1.2 working in .NET 9 using Blazor WASM.
We had to roll-back to .NET 8.
I hope this gets fixed soon!

jahnotto commented 2 days ago

I don't know if it's related, but fo-dicom has some issues with loading plugins because .NET 9 has issues figuring out which architecture the CPU is. I don't know any more details -- but perhaps that's what's happening here as well as the dll can't be loaded.

It would be good to be able to upgrade to .NET 9 for sure.

LucaCris commented 1 day ago

A free sunday morning to upgrade my Blazor/SkiaSharp project to NET9 and... DllNotFoundException: libSkiaSharp 💩

thomasstockermc commented 18 hours ago

This pull request should fix this. The underlying issue is a Bug in the .NET 9 Framework.

https://github.com/mono/SkiaSharp/pull/3064