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.12k stars 518 forks source link

[BUG] Unable to load library 'libSkiaSharp'. #2758

Open jakobeazy opened 2 months ago

jakobeazy commented 2 months ago

Description

using svg.skia on anASP.NET website i get the following error: Exception message: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. Unable to load library 'libSkiaSharp'.

The strange thing is that debugging the code locally, it works, but when deploying it to a server it fails with this error. The versions i an using: Svg.Skia: 1.0.0.13 SkiaSharp: 2.88.6 SkiaSharp.HarfBuzz: 2.88.6 SkiaSharp.NativeAssets.macOS: 2.88.6 SkiaSharp.NativeAssets.Win32: 2.88.6

the project is a .NET Framework 4.7.2 I can't figure out why it can run locally and not remote.

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

Other (Please indicate in the description)

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 Server 2016 v1607

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

jakobeazy commented 2 months ago

This is the complete call stack:

Exception information:

    Exception type: TypeInitializationException
    Exception message: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
   at Svg.Skia.SKSvgSettings..ctor()
   at Svg.Skia.SKSvg..ctor()
   at FaellesKode.Generelt.SvgConverter.SaveAsPng(Stream file, String filePath) in D:\a\1\s\EazyProjectCode\EazyFaellesKode\Generelt\SvgConverter.cs:line 12
   at EazyProject.WebForm236.GemLogo(FileUpload fileupload) in D:\a\1\s\EazyProjectCode\EazyProject\O_admin_faktura_setup.aspx.vb:line 270
   at EazyProject.WebForm236.savelogo_Click(Object sender, EventArgs e) in D:\a\1\s\EazyProjectCode\EazyProject\O_admin_faktura_setup.aspx.vb:line 300
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Unable to load library 'libSkiaSharp'.
   at SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()
mattleibow commented 2 months ago

Is the libSkiaSharp.dll file in the bin folder somewhere? How are you publishing/deploying? Are you able to share a msbuild binlog so I can see why the native binary is not reaching the final output.

If you run the app locally after publishing, does it work?

romansp commented 2 months ago

@mattleibow We're also seeing this error but when trying out 3.0 preview 2.

It's a browser-wasm app on .Net 8. Loads fine on 2.88.7 and HarfBuzzSharp 7.3.0.1. We don't use Blazor but we do include reference to SkiaSharp.Views.Blazor for InterceptGLObject workaround and that's where it fails to load libSkiaSharp.

Haven't tried publishing yet as we're seeing this error with regular dotnet build.

Didn't want to bother early because it's still a preview. But can create a minimal repro if that's already expected to work properly.

jakobeazy commented 2 months ago

hi I was actually using the svg.skia nuget package. Changing to use the svg package solved it for me.

prashants7718 commented 2 weeks ago

Hi @jakobeazy ,

How you have solved this issue, have you changed package and used another package for svg generation

jakobeazy commented 2 weeks ago

Yes, i changed the nuget package from svg.skia to svg.

mattleibow commented 2 weeks ago

@romansp it should be working since there should be no changes for wasm in 3.x Please attach a repro/sample so I can have a look.