SkiaSharp
SkiaSharp copied to clipboard
[BUG] AoT application is crashing when reflection is disabled.
Description
The error ocurrs at instantiate the SkPaint using the latest version (3.116.1)
I remember the previous version (2.88.9) working at some point. But trying again reults on different error.
The version of the native libSkiaSharp library (116.0) is incompatible with this version of SkiaSharp. Supported versions of the native libSkiaSharp library are in the range [88.1, 89.0)
Code
using SkiaSharp;
var paint = new SKPaint();
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<PublishAot>true</PublishAot>
<IlcDisableReflection>true</IlcDisableReflection>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>
</Project>
Unhandled exception. 0x7ff76e3a5180: TypeInitialization_Type_NoTypeAvailable
---> 0x7ff76e3a5180: TypeInitialization_Type_NoTypeAvailable
---> 0x7ff76e3a4c58: Reflection_Disabled
at System.RuntimeType.InitializeRuntimeTypeInfoHandle() + 0x2c
at System.Array.InternalCreate(RuntimeType, Int32, Int32*, Int32*) + 0x180
at System.Array.CreateInstance(Type, Int32) + 0x27
at System.RuntimeType.GetEnumValues() + 0x74
at SkiaSharp.SKBlender..cctor() + 0x1f
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0xba
Exception_EndOfInnerExceptionStack
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x13d
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0xd
at SkiaSharp.SKObject..cctor() + 0x7a
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0xba
Exception_EndOfInnerExceptionStack
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x13d
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0xd
at SkiaSharp.SKPaint..ctor() + 0x68
at Program.<Main>$(String[]) + 0x18
Expected Behavior
No crash when reflection disabled
Actual Behavior
AoT application crashes when reflection disabled
Version of SkiaSharp
3.116.0 (Current)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Visual Studio Code (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
Windows 11
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
I'm seeing the same thing building for .NET on Linux. I believe it is this issue which was closed prematurely, imho #3117