Skip to content

Add Graphite views for .NET MAUI - #4739

Closed
mattleibow wants to merge 3 commits into
mainfrom
mattleibow-add-maui-graphite-views
Closed

mattleibow wants to merge 3 commits into
mainfrom
mattleibow-add-maui-graphite-views

Conversation

@mattleibow

Copy link
Copy Markdown
Contributor

Description

Adds the backend-neutral SKGraphiteView for .NET MAUI over the native Apple/Android controls from #4734. This top layer contains only MAUI controls/handlers, touch/lifecycle plumbing, the MAUI multi-recorder sample, and MAUI tests.

The sample demonstrates Graphite’s record/snap/insert/submit model without claiming unmeasured Ganesh speedups: a cached background Recording is replayed while two thread-affine recorders build animated layers concurrently.

This PR is commit-stacked on the lower layers but intentionally targets main so its full CI can run immediately. Merge/review order is #4729, then #4734, then this PR.

Related issues

Fixes #4721
Related to #3962

Required skia PR

Transitively requires mono/skia#345

Required lower SkiaSharp PRs

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

public class SKGraphiteView : Microsoft.Maui.Controls.View;
public interface ISKGraphiteView : IView;
public class SKPaintGraphiteSurfaceEventArgs : EventArgs;
public sealed class SKGraphiteRenderFailedEventArgs : EventArgs;
public partial class SKGraphiteViewHandler;

Behavior

  • MAUI selects Metal on iOS/Mac Catalyst and Vulkan on Android through the native lower layer.
  • HasRenderLoop, invalidation, pixel scaling, touch, detach/reconnect, context changes, and render failures follow existing MAUI view conventions.
  • Windows/Tizen handlers explicitly report unsupported; Graphite is hidden from the Basic sample there.
  • No silent Ganesh fallback.

Testing

  • Built MAUI Controls/Core for net10 Android, iOS, and Mac Catalyst.
  • Packed MAUI Core and Controls across current/previous TFMs; verified every Apple/Android platform group depends on SkiaSharp.Views.Graphite 4.152.0.
  • Built the MAUI Android sample as a Release arm64 APK against source-built native assets.
  • Compiled MAUI device-test projects for Android arm64 and iOS Simulator.
  • The identical stacked tree was runtime-verified on Android API 36 (parallel/serial toggle, touch, repeated Shell detach/reattach) and iOS Simulator (Metal, 60 FPS).
  • Lower PR Add native Graphite views and samples #4734 independently validates the native controls and native samples.
MAUI Graphite sample screenshots
Android / Vulkan iOS / Metal
Graphite sample on Android Graphite sample on iOS

Checklist

Copilot AI added 3 commits August 11, 2026 13:31
Expose deferred canvases, Vulkan synchronization and texture-state primitives, and 64-bit-safe external handles independently of any view implementation.\n\nCo-authored-by: Copilot App <[email protected]>\nCopilot-Session: 00cda8ff-9603-406f-ae2e-45c70e39b3e7
Carve the reviewed native Graphite views package from the combined Graphite
views work and add direct native Basic samples for Android, iOS, Mac Catalyst,
macOS, and tvOS. Gate Android below API 24 and keep the sample render loops
lifecycle-aware and failure-reporting.

Related: #4721
Requires: #4729
Requires: mono/skia#345

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: dd83f08e-1222-4b30-b315-1a5c2103463a
Layer a backend-neutral MAUI control over the native Graphite views and add the multi-recorder MAUI sample plus lifecycle/integration coverage.\n\nCo-authored-by: Copilot App <[email protected]>\nCopilot-Session: 00cda8ff-9603-406f-ae2e-45c70e39b3e7
@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 -- 4739

PowerShell / Windows:

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

Step 2 — Add the local NuGet source

dotnet nuget add source ~/.skiasharp/hives/pr-4739/packages --name skiasharp-pr-4739
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-4739

@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

The documentation for this PR has been deployed and is available at:

🔗 View Staging Site
🔗 View Staging Docs
🔗 View Staging Gallery (Blazor)
🔗 View Staging Gallery (Uno Platform)
🔗 View Staging SkiaFiddle

This preview will be updated automatically when you push new commits to this PR.


This comment is automatically updated by the documentation staging workflow.

@github-actions

Copy link
Copy Markdown
Contributor

📊 SkiaSharp benchmarks — PR #4739

⭐ 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 — 🔴 44 slower · 🟢 43 faster

  • 🔴 BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) · macOS · 148.63 µs → 243.63 µs (+64%)
  • 🔴 BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) · macOS · 195.71 µs → 311.66 µs (+59%)
  • 🔴 RuntimeEffectShaderBenchmark.DrawFrame · Linux · 2.85 ms → 4.32 ms (+52%)
  • 🟢 ColorMathBenchmark.ToColor(Colors: 4096) · Linux · 14.99 µs → 7.32 µs (-51%)
  • 🔴 ColorMathBenchmark.ToColor(Colors: 4096) · Windows · 11.93 µs → 16.97 µs (+42%)
  • …and 82 more (see details below)

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

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

Linux

⏱️ Time (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
RuntimeEffectShaderBenchmark.DrawFrame 2.85 ms 4.32 ms 🔴 +52%
ColorMathBenchmark.ToColor(Colors: 4096) 14.99 µs 7.32 µs 🟢 -51%
ColorMathBenchmark.PreMultiply(Colors: 4096) 12.87 µs 7.81 µs 🟢 -39%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 11.44 µs 7.11 µs 🟢 -38%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 71.97 µs 48.74 µs 🟢 -32%
ColorParseBenchmark.Parse(Iterations: 1000) 74.14 µs 50.25 µs 🟢 -32%
MatrixOpsBenchmark.Invert(Count: 4096) 130.80 µs 89.11 µs 🟢 -32%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 4.51 µs 3.09 µs 🟢 -32%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.92 ms 2.00 ms 🟢 -31%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 257.65 µs 179.56 µs 🟢 -30%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 757.90 µs 532.45 µs 🟢 -30%
MatrixOpsBenchmark.Concat(Count: 4096) 218.29 µs 156.19 µs 🟢 -28%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 3.94 ms 5.05 ms 🔴 +28%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 18.07 ms 23.10 ms 🔴 +28%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 13.72 µs 10.30 µs 🟢 -25%
PathBoundsBenchmark.TightBounds(Points: 64) 977.7 ns 735.0 ns 🟢 -25%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 216.94 µs 164.51 µs 🟢 -24%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 254.11 µs 192.75 µs 🟢 -24%
PathBoundsBenchmark.TightBounds(Points: 1024) 10.15 µs 7.71 µs 🟢 -24%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.33 ms 1.01 ms 🟢 -24%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 2.06 ms 1.57 ms 🟢 -24%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 209.2 ns 257.9 ns 🔴 +23%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 351.94 µs 271.76 µs 🟢 -23%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 7.96 ms 6.18 ms 🟢 -22%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 174.32 µs 135.42 µs 🟢 -22%
…and 7 more

📦 Allocations (vs 🌙 nightly 4.152.0-nightly.10)

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

Windows

⏱️ Time (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
ColorMathBenchmark.ToColor(Colors: 4096) 11.93 µs 16.97 µs 🔴 +42%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 96.45 µs 131.63 µs 🔴 +36%
PathBoundsBenchmark.TightBounds(Points: 1024) 16.70 µs 21.06 µs 🔴 +26%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 238.66 µs 289.01 µs 🔴 +21%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 2.10 µs 2.52 µs 🔴 +20%
PathBoundsBenchmark.TightBounds(Points: 64) 1.61 µs 1.88 µs 🔴 +17%
CanvasDrawBenchmark.Draw(Shapes: 512) 20.57 ms 23.43 ms 🔴 +14%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 3.25 ms 2.87 ms 🟢 -11%
CanvasDrawBenchmark.Draw(Shapes: 64) 2.65 ms 2.94 ms 🔴 +11%
ColorMathBenchmark.PreMultiply(Colors: 4096) 14.74 µs 13.17 µs 🟢 -11%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 86.67 µs 77.49 µs 🟢 -11%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 822.95 µs 740.44 µs 🟢 -10%
MatrixMapPointsBenchmark.MapRect(Points: 4096) 128.91 µs 141.44 µs 🔴 +10%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 153.16 µs 167.34 µs 🔴 +9%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 12.79 µs 11.63 µs 🟢 -9%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 5.42 µs 4.93 µs 🟢 -9%
ColorParseBenchmark.Parse(Iterations: 1000) 77.81 µs 84.54 µs 🔴 +9%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 11.24 ms 10.28 ms 🟢 -9%
MatrixOpsBenchmark.Invert(Count: 4096) 148.24 µs 136.70 µs 🟢 -8%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 2.84 ms 2.64 ms 🟢 -7%
RuntimeEffectShaderBenchmark.DrawFrame 1.22 ms 1.14 ms 🟢 -6%
ColorMathBenchmark.ToColorF(Colors: 4096) 14.14 µs 13.29 µs 🟢 -6%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 9.81 µs 10.36 µs 🔴 +6%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 361.89 µs 343.72 µs 🟢 -5%

macOS

⏱️ Time (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 148.63 µs 243.63 µs 🔴 +64%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 195.71 µs 311.66 µs 🔴 +59%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 664.73 µs 910.14 µs 🔴 +37%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 1.52 µs 2.05 µs 🔴 +35%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 543.43 µs 716.71 µs 🔴 +32%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 97.96 µs 124.01 µs 🔴 +27%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 39.10 µs 47.93 µs 🔴 +23%
RuntimeEffectShaderBenchmark.DrawFrame 507.38 µs 617.02 µs 🔴 +22%
CanvasDrawBenchmark.Draw(Shapes: 64) 1.39 ms 1.68 ms 🔴 +21%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 135.9 ns 162.8 ns 🔴 +20%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.69 ms 2.22 ms 🟢 -18%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 66.42 µs 77.76 µs 🔴 +17%
ColorParseBenchmark.Parse(Iterations: 1000) 63.10 µs 73.70 µs 🔴 +17%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 671.67 µs 561.42 µs 🟢 -16%
CanvasDrawBenchmark.Draw(Shapes: 512) 11.08 ms 12.71 ms 🔴 +15%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 141.56 µs 158.88 µs 🔴 +12%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 18.14 µs 20.08 µs 🔴 +11%
MatrixOpsBenchmark.Concat(Count: 4096) 111.66 µs 122.41 µs 🔴 +10%
PathBoundsBenchmark.TightBounds(Points: 64) 850.3 ns 931.7 ns 🔴 +10%
ColorMathBenchmark.PreMultiply(Colors: 4096) 8.48 µs 9.28 µs 🔴 +9%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 1.14 µs 1.24 µs 🔴 +9%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 5.40 ms 5.88 ms 🔴 +9%
PathBoundsBenchmark.TightBounds(Points: 1024) 8.07 µs 8.78 µs 🔴 +9%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 7.56 µs 8.21 µs 🔴 +9%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 6.17 µs 6.69 µs 🔴 +8%
…and 6 more

📈 Full interactive perf-dashboard & run details →

@mattleibow

Copy link
Copy Markdown
Contributor Author

Superseded by the staged split.

The Apple-native foundation is now isolated in #4745, while #4729 and mono/skia#345 continue in parallel. Once those prerequisites land, Apple MAUI and Android native views will proceed as separate parallel PRs; Android MAUI will be the final layer that enables the existing Graphite sample page on Android API 24+.

The runtime screenshots and exact cumulative source commit remain available here for carving and validating the later MAUI layers.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add native Graphite views and a .NET MAUI Graphite view

2 participants