Skip to content

Add Ganesh and Graphite native and MAUI views - #5329

Draft
mattleibow wants to merge 19 commits into
mattleibow-graphite-interop-bindingsfrom
mattleibow-maui-gpu-views
Draft

mattleibow wants to merge 19 commits into
mattleibow-graphite-interop-bindingsfrom
mattleibow-maui-gpu-views

Conversation

@mattleibow

@mattleibow mattleibow commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add engine-named native containers and MAUI controls: SKGaneshView and SKGraphiteView. Applications can share drawing code through SKPaintSurfaceEventArgs without losing typed GRContext or SKGraphiteContext access. Presentation backends remain private implementation details rather than public base classes, so adopting a different backend later need not replace the control API.

Platform Ganesh presenter Graphite presenter
iOS / Mac Catalyst Metal Native Metal
Android OpenGL ES Native Vulkan on compatible devices
Windows / WinUI ANGLE / OpenGL ES Explicitly unsupported in this iteration

Keep the existing SKGLView API and signed native assembly identities. Migrate the supported native Basic and MAUI Basic/Gallery GPU paths, add an explicit Graphite choice, and isolate Android's unsigned Vulkan integration dependency in SkiaSharp.Views.Graphite. No native Dawn, backend selector, silent renderer fallback, Tizen, or new macOS/tvOS view is included.

Stacked prerequisite: this PR intentionally targets #4729's refreshed feature branch while its interop changes remain unmerged. Its diff is views-only; native exports, generated bindings, and core interop regressions remain in #4729 and mono/skia#345. Keep this PR dependent on the prerequisite; do not merge the stack out of order.

Current alignment: head 4813015ef9262504c1f32d4c5464680647cf09d8 is rebased onto #4729 f5b6f58ee7aaf8c327268df04fa3907b4a4541f8, whose exact main base is 5e3e1c51bab1b5ef41017f570717e173108b48b4. All 19 upper commits were replayed after old lower 14157c0030ab0c339310b3c68999e866cf0ab918, conflict-free and range-diff identical. This refresh only inherits main's landed #5795 x86 Docker digest pins and #5788 Uno 7 smoke-layout fixes, plus generated release documentation. Those repairs are byte-identical to the lower/main baseline and are not copied into the views diff. Implementation, native source/pin, public APIs, tests, target/package graphs and Gallery's Ganesh-first default are unchanged. The combined Mesh/Graphite native pin remains 75ab194f675fe445dac44ea98829148fc6c6848d, based on merged Mesh 5d226f638edbb3c0dac0ac93ac1ff349298880a4; its verified source-built artifacts/provenance remain valid. Stack 5781 stays [4729, 5329], with the same base chain and draft states. No pending APIs, unrelated feature repairs, stack metadata or foreign branch changes were introduced.

Draft acceptance gaps: the local unfiltered console gate was rerun on this head, but repaired remote container/Uno checks still need their natural new-head CI run; inheriting fixes is not a claimed remote pass. Native-view Windows/mobile/package-consumer runtime acceptance also remains outstanding. The earlier Windows CFG fix and mandatory five-host acceptance gate are retained unchanged. No manual CI queues, device runs, golden/tolerance changes or GPU-policy relaxation were made.

Related issues

Related to #4721 and #3962. #4745 is now closed as superseded for iOS/Mac Catalyst; its unported macOS/tvOS source and mattleibow-apple-native-graphite-views branch are preserved.

Required skia PR

Requires mono/skia#345 through #4729. The source-built native prerequisite is the combined Mesh/Graphite m159 75ab194f675fe445dac44ea98829148fc6c6848d; the refreshed managed prerequisite is f5b6f58ee7aaf8c327268df04fa3907b4a4541f8. The native presentation changes and regenerated Mesh/Graphite Cdecl/callback bindings remain in the prerequisite/main layers, not this views diff.

Areas affected

  • Managed API (binding/)
  • Native / C API (externals/skia/src/c, include/c)
  • Generated P/Invoke bindings
  • Native dependency or Skia update (libpng, HarfBuzz, FreeType, zlib, milestone bump, …)
  • Views & integrations (MAUI, Uno, WPF, WinUI, Blazor, …)
  • Rendering output / visual behavior
  • Performance
  • Tests
  • Build, packaging, or CI
  • Documentation or samples

Changes

Public API

All additions; no legacy signature, return type, interface requirement, or assembly identity is changed. The native/MAUI paint arguments below inherit the existing SKPaintSurfaceEventArgs, retaining its Surface, Info, and RawInfo properties.

MAUI controls: SkiaSharp.Views.Maui.Controls
public abstract class SKGpuView : View, ISKGpuView
{
    protected SKGpuView();
    public static readonly BindableProperty IgnorePixelScalingProperty;
    public static readonly BindableProperty HasRenderLoopProperty;
    public static readonly BindableProperty EnableTouchEventsProperty;
    public bool IgnorePixelScaling { get; set; }
    public bool HasRenderLoop { get; set; }
    public bool EnableTouchEvents { get; set; }
    public SKSize CanvasSize { get; }
    public event EventHandler? ContextCreated;
    public event EventHandler? ContextDestroying;
    public event EventHandler? ContextDestroyed;
    public event EventHandler<SKGpuRenderFailedEventArgs>? RenderFailed;
    public event EventHandler<SKTouchEventArgs>? Touch;
    public void InvalidateSurface();
    protected virtual void OnTouch(SKTouchEventArgs e);
    protected void OnContextChanged(bool created);
}
public class SKGaneshView : SKGpuView, ISKGaneshView
{
    public SKGaneshView();
    public GRContext? GRContext { get; }
    public event EventHandler<SKPaintGaneshSurfaceEventArgs>? PaintSurface;
    protected virtual void OnPaintSurface(SKPaintGaneshSurfaceEventArgs e);
}
public class SKGraphiteView : SKGpuView, ISKGraphiteView
{
    public SKGraphiteView();
    public SKGraphiteContext? GraphiteContext { get; }
    public event EventHandler<SKPaintGraphiteSurfaceEventArgs>? PaintSurface;
    public SKGraphiteRecorder CreateRecorder();
    public SKGraphiteRecording SnapRecording(SKGraphiteRecorder recorder);
    public SKGraphiteInsertStatus InsertRecording(SKGraphiteRecording recording);
    protected virtual void OnPaintSurface(SKPaintGraphiteSurfaceEventArgs e);
}

UseSkiaSharp() registers both new handlers while retaining the existing registrations; its signature is unchanged.

MAUI contracts and events: SkiaSharp.Views.Maui
public interface ISKGpuView : IView
{
    SKSize CanvasSize { get; }
    bool HasRenderLoop { get; }
    bool IgnorePixelScaling { get; }
    bool EnableTouchEvents { get; }
    void InvalidateSurface();
    void OnCanvasSizeChanged(SKSizeI size);
    void OnTouch(SKTouchEventArgs e);
    void OnContextDestroying();
    void OnRenderFailed(Exception exception);
}
public interface ISKGaneshView : ISKGpuView
{
    GRContext? GRContext { get; }
    void OnGRContextChanged(GRContext? context);
    void OnPaintSurface(SKPaintGaneshSurfaceEventArgs e);
}
public interface ISKGraphiteView : ISKGpuView
{
    SKGraphiteContext? GraphiteContext { get; }
    SKGraphiteRecorder CreateRecorder();
    SKGraphiteRecording SnapRecording(SKGraphiteRecorder recorder);
    SKGraphiteInsertStatus InsertRecording(SKGraphiteRecording recording);
    void OnGraphiteContextChanged(SKGraphiteContext? context);
    void OnPaintSurface(SKPaintGraphiteSurfaceEventArgs e);
}
public class SKPaintGaneshSurfaceEventArgs : SKPaintSurfaceEventArgs
{
    public SKPaintGaneshSurfaceEventArgs(SKSurface surface, GRContext context,
        GRBackendRenderTarget renderTarget, GRSurfaceOrigin origin,
        SKImageInfo info, SKImageInfo rawInfo);
    public GRContext Context { get; }
    public GRBackendRenderTarget BackendRenderTarget { get; }
    public GRSurfaceOrigin Origin { get; }
}
public class SKPaintGraphiteSurfaceEventArgs : SKPaintSurfaceEventArgs
{
    public SKPaintGraphiteSurfaceEventArgs(SKSurface surface, SKGraphiteContext context,
        SKGraphiteBackendTexture backendTexture, SKImageInfo info, SKImageInfo rawInfo);
    public SKGraphiteContext Context { get; }
    public SKGraphiteBackendTexture BackendTexture { get; }
    public void RequestReadPixels(SKImageInfo info, SKRectI sourceRect,
        Action<SKImageReadPixelsResult?> callback);
}
public sealed class SKGpuRenderFailedEventArgs : EventArgs
{
    public SKGpuRenderFailedEventArgs(Exception exception);
    public Exception Exception { get; }
}
Native contracts and containers

The following native contracts are in SkiaSharp.Views.iOS, SkiaSharp.Views.Android, and (Ganesh/common contracts only) SkiaSharp.Views.Windows:

public interface ISKGpuView
{
    SKSize CanvasSize { get; }
    bool HasRenderLoop { get; set; }
    bool IgnorePixelScaling { get; set; }
    void InvalidateSurface();
    void Disconnect();
    event EventHandler? ContextCreated;
    event EventHandler? ContextDestroying;
    event EventHandler? ContextDestroyed;
    event EventHandler<SKGpuRenderFailedEventArgs>? RenderFailed;
}
public interface ISKGaneshView : ISKGpuView
{
    GRContext? GRContext { get; }
    event EventHandler<SKPaintGaneshSurfaceEventArgs>? PaintSurface;
}
public interface ISKGraphiteView : ISKGpuView
{
    SKGraphiteContext? GraphiteContext { get; }
    SKGraphiteRecorder CreateRecorder();
    SKGraphiteRecording SnapRecording(SKGraphiteRecorder recorder);
    SKGraphiteInsertStatus InsertRecording(SKGraphiteRecording recording);
    event EventHandler<SKPaintGraphiteSurfaceEventArgs>? PaintSurface;
}

Each new concrete native container publicly implements all its engine-contract members. Stable hosts and constructors:

// iOS / Mac Catalyst: SkiaSharp.Views.iOS
public class SKGaneshView : UIView, ISKGaneshView;
public SKGaneshView();
public SKGaneshView(CGRect frame);
public SKGaneshView(IntPtr handle);
public override void SKGaneshView.MovedToWindow();
public override void SKGaneshView.LayoutSubviews();
public class SKGraphiteView : UIView, ISKGraphiteView;
public SKGraphiteView();
public SKGraphiteView(CGRect frame);
public SKGraphiteView(IntPtr handle);
public override void SKGraphiteView.MovedToWindow();
public override void SKGraphiteView.LayoutSubviews();

// Android: SkiaSharp.Views.Android
public class SKGaneshView : FrameLayout, ISKGaneshView;
public SKGaneshView(Context context);
public SKGaneshView(Context context, IAttributeSet attrs);
public void SKGaneshView.OnPause();
public void SKGaneshView.OnResume();
public class SKGraphiteView : FrameLayout, ISKGraphiteView;
public SKGraphiteView(Context context);
public SKGraphiteView(Context context, IAttributeSet attrs);
public void SKGraphiteView.OnPause();
public void SKGraphiteView.OnResume();

// WinUI: SkiaSharp.Views.Windows
public class SKGaneshView : Grid, ISKGaneshView;
public SKGaneshView();

Native SKPaintGaneshSurfaceEventArgs and SKGpuRenderFailedEventArgs have the same public members/signatures listed for their MAUI counterparts. Native Graphite event-argument constructor ordering matches the prior native presentation convention:

public class SKPaintGraphiteSurfaceEventArgs : SKPaintSurfaceEventArgs
{
    public SKPaintGraphiteSurfaceEventArgs(SKSurface surface,
        SKGraphiteBackendTexture backendTexture, SKGraphiteContext context, SKImageInfo info);
    public SKPaintGraphiteSurfaceEventArgs(SKSurface surface,
        SKGraphiteBackendTexture backendTexture, SKGraphiteContext context,
        SKImageInfo info, SKImageInfo rawInfo);
    public SKGraphiteContext Context { get; }
    public SKGraphiteBackendTexture BackendTexture { get; }
    public void RequestReadPixels(SKImageInfo info, SKRectI sourceRect,
        Action<SKImageReadPixelsResult?> callback);
}

Graphite containers/contracts are provided only on iOS, Mac Catalyst and Android by the new unsigned SkiaSharp.Views.Graphite package. Android alone depends on the existing Silk.NET.Vulkan 2.23.0 package. The cross-platform MAUI type compiles for reference/Windows TFMs but unsupported presentation throws explicitly.

Handler customization: SkiaSharp.Views.Maui.Handlers
// On supported platform TFMs; platform-container constraints are native framework types.
public abstract class SKGpuViewHandler<TVirtual, TPlatform> : ViewHandler<TVirtual, TPlatform>;
protected SKGpuViewHandler(IPropertyMapper mapper, CommandMapper commands);
protected abstract void SKGpuViewHandler<TVirtual, TPlatform>.UpdateContext(bool available);
protected void SKGpuViewHandler<TVirtual, TPlatform>.MapGpuProperties();

public class SKGaneshViewHandler;
public static PropertyMapper<ISKGaneshView, SKGaneshViewHandler> SKGaneshViewMapper;
public static CommandMapper<ISKGaneshView, SKGaneshViewHandler> SKGaneshViewCommandMapper;
public SKGaneshViewHandler();
public SKGaneshViewHandler(IPropertyMapper? mapper, CommandMapper? commands);
public static void MapProperties(SKGaneshViewHandler handler, ISKGaneshView view);
public static void OnInvalidateSurface(SKGaneshViewHandler handler, ISKGaneshView view, object? args);

public class SKGraphiteViewHandler;
public static PropertyMapper<ISKGraphiteView, SKGraphiteViewHandler> SKGraphiteViewMapper;
public static CommandMapper<ISKGraphiteView, SKGraphiteViewHandler> SKGraphiteViewCommandMapper;
public SKGraphiteViewHandler();
public SKGraphiteViewHandler(IPropertyMapper? mapper, CommandMapper? commands);
public static void MapProperties(SKGraphiteViewHandler handler, ISKGraphiteView view);
public static void OnInvalidateSurface(SKGraphiteViewHandler handler, ISKGraphiteView view, object? args);
public SKGraphiteRecorder SKGraphiteViewHandler.CreateRecorder();
public SKGraphiteRecording SKGraphiteViewHandler.SnapRecording(SKGraphiteRecorder recorder);
public SKGraphiteInsertStatus SKGraphiteViewHandler.InsertRecording(SKGraphiteRecording recording);

The concrete handlers inherit SKGpuViewHandler<engine-contract, native-container> on supported platforms. Reference handlers and Windows Graphite inherit the corresponding ViewHandler placeholder specialization and reject platform creation. Native create/connect/disconnect lifecycle overrides are documented in source.

Behavior

  • Defaults remain on-demand rendering, physical-pixel drawing, and opt-in touch forwarding. Contexts and frame surfaces are borrowed and thread-affine; application code must not dispose/retain frame resources or submit the private presentation recorder independently.

  • Graphite caller recorders are created/tracked through CreateRecorder, snapped on their exclusive worker thread through SnapRecording, and inserted on the context owner thread. Stale/untracked recordings are rejected before native insertion. Shutdown stops producers and disposes dependent surfaces/images/recordings before recorders; retiring generations remain bounded while dependencies drain.

  • Vulkan uses up to three asynchronously submitted frames, with acquisition waits, per-image completion semaphores, present layout/queue transitions and resize-aware native-window geometry. Ordinary frames do not block on CPU fence/device-idle waits; resize/teardown may drain.

  • e.RequestReadPixels schedules reads after current-frame drawing insertion and before presentation transitions; callbacks receive borrowed pixels or null on failure/cancellation, including while an on-demand view is idle. All canceled requests are notified even if a callback throws, and mandatory GPU cleanup still runs.

  • Failure stops the affected generation and notifies/logs explicitly. Retry is explicit; no blank-success, Ganesh, or software fallback is substituted for Graphite. Typed context state and canvas size clear on destruction. Windows teardown makes its own EGL context current before notifying applications.

  • Android disconnect completes native context disposal before returning when destruction callbacks release all registered dependencies; callers retaining producer recorders still defer final retirement to the GPU owner thread.

  • Gallery preserves main's GPU-first default through Ganesh; CPU and supported-platform Graphite remain explicit selections.

See documentation/dev/gpu-engine-views.md for ownership, worker shutdown, readbacks, platform scope and migration examples.

Testing

Current CI-base refresh validation (November 17): the unfiltered console command below was rerun successfully on this head, and source/native/CI identity checks were repeated. All other library, Gallery compilation, package and fixture evidence below comes from the preceding Mesh refresh on byte-identical implementation and target/package graphs; it was not relabeled as newly executed. No manual CI queues, device runs, golden updates, new GPU skips or protected-branch changes were made.

The macOS ARM64 natives were reused from the prerequisite's successful dotnet cake --target=externals-macos --arch=arm64 source build at 75ab194f675fe445dac44ea98829148fc6c6848d, not downloaded. Both source-artifact SHA256s were checked before/after copying; the Skia hash also matches all five rebuilt console hosts: Skia fce798551b6779290b0f5b052ef521d4da33be23be2286a87142e64037ea1e02; HarfBuzz 534e548753bfca75c78384d0e6527e2f8caac146aefa307742967b92cf1a1cb6. These are ARM64 macOS outputs only, not device/x64/Windows artifacts. Apple library compilation used process-local Xcode 27.2.

Exact command / evidence Result
dotnet test tests/SkiaSharp.Tests.Console.slnx -p:TargetFramework=net10.0 -p:TargetFrameworks=net10.0 --verbosity quiet -- --report-trx Passed, unfiltered: 6,787 passed / 55 declared skips inherited from updated lower / zero failures, across core, singleton, Vulkan, Direct3D and Gallery hosts. Actual TRX outcomes and native hashes were parsed; the former local Ganesh GL DiagonalLines blocker passes now.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net10.0-android36.0 -p:TargetFrameworks=net10.0-android36.0 --verbosity quiet Passed, including native Ganesh/Graphite dependencies and MAUI handlers/controls.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net10.0-ios26.0 -p:TargetFrameworks=net10.0-ios26.0 --verbosity quiet Passed.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net10.0-maccatalyst26.0 -p:TargetFrameworks=net10.0-maccatalyst26.0 --verbosity quiet Passed.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net9.0-android35.0 -p:TargetFrameworks=net9.0-android35.0 --verbosity quiet Passed; SDK reports the existing .NET 9 Android end-of-support warning.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net9.0-ios18.0 -p:TargetFrameworks=net9.0-ios18.0 --verbosity quiet Passed.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net9.0-maccatalyst18.0 -p:TargetFrameworks=net9.0-maccatalyst18.0 --verbosity quiet Passed.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net10.0 -p:TargetFrameworks=net10.0 --verbosity quiet Passed, reference surface.
dotnet build source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj -p:TargetFramework=net9.0 -p:TargetFrameworks=net9.0 --verbosity quiet Passed, reference surface.
dotnet restore samples/Gallery/Maui/SkiaSharpSample.Maui.csproj --verbosity quiet then dotnet build samples/Gallery/Maui/SkiaSharpSample.Maui.csproj -t:Compile --no-restore --framework net10.0-android --verbosity quiet Passed; actual Gallery managed compilation covers the merged Mesh samples and Ganesh-default conflict resolution. This does not link, package or run a native Android app.
dotnet restore source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj --verbosity quiet Passed; restores the complete declared framework graph after single-framework builds, rather than packing from the final single-framework assets file.
dotnet pack source/SkiaSharp.Views/SkiaSharp.Views.Graphite/SkiaSharp.Views.Graphite.csproj --configuration Debug --no-build --output output/gpu-view-validation/m159-mesh-sync/packages --verbosity quiet Passed, using the six already-built current/previous Android/iOS/Catalyst TFMs.
dotnet pack source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Core/SkiaSharp.Views.Maui.Core.csproj --configuration Debug --no-build --output output/gpu-view-validation/m159-mesh-sync/packages --verbosity quiet Passed, eight platform/reference TFMs.
dotnet pack source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Controls/SkiaSharp.Views.Maui.Controls.csproj --configuration Debug --no-build --output output/gpu-view-validation/m159-mesh-sync/packages --verbosity quiet Passed, eight platform/reference TFMs.
Actual NuGet archive inspection Passed: all three packages and their SkiaSharp dependencies are 4.159.0; compiler XML accompanies all 22 packaged assemblies, and only Android Graphite groups depend on Silk.NET.Vulkan. These Debug packs preserve main's ProduceReferenceAssembly=false setting; they do not claim separate ref/ assemblies or production signing/BAR certification.
pwsh -NoLogo -NoProfile -File scripts/infra/tests/tests/Test-SharedRunner.ps1 Passed; actual shared C# runner argument method, including solution/project defaults, caller overrides, typed Samples filtering, no-build/hang behavior, distinct solution reports and MTP coverage. Updated its source path to main's tests-shared.cake rename.
pwsh -NoLogo -NoProfile -File scripts/infra/tests/tests/Test-WindowsGaneshBackend.ps1 Passed; actual Windows render method selects ANGLE only after making EGL current, once per generation, over 16 generations/two frames each. This is not a native Windows presentation run.
pwsh -NoLogo -NoProfile -File scripts/infra/tests/tests/Test-WindowsGpuCapture.ps1 Passed before this Mesh refresh on byte-identical capture code, with verified isolated macOS ARM64 PowerShell 7.6.3; actual child-job launch, surviving collector/helper ownership, late analysis, recovery, publication privacy and repeat-invocation fixtures. The existing .NET-tool package's bundled Linux ELF child executable was not usable on macOS; no shared tool installation or production fallback was changed.
Offline canonical YAML/template/source comparisons Passed: six default desktop caller/coverage expansions identical; the Windows SDK/post-build hook is migrated to azure-templates-stages-tests.yml; default-off capture is forwarded through the stage wrapper. Other runtime callers, current Android/iOS matrices, Windows MAUI job, typed Samples/analyzer/templates/runner and human-facing building-samples.md are unchanged from the lower/main baseline.
Review The previous independent rubber-duck review found no blocking correctness/build issues. This CI-only refresh was verified directly: all 19 upper patches are range-diff identical, implementation/native trees are unchanged and landed Docker/Uno repairs match the canonical lower/main files. Main's unfiltered Windows MAUI job also runs the new GPU cases without the specialized gate's diagnostics; its coverage is intentionally preserved alongside the five-host stress gate, not suppressed with new GPU skips. Actual Windows execution remains unverified here.
git diff --check Passed.

Remaining acceptance: no new Windows native presentation/input/teardown run, mobile device run, or package-consumer runtime run was performed for m159. Those remain required before treating the views as fully accepted. The historical Windows crash was identified as a CFG indirect-call failure into unloaded WGL code; the presenter now explicitly uses GRGlInterface.CreateAngle() after MakeCurrent(). The retained gate still requires all eight cases in five independent hosts; a method-level regression or old pass is not its replacement. The old build 1635543 is not claimed as a verified after-pass.

Historical m156 evidence, not m159 acceptance: source-built native matrices, package metadata/legacy compatibility checks and actual Android/iOS/Catalyst pixel/readback/lifetime runs were obtained earlier. The complete hosted Android after-gate passed 1,191 / 0 failures / 87 declared skips, including all 16 new GPU/lifetime cases. Catalyst package-only runs passed 15/15 with no skips after Appium authentication prevented the original launch. Windows had complete eight-case passes but intermittent host termination before the explicit ANGLE fix. These results explain the retained tests and fixes; they are not relabeled as fresh m159 runtime evidence. Screenshots below also come from that original implementation.

Screenshots (before / after)

Native iOS Basic migration. These are real animated shader scenes, not synchronized golden captures; animation phases differ. The original-main SKMetalView sample is unchanged and was rebuilt for the comparison.

Before: legacy Metal view After: engine-named Ganesh view
Original main iOS Metal shader scene New iOS Ganesh shader scene
New Graphite on iOS / Metal New Graphite on Android / Vulkan
iOS Graphite shader scene Android Graphite shader scene

No golden-image changes.

Checklist

  • Tests added or updated (if omitted, explain why above)
  • Changes above lists all public API and behavioral changes (or "None.")
  • New/changed public API? Added or updated accurate source /// documentation and regenerated bindings when applicable
  • Native change? Companion mono/skia PR linked above and bindings regenerated

@github-actions

Copy link
Copy Markdown
Contributor

📦 Try the packages from this PR

Warning

Do not run these scripts without first reviewing the code in this PR.

Step 1 — Download the packages

bash / macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 5329

PowerShell / Windows:

iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 5329"

Step 2 — Add the local NuGet source

dotnet nuget add source ~/.skiasharp/hives/pr-5329/packages --name skiasharp-pr-5329
More options
Option Description
--successful-only / -SuccessfulOnly Only use successful builds
--force / -Force Overwrite previously downloaded packages
--list / -List List available artifacts without downloading
--build-id ID / -BuildId ID Download from a specific build

Or download manually from Azure Pipelines — look for the nuget artifact on the build for this PR.

Remove the source when you're done:

dotnet nuget remove source skiasharp-pr-5329

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

📊 SkiaSharp benchmarks — PR #5329

⭐ this PR (full source build) vs 🌙 nightly · Linux · Windows · macOS

Informational only — this never blocks the PR. 🟢 faster / less allocation · 🔴 slower / more allocation; moves under 5% are hidden as noise.

⏱️ Times are raw BenchmarkDotNet means, and the ⭐ PR and baseline legs run on separate CI runners, so microbenchmarks can swing run-to-run — treat small time deltas as noise. Allocations are deterministic and the reliable signal. The interactive perf-dashboard (linked below) applies smoothing for the trend view.

Highlights

⏱️ Time — 🔴 36 slower · 🟢 59 faster

  • 🔴 MatrixMapPointsBenchmark.MapPoints(Points: 256) · Windows · 146.5 ns → 304.2 ns (+108%)
  • 🔴 MatrixMapPointsBenchmark.MapPoints(Points: 4096) · Windows · 1.69 µs → 3.37 µs (+99%)
  • 🔴 RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) · Windows · 74.59 µs → 125.91 µs (+69%)
  • 🔴 ColorMathBenchmark.ToColorF(Colors: 4096) · Windows · 10.93 µs → 17.43 µs (+59%)
  • 🟢 ColorMathBenchmark.ToColor(Colors: 4096) · Linux · 16.89 µs → 7.93 µs (-53%)
  • …and 90 more (see details below)

📦 Allocations — 🔴 1 more alloc · 🟢 0 less alloc

  • 🔴 RuntimeEffectShaderBenchmark.DrawFrame · Linux · 683 B → 733 B (+7%)
Full per-OS benchmark deltas

Linux

⏱️ Time (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
ColorMathBenchmark.ToColor(Colors: 4096) 16.89 µs 7.93 µs 🟢 -53%
RuntimeEffectShaderBenchmark.DrawFrame 2.84 ms 4.15 ms 🔴 +46%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 11.43 µs 6.86 µs 🟢 -40%
ColorMathBenchmark.PreMultiply(Colors: 4096) 12.87 µs 7.91 µs 🟢 -39%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 4.51 µs 2.93 µs 🟢 -35%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 72.11 µs 46.85 µs 🟢 -35%
ColorParseBenchmark.Parse(Iterations: 1000) 73.17 µs 48.51 µs 🟢 -34%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 254.55 µs 177.73 µs 🟢 -30%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 234.47 µs 165.03 µs 🟢 -30%
MatrixOpsBenchmark.Concat(Count: 4096) 216.73 µs 153.03 µs 🟢 -29%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 14.62 µs 10.35 µs 🟢 -29%
MatrixOpsBenchmark.Invert(Count: 4096) 127.43 µs 90.59 µs 🟢 -29%
PathBoundsBenchmark.TightBounds(Points: 64) 984.1 ns 708.7 ns 🟢 -28%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 177.22 µs 130.45 µs 🟢 -26%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 18.16 ms 22.85 ms 🔴 +26%
MatrixMapPointsBenchmark.MapVector(Points: 256) 11.07 µs 8.25 µs 🟢 -25%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 344.69 µs 258.84 µs 🟢 -25%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.29 ms 975.78 µs 🟢 -24%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 920.17 µs 702.36 µs 🟢 -24%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 4.00 ms 4.94 ms 🔴 +23%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 244.74 µs 187.55 µs 🟢 -23%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.63 ms 2.02 ms 🟢 -23%
PathBoundsBenchmark.TightBounds(Points: 1024) 9.83 µs 7.68 µs 🟢 -22%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 681.24 µs 547.21 µs 🟢 -20%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 95.42 µs 77.84 µs 🟢 -18%
…and 6 more

📦 Allocations (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
RuntimeEffectShaderBenchmark.DrawFrame 683 B 733 B 🔴 +7%

Windows

⏱️ Time (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
MatrixMapPointsBenchmark.MapPoints(Points: 256) 146.5 ns 304.2 ns 🔴 +108%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 1.69 µs 3.37 µs 🔴 +99%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 74.59 µs 125.91 µs 🔴 +69%
ColorMathBenchmark.ToColorF(Colors: 4096) 10.93 µs 17.43 µs 🔴 +59%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 201.26 µs 300.61 µs 🔴 +49%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.49 ms 3.66 ms 🔴 +47%
PathBoundsBenchmark.TightBounds(Points: 64) 1.20 µs 1.72 µs 🔴 +43%
PathBoundsBenchmark.TightBounds(Points: 1024) 12.77 µs 17.65 µs 🔴 +38%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 1.74 ms 2.38 ms 🔴 +37%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 8.12 ms 10.93 ms 🔴 +35%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 624.32 µs 812.19 µs 🔴 +30%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 8.58 ms 11.15 ms 🔴 +30%
CanvasDrawBenchmark.Draw(Shapes: 512) 15.99 ms 20.12 ms 🔴 +26%
ColorParseBenchmark.Parse(Iterations: 1000) 63.75 µs 79.99 µs 🔴 +25%
CanvasDrawBenchmark.Draw(Shapes: 64) 2.01 ms 2.52 ms 🔴 +25%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 205.30 µs 252.61 µs 🔴 +23%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 744.53 µs 916.07 µs 🔴 +23%
ColorMathBenchmark.ToColor(Colors: 4096) 9.18 µs 11.22 µs 🔴 +22%
ColorMathBenchmark.PreMultiply(Colors: 4096) 11.39 µs 13.73 µs 🔴 +21%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 2.15 ms 2.58 ms 🔴 +20%
MatrixMapPointsBenchmark.MapRect(Points: 256) 9.50 µs 11.29 µs 🔴 +19%
MatrixOpsBenchmark.Concat(Count: 4096) 187.97 µs 222.75 µs 🔴 +19%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.03 ms 1.22 ms 🔴 +18%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 272.44 µs 320.19 µs 🔴 +18%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 9.84 µs 11.34 µs 🔴 +15%
…and 6 more

macOS

⏱️ Time (vs 🌙 nightly 4.157.0-nightly.26554.4)

Benchmark baseline this PR Δ
MatrixOpsBenchmark.Invert(Count: 4096) 94.85 µs 59.07 µs 🟢 -38%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 1.95 µs 2.66 µs 🔴 +37%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 3.22 ms 2.07 ms 🟢 -36%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 9.59 µs 6.24 µs 🟢 -35%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 759.35 µs 511.66 µs 🟢 -33%
RuntimeEffectShaderBenchmark.DrawFrame 653.18 µs 446.35 µs 🟢 -32%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 1.86 ms 1.30 ms 🟢 -30%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 7.11 µs 4.97 µs 🟢 -30%
ColorParseBenchmark.Parse(Iterations: 1000) 75.21 µs 53.26 µs 🟢 -29%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 110.76 µs 79.10 µs 🟢 -29%
PathBoundsBenchmark.TightBounds(Points: 64) 1.22 µs 873.5 ns 🟢 -28%
ColorMathBenchmark.PreMultiply(Colors: 4096) 9.81 µs 7.07 µs 🟢 -28%
ColorMathBenchmark.ToColor(Colors: 4096) 22.78 µs 16.56 µs 🟢 -27%
PathBoundsBenchmark.TightBounds(Points: 1024) 11.14 µs 8.37 µs 🟢 -25%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 6.68 ms 5.19 ms 🟢 -22%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 172.9 ns 210.5 ns 🔴 +22%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 717.36 µs 577.26 µs 🟢 -20%
MatrixMapPointsBenchmark.MapVector(Points: 256) 2.67 µs 2.16 µs 🟢 -19%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 6.65 ms 5.40 ms 🟢 -19%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 249.89 µs 205.58 µs 🟢 -18%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 1.41 ms 1.17 ms 🟢 -17%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 783.79 µs 656.47 µs 🟢 -16%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 179.12 µs 150.73 µs 🟢 -16%
CanvasDrawBenchmark.Draw(Shapes: 512) 13.32 ms 11.22 ms 🟢 -16%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 175.41 µs 152.02 µs 🟢 -13%
…and 8 more

📈 Full interactive perf-dashboard & run details →

@mattleibow

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@mattleibow

Copy link
Copy Markdown
Contributor Author

The remaining Windows acceptance work is now wired into the owning Windows .NET Core CI leg at dd67cefa6d1: it runs the real MAUI device-host GPU tests, including a distinctive composited-window pixel pattern and actual native pointer/DPI routing. Rendering failures stay latched through cleanup; no GPU skips or signing/native-build workarounds were added. The exact revision is queued in public build 1631369.

The Catalyst package-validation blocker has an independent, non-Appium path now: a package-only host reused the actual GPU view tests and collection checks and passed 15/15 with zero skips, including current-frame pixels/readbacks, producers, resize, retry and retirement. It did not bypass OS authentication or permission settings.

The local macOS GL golden divergence is explicitly documented by the already merged #5183: the repository deliberately chose the macOS 15.7 CI capture rather than the macOS 26.7 M3 Pro local image. We retain that golden and require the fresh unfiltered owning-platform CI gates; no golden/tolerance/skip changes are included here.

@mattleibow
mattleibow force-pushed the mattleibow-maui-gpu-views branch from 592b555 to 8aabb95 Compare October 13, 2026 05:16
@mattleibow
mattleibow added this pull request to stack #5781 November 17, 2026 05:20
@mattleibow
mattleibow force-pushed the mattleibow-maui-gpu-views branch from d72fe35 to cafdc05 Compare November 17, 2026 13:52
@mattleibow
mattleibow force-pushed the mattleibow-maui-gpu-views branch from cafdc05 to 326396e Compare November 17, 2026 15:16
v and others added 13 commits November 17, 2026 19:57
Keep native GPU presentation behind stable engine-named containers and expose typed contexts, common drawing metadata, explicit lifecycle notifications, and generation-safe producer recording. Ganesh uses the established Metal/GLES/ANGLE backends; Graphite uses Metal/Vulkan without a Windows or software fallback. Vulkan presentation retires bounded asynchronous frames, and frame readback is scheduled after drawing and before presentation transitions.

Migrate supported native and MAUI samples, isolate Vulkan integration dependencies, and cover pixels, resize, input, completion, retry, reattachment, and owned-resource collection. The legacy SKGLView consumer API remains unchanged. Windows validation and the independently reproduced main Ganesh-GL golden failure remain explicit draft blockers.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Native Android containers expose SkiaCanvas through ContentDescription, whereas MAUI controls use a resource ID. Locate archived native samples by their shared accessibility identifier instead of applying the MAUI-specific Android resource-ID locator.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Avoid Java's reserved native identifier in Android sample package names. Build iOS package consumers for the simulator RID expected by the harness, with normal ad-hoc signing, instead of relying on device-build defaults. Both archived Android GPU samples and both archived iOS GPU samples pass their actual presentation checks against the source-built local package feed.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Run the owning MAUI device host in the Windows console-test leg with its repository-derived framework. Verify a distinctive composited Ganesh pattern and real pointer routing in addition to context, pixel, lifecycle and collection contracts. Keep rendering failures latched through cleanup and restore only this test's injected input state.

No GPU skip, golden, tolerance, native download fallback, or production signing change is introduced. An exact-package Catalyst device host separately passed all 15 GPU/lifecycle cases without depending on Appium or OS authentication automation.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Collapse both framework properties for the primary unfiltered console solution instead of restoring every platform from desktop jobs. Query the Windows MAUI framework through a neutral binding evaluation so native-copy targets cannot inspect an unset platform version.

Keep distinct result files for all five solution hosts. Use the compatible MTP-native coverage extension, preserve the isolated MSBuild test project's boundary, and normalize merged coverage class filenames without assuming a sources element. Actual local validation produced five populated Cobertura reports; only the intentionally documented main macOS GL golden divergence remains.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
The primary console solution declares Any CPU, while its individual projects use AnyCPU. Preserve each runner's correct platform spelling instead of passing the project spelling to a solution. The actual coverage-enabled Cake helper reaches all five hosts and emits distinct result/coverage files; only the previously documented local main GL image difference remains.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Build the owning Windows UI test host as unpackaged and self-contained. The first real-host compile passed, but DeviceRunners attempted loose MSIX registration and correctly rejected an agent without Developer Mode. Use normal executable deployment instead of enabling machine-wide installation exceptions or skipping presentation/input coverage.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
The Windows App SDK rejects self-contained AnyCPU projections. Match the owning x64 test agent for the UI host and its project graph so the unpackaged launch can be verified without enabling Developer Mode.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Avoid extracting competing Windows App SDK runtime copies in every referenced view library. Keep self-contained unpackaged mode local to the Windows test host, preserving normal packaged and non-Windows defaults.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Import the existing WinUI source-native helper and explicitly copy its native content for unpackaged execution. The owning Windows host now launches; its GPU tests exposed missing ANGLE DLLs that packaged sample layouts previously collected implicitly.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
When destruction callbacks have released every producer dependency, dispose the native context before Stop returns. Preserve asynchronous owner-thread retirement for callers retaining recorders. The existing context-handle regression reproduced the race in a full Android run; six complete after-runs pass, and independent ownership review found no significant issues.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Retain opt-in host exception and exit logs, plus recent Application Error/.NET Runtime/WER events and existing reports for the owning test executable, without changing system policy. Require five complete eight-case host runs and fail immediately on any failure or incomplete stream; this is stress validation, not a retry-until-pass fallback. The intermittent four-case termination remains unexplained and is not classified as infrastructure.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Keep the initial frame completion stable and publish a separate logical-size waiter. An Android GPU callback can still be finishing a pre-scaling frame after the UI observes its frame counter and changes IgnorePixelScaling. Preserve the existing width/height criteria, latch render failures through cleanup, and always disconnect the host.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
v and others added 6 commits November 17, 2026 19:57
Keep the five-host gate unchanged by default and enable native crash capture only on explicit diagnostic runs. Verify Microsoft tooling and owning process identities, retain collector/analysis ownership through recovery, and analyze privately before deleting dumps. Isolate raw dumps, licensed binaries and symbols from all failed-job artifacts. Exercise timeout, failed-job, late-analysis and repeated-invocation paths with owned-process fixtures.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Queue Build does not propagate arbitrary runtime variables. Forward a default-off captureWindowsGpuNativeDumps boolean through complete/tests templates and log its evaluated value before the GPU gate, preserving the local task-environment opt-in. Validate both true and false rendered task scripts.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
The actual capture worker exposed advanced-script positional binding failure and lost PSScriptRoot from Start-Job -FilePath. Forward named arguments through a job scriptblock invoking the real file, and verify the actual launch AST reaches platform/tool validation in a real background job.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Keep the Windows GPU workload and acceptance hook caller-owned while common reporting stays in the shared desktop template. Exercise the actual shared-runner method with local stand-ins to preserve Samples filtering/no-build/hang behavior, caller properties, solution platform spelling and distinct MTP coverage/TRX arguments without restoring Cake or launching native/device hosts.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
The captured Windows failure enters native MakeWin with cached WGL procedure addresses inside an unloaded opengl32 mapping. This presenter already owns an EGL/ANGLE context, so probing desktop WGL is both unnecessary and unsafe. Select the existing ANGLE factory after MakeCurrent without changing native code, public APIs or fallback policy. The actual-render-method local fixture fails before and passes across 16 context generations after; owning Windows after-runtime validation remains paused.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f
Use the renamed shared runner in its regression fixture and keep only the inherited WinUI native-assets import before the unpackaged host content update. Document the Windows GPU hook in the split runtime stage without changing canonical device coverage or GPU policy.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: cd863066-e555-4b94-a17a-cc1bc0633c2f

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants