Skip to content

bytesandwich/unpackagedSkiasharpAngle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Working Unpackaged WinUI 3 + SkiaSharp App

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

The Core Problem & The Workaround

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.dll must be compiled with angle_is_winappsdk=false.
  • libGLESv2.dll must be compiled with angle_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:

  1. A PowerShell script (scripts/build-native.ps1) uses Google's depot_tools to perform two separate builds of ANGLE, producing a compatible libEGL.dll and libGLESv2.dll.
  2. 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.


How to Build and Run

Prerequisites

  1. Visual Studio 2022: You must have the "Desktop development with C++" workload installed.
  2. .NET 9 SDK: (or the version that the script downloads as 'winappsdk_headers' - currently set correctly in this csproj. ).

Build and Run Instructions

  1. 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.

  2. Navigate to the Solution Directory: In the Developer Command Prompt, cd to the root folder of this repository (where the .sln file is).

  3. Run the Application: Execute the following command:

    dotnet run -c Debug --project .\SmileyApp\SmileyApp.csproj

Important Note on the First Build

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.

Troubleshooting the Native Build

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 run command again without deleting any files. The script will resume where it left off.

Project File Descriptions

  • SmileyApp.sln: The Visual Studio solution file, configured for x64 builds 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 the SKSwapChainPanel.
  • 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-built libEGL.dll and libGLESv2.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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published