You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingMicrosoft.Azure.Functions.Worker.Builder;usingMicrosoft.Extensions.Hosting;varbuilder=FunctionsApplication.CreateBuilder(args);builder.ConfigureFunctionsWebApplication();// Application Insights isn't enabled by default. See https://aka.ms/AAt8mw4.// builder.Services// .AddApplicationInsightsTelemetryWorkerService()// .ConfigureFunctionsApplicationInsights();builder.Build().Run();
function
usingSystem;usingMicrosoft.Azure.Functions.Worker;usingMicrosoft.Extensions.Logging;usingSkiaSharp;usingSystem.IO;namespaceSkiaTest{publicclassSkiaTest{privatereadonlyILogger_logger;publicSkiaTest(ILoggerFactoryloggerFactory){_logger=loggerFactory.CreateLogger<SkiaTest>();}[Function("SkiaTest")]publicvoidRun([TimerTrigger("0 */5 * * * *",RunOnStartup=true)]TimerInfomyTimer){varpath=Path.GetTempPath();varoutputFile=Path.Combine(path,"report.pdf");_logger.LogInformation("Writing to file...");// Create a PDF documentvarmetadata=newSKDocumentPdfMetadata{Author="Your Name",Title="Sample PDF Report",Creation=DateTime.Now,Modified=DateTime.Now};using(varstream=File.Create(outputFile)){vardocument=SKDocument.CreatePdf(stream,metadata);using(varcanvas=document.BeginPage(612,792))// A4 size in points{canvas.Clear(SKColors.White);using(varpaint=newSKPaint{Color=SKColors.Black,TextSize=24}){canvas.DrawText("Hello, World!",100,100,paint);}}document.EndPage();document.Close();}_logger.LogInformation($"File written to: {outputFile}");if(myTimer.ScheduleStatusis not null){_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");}}}}
Expected Behavior
a report named "report.pdf" be created in the temp directory.
Actual Behavior
Result: Function 'SkiaTest', Invocation id '0245d8d8-2e4c-4d91-8363-5828a29c182a': An exception was thrown by the invocation.
Exception: System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedWStream' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libSkiaSharp.so: cannot open shared object file: No such file or directory
/home/site/wwwroot/libSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/home/site/wwwroot/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libSkiaSharp: cannot open shared object file: No such file or directory
/home/site/wwwroot/libSkiaSharp: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/liblibSkiaSharp: cannot open shared object file: No such file or directory
/home/site/wwwroot/liblibSkiaSharp: cannot open shared object file: No such file or directory
at SkiaSharp.SkiaApi.sk_managedwstream_set_procs(SKManagedWStreamDelegates procs)
at SkiaSharp.SkiaApi.sk_managedwstream_set_procs(SKManagedWStreamDelegates procs)
at SkiaSharp.SKAbstractManagedWStream..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKAbstractManagedWStream..ctor(Boolean owns)
at SkiaSharp.SKManagedWStream..ctor(Stream managedStream, Boolean disposeManagedStream, Boolean owns)
at SkiaSharp.SKManagedWStream..ctor(Stream managedStream, Boolean disposeManagedStream)
at SkiaSharp.SKManagedWStream..ctor(Stream managedStream)
at SkiaSharp.SKDocument.CreatePdf(Stream stream, SKDocumentPdfMetadata metadata)
at SkiaTest.SkiaTest.Run(TimerInfo myTimer) in D:\source\FunctionAppLatest\FunctionApp1\SkiaTest.cs:line 36
at SkiaTest.DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\source\FunctionAppLatest\FunctionApp1\obj\Release\net9.0\linux-x64\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator\GeneratedFunctionExecutor.g.cs:line 37
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 38
at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 96
Stack: at SkiaSharp.SKAbstractManagedWStream..ctor(Boolean owns)
at SkiaSharp.SKManagedWStream..ctor(Stream managedStream, Boolean disposeManagedStream, Boolean owns)
at SkiaSharp.SKManagedWStream..ctor(Stream managedStream, Boolean disposeManagedStream)
at SkiaSharp.SKManagedWStream..ctor(Stream managedStream)
at SkiaSharp.SKDocument.CreatePdf(Stream stream, SKDocumentPdfMetadata metadata)
at SkiaTest.SkiaTest.Run(TimerInfo myTimer) in D:\source\FunctionAppLatest\FunctionApp1\SkiaTest.cs:line 36
at SkiaTest.DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\source\FunctionAppLatest\FunctionApp1\obj\Release\net9.0\linux-x64\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator\GeneratedFunctionExecutor.g.cs:line 37
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 38
at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 96
Version of SkiaSharp
3.116.0 (Current)
Last Known Good Version of SkiaSharp
2.88.7 (Deprecated)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Linux
Platform / Operating System Version
Azure Linux Function app - .NET 9.0
Please note this appears to be a .NET 9.0 issue.
SkiaSharp 2.88.7 works fine on .NET 8.0
SkiaSharp 2.887 + fails on .NET 9.0
Devices
Not applicable
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
HmichaelG
changed the title
[BUG] SkiaSharp v3.116.0 System.TypeInitializationException when executing as Azure Linux Function
[BUG] SkiaSharp v3.116.0 System.TypeInitializationException when executing as Azure Linux Function (.NET 9.0 - isolated)
Dec 5, 2024
Description
The following code executes successfully...
but fails when executed as an Azure Linux Function app (.NET 9.0 - isolated).
Code
The test project: https://github.com/HmichaelG/SkiaTest
program.cs
function
Expected Behavior
a report named "report.pdf" be created in the temp directory.
Actual Behavior
Version of SkiaSharp
3.116.0 (Current)
Last Known Good Version of SkiaSharp
2.88.7 (Deprecated)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Linux
Platform / Operating System Version
Azure Linux Function app - .NET 9.0
Please note this appears to be a .NET 9.0 issue.
SkiaSharp 2.88.7 works fine on .NET 8.0
SkiaSharp 2.887 + fails on .NET 9.0
Devices
Not applicable
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: