This repository provides a minimal, working WinUI 3 starter app that uses a hardware-accelerated SkiaSharp canvas (SKSwapChainPanel).
The goal is to create a self-contained application suitable for distribution on platforms like Steam, which do not support the standard MSIX packaging format. This repository represents the successful result of that research.
The application runs a simple demo of a smiley face whose color animates through the hue spectrum, demonstrating a constantly running GPU-accelerated render loop.
Screen.Recording.2025-07-13.202812.mp4
Running SkiaSharp's hardware-accelerated controls in an unpackaged WinUI 3 app currently fails due to a bug in the official ANGLE graphics libraries (libEGL.dll and libGLESv2.dll) provided by the SkiaSharp NuGet packages.
Based on deep analysis from the community (see SkiaSharp GitHub Issue #2968), the root cause is that for an unpackaged app to function, the two main ANGLE libraries must be compiled with conflicting build flags:
libEGL.dllmust be compiled withangle_is_winappsdk=false.libGLESv2.dllmust be compiled withangle_is_winappsdk=true.
The official libraries are built with a single configuration, making them incompatible.
The only reliable solution is to manually build ANGLE from source using a split-configuration process. This repository automates this complex workaround:
- A PowerShell script (
scripts/build-native.ps1) uses Google'sdepot_toolsto perform two separate builds of ANGLE, producing a compatiblelibEGL.dllandlibGLESv2.dll. - The C# project (
SmileyApp.csproj) is configured with MSBuild targets that automatically run this script and copy the custom-built libraries into the final application directory.
This is a significant workaround that ideally should not be necessary. The hope is that the ANGLE or SkiaSharp build process can be fixed to produce libraries that work out-of-the-box, making this repository obsolete.
- Visual Studio 2022: You must have the "Desktop development with C++" workload installed.
- .NET 9 SDK: (or the version that the script downloads as 'winappsdk_headers' - currently set correctly in this csproj. ).
-
Open the Correct Terminal: You must use the Developer Powershell for VS . This is critical as it sets up the necessary environment variables for the C++ compiler. You can find it in your Start Menu.
-
Navigate to the Solution Directory: In the Developer Command Prompt,
cdto the root folder of this repository (where the.slnfile is). -
Run the Application: Execute the following command:
dotnet run -c Debug --project .\SmileyApp\SmileyApp.csproj
The very first time you build the project, it will trigger the build-native.ps1 script. This script will download Google's depot_tools and the entire ANGLE source code, then compile it twice. This is a lengthy process that can take 15-30 minutes and download GBs of data.
This only happens once. Subsequent builds will be fast, as the script will detect that the final libraries already exist in the artifacts folder.
If the build script fails during the gclient sync step with a RESOURCE_EXHAUSTED or 429 error, it means Google's servers have temporarily rate-limited your connection.
- Solution: Wait 15-30 minutes, then run the
dotnet runcommand again without deleting any files. The script will resume where it left off.
SmileyApp.sln: The Visual Studio solution file, configured forx64builds only.SmileyApp/SmileyApp.csproj: The C# project file. Contains the MSBuild targets that automate the native build and file copying.SmileyApp/Program.cs: The application entry point. It contains the minimal code to create a WinUI 3 window and host theSKSwapChainPanel.scripts/build-native.ps1: The PowerShell script responsible for the complex, two-stage build of the ANGLE libraries.artifacts/: (Generated by the script) This folder contains the final, correctly-builtlibEGL.dllandlibGLESv2.dll. It is ignored by git.angle_build_workspace/: (Generated by the script) This folder contains the ANGLE source code and build tools. It is ignored by git.