SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[FEATURE] Support UWP for SkiaSharp 3.0

Open tipa opened this issue 1 year ago • 11 comments

Is your feature request related to a problem?

I am using UWP and migrating to WinUI3 is not an option (yet)

Describe the solution you would like

I would like to use SkiaSharp 3.0 on UWP but when attempting to use it, I get the following error:

NU1202: Package SkiaSharp.Views 3.0.0-preview.1.8 is not compatible with uap10.0.17763 (UAP,Version=v10.0.17763) / win10-x86-aot. Package SkiaSharp.Views 3.0.0-preview.1.8 supports:
  - net462 (.NETFramework,Version=v4.6.2)
  - net7.0-android33.0 (.NETCoreApp,Version=v7.0)
  - net7.0-ios16.1 (.NETCoreApp,Version=v7.0)
  - net7.0-maccatalyst16.1 (.NETCoreApp,Version=v7.0)
  - net7.0-macos13.0 (.NETCoreApp,Version=v7.0)
  - net7.0-tizen7.0 (.NETCoreApp,Version=v7.0)
  - net7.0-tvos16.1 (.NETCoreApp,Version=v7.0)
  - net7.0-windows10.0.19041 (.NETCoreApp,Version=v7.0)

As announced here, v3.0 should be compartible with .NET Standard 2.0 (which is what UWP is using) so I am not sure if this is a bug

Describe alternatives you have considered

Migrating to WinUI3 is not an option as it has bad performance, unsatisfying bundle size and various other issues. I could also just stay on SkaiSharp 2.x, but I'd prefer to use the "latest and greatest" SkiaSharp version ;)

Additional context

No response

Code of Conduct

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

tipa avatar Feb 07 '24 17:02 tipa

I heard echos of the case where win32 dlls now work on UWP - especially so we can build using Clang.

For now, you could try copying in the view source from the 2.x branch and see if that works. A bit of work, but if that is the case then maybe we can use the win32 dlls from 3.x and then just have a small uwp dll for the views.

mattleibow avatar Feb 08 '24 15:02 mattleibow

I know this is something I have heard from @dotMorten, so I guess I will have to start by reading my old chats and inboxes with all the steps. But, if anyone else has had success, then we might be able to do this easily. I do know the skia codebase is optimized for and supported on Clang. MSVC is a little dodgy in areas as they have slow code paths and sometimes build errors.

mattleibow avatar Feb 08 '24 15:02 mattleibow

Correct we no longer build Skia specifically for uwp but use standard win32 dlls in our uwp apps and they still pass app certification

dotMorten avatar Feb 08 '24 15:02 dotMorten

I was typing steps, but the replies are too fast. Very good news.

mattleibow avatar Feb 08 '24 15:02 mattleibow

So, this just means we need to add the UWP TFM back into the views nuget and we might be safe. Not sure the dotnet CLI can do that... Will be annoying to get set up I am sure, but I could probably build a separate project and then manually pack the UWP dlls...

mattleibow avatar Feb 08 '24 15:02 mattleibow

You just need to put the native libs in the runtimes/win-xXX/native folder and both net6 and UWP will deploy them correctly. The managed api to call into them will be the same too but you might need a uwp specific build of the .net assembly but that's easy to do with multi targeting. Once done build a uwp app using it and run it through the app certification kit just to make sure there are no cert issues with banned api calls

dotMorten avatar Feb 08 '24 15:02 dotMorten

Thanks!

mattleibow avatar Feb 08 '24 16:02 mattleibow

I realize the preview was only published a week ago, but do you guys have a ballpark goal for the 3.0 release? Thanks. And thanks for the great library!

jackbond avatar Feb 13 '24 14:02 jackbond

WinUI3 ... bad performance, unsatisfying bundle size

I agree and the fix for both will be in NativeAOT support and associated work. This doesn't look far off and is being worked on in https://github.com/microsoft/CsWinRT/tree/staging/AOT . If we are lucky we may get both goodies at the same time (usable WinUI3, SkiaSharp 3.0) and this issue will be avoided.

charlesroddie avatar Feb 17 '24 17:02 charlesroddie