Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
Frostchi opened this issue Nov 15, 2024 · 26 comments
Closed
1 task done

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

Frostchi opened this issue Nov 15, 2024 · 26 comments
Labels
area/SkiaSharp.Views.Blazor Issues relating to the views for ASP.NET Blazor. os/WASM Issues running on WebAssembly (ASP.NET Blazor or Uno Platform) type/bug

Comments

@Frostchi
Copy link

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

  • I agree to follow this project's Code of Conduct
Copy link

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
Copy link
Author

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

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

@18779758522
Copy link

.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
Copy link

capdiem commented Nov 18, 2024

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
Copy link

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
Copy link

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
Copy link

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

@thomasstockermc
Copy link

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

#3064

@mattleibow
Copy link
Contributor

This may be fixed with #3064

Can you try the nightly on the preview feed: 3.118.0-nightly.27

https://aka.ms/skiasharp-eap/index.json

Let me know if this fixes it and I will push out the 3.x release.

@capdiem
Copy link

capdiem commented Nov 27, 2024

@mattleibow 3.118.0-nightly.27 is working, thanks! When will version 3.x be released?

@mattleibow
Copy link
Contributor

I am hoping that I can release this week.

@mattleibow mattleibow added os/WASM Issues running on WebAssembly (ASP.NET Blazor or Uno Platform) area/SkiaSharp.Views.Blazor Issues relating to the views for ASP.NET Blazor. labels Nov 27, 2024
@jahnotto
Copy link

I am hoping that I can release this week.

Awesome. Thank you!

@manu-aesim
Copy link

@mattleibow 3.118.0-nightly.27 is working, thanks! When will version 3.x be released?

I had a similar issue, and this nightly build resolved it for me as well. Thanks!

@18779758522
Copy link

18779758522 commented Nov 29, 2024

This may be fixed with #3064

Can you try the nightly on the preview feed: 3.118.0-nightly.27

https://aka.ms/skiasharp-eap/index.json

Let me know if this fixes it and I will push out the 3.x release.

Using version 3.118.0-nightly.27, an issue was found. If there is a BasePath path, the SKHtmlCanvas.js file will not be loaded.Error 404 is reported。This issue does not occur in version 2.88.9
Is it related to here? "/" + moduleUrl

public JSModuleInterop(IJSRuntime js, string moduleName, string moduleUrl)
		{
                       #if NET7_0_OR_GREATER
			moduleTask = JSHost.ImportAsync(moduleName, "/" + moduleUrl);
                        #else
			if (js is not IJSInProcessRuntime)
				throw new NotSupportedException("SkiaSharp currently only works on Web Assembly.");

			moduleTask = js.InvokeAsync<JSObject>("import", moduleUrl).AsTask();
                        #endif
		}

@18779758522
Copy link

a84a031f-8bce-4d18-a0d4-cc72fafa9e9e
a08b628a-037b-45fc-8427-9f175864d834

@mattleibow
Copy link
Contributor

@18779758522 can you add a sample so I can investigate?

@mattleibow
Copy link
Contributor

@18779758522 this PR should fix it for you: #3092

@mattleibow
Copy link
Contributor

Closing this as all the issues mentioned in here have been fixed by one PR or another. Hopefully once CI is finished I can release. It has been a long time.

@github-project-automation github-project-automation bot moved this from Ready For Work to Done in SkiaSharp Backlog Dec 2, 2024
@18779758522
Copy link

@18779758522 this PR should fix it for you: #3092

Is there a release preview? I'd love to test it out

@mattleibow
Copy link
Contributor

This should be on nuget.org now

@harveytriana
Copy link

Update to 3.118.0-preview.2.3

Start Without Debbuging: OK!
Start With Debbuging: No canvas element was provided.

Minimal sample: https://github.com/harveytriana/BlazorMinimalSS9

@mattleibow
Copy link
Contributor

@harveytriana thanks for letting me know, can you try 3.116.0?

Also, please open a new issue with your findings. Thanks!

@LucaCris
Copy link

LucaCris commented Dec 8, 2024

I can confirm the "random appearing" canvas.

@markushaslinger
Copy link

I got No canvas element was provided after upgrading until I cleared the browser cache (in Firefox the one that does not go away with Ctrl+F5, but has to be deleted in about:preferences#privacy > Clear Data) and it worked since then, debug or not.
If you guys can repro it then there must be another error somewhere, but maybe this helps track it down.

@mattleibow
Copy link
Contributor

Hmmm, I wonder if I need to make the js files not cached. I thought it was, but I guess not.

@xela-trawets
Copy link

xela-trawets commented Jan 7, 2025

In ScottPlot
under dotnet 8, ScottPlot using <PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.2.3" />
@harveytriana HarveyTriana's observation holds in the blazor demo code - also mouse events are disconnected- interop maybe?
https://github.com/ScottPlot/ScottPlot/issues/4584

On dotnet 9, the (scottplot) canvas shows up in both release and debug,
Also in both dotnet 8 and dotnet 9 the mouse interaction seems to be disconnected, but that maybe "old" blazor js interop.

Update to 3.118.0-preview.2.3
Start Without Debbuging: OK! Start With Debbuging: No canvas element was provided.
Minimal sample: https://github.com/harveytriana/BlazorMinimalSS9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/SkiaSharp.Views.Blazor Issues relating to the views for ASP.NET Blazor. os/WASM Issues running on WebAssembly (ASP.NET Blazor or Uno Platform) type/bug
Projects
Status: Done
Development

No branches or pull requests