Skip to content

[BUG / WinUI] SkiaSharp is not trimming-safeΒ #3327

@tipa

Description

@tipa

Description

I use SkiaSharp.Views.WinUI 3.119.0 in my WinUI3 app, which I publish using NativeAOT (PublishAot=true) - this implicitly enabled (as requires) full trimming.

Code

I am using SKXamlCanvas and the PaintSurface event handler in several places in my app

Expected Behavior

No warnings, trimming-safe library

Actual Behavior

When building the app in Release mode, I am seeing this warning:

...\.nuget\packages\skiasharp.nativeassets.winui\3.119.0\runtimes\win-x64\lib\net8.0-windows10.0.19041.0\SkiaSharp.Views.WinUI.Native.Projection.dll : warning IL2104: Assembly 'SkiaSharp.Views.WinUI.Native.Projection' produced trim warnings. For more information see https://aka.ms/il2104

When also seting TrimmerSingleWarn=false, I get this more detailed warning breakdown:

ILC : Trim analysis warning IL2026: WinRT.WinrtModule.GetActivationFactory(String): Using member 'WinRT.ComWrappersSupport.GetObjectReferenceForInterface<IActivationFactoryVftbl>(IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This method is not trim-safe, and is only supported for use when not using trimming (or AOT).
ILC : Trim analysis warning IL2026: WinRT.DllModule.GetActivationFactory(String): Using member 'WinRT.ComWrappersSupport.GetObjectReferenceForInterface<IActivationFactoryVftbl>(IntPtr)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This method is not trim-safe, and is only supported for use when not using trimming (or AOT).

While can not reproduce any crashes myself (yet), I am seeing a lot of crash reports that might be related to these warnings.

Version of SkiaSharp

3.119.0 (Current)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions