Skip to content

Make GPU tests required; skip only when declared - #4575

Merged
mattleibow merged 32 commits into
mainfrom
mattleibow-gpu-test-skip-policy
Jul 31, 2026
Merged

mattleibow merged 32 commits into
mainfrom
mattleibow-gpu-test-skip-policy

Conversation

@mattleibow

@mattleibow mattleibow commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

GPU tests were written as "try to bring the backend up; if anything throws, Assert.Skip". That reads as caution but behaves as a coverage hole: a missing ICD, a null context, a DllNotFoundException from a broken binding and a genuine regression all produce the same green build. Two backends had been silently skipping in CI for months — ganesh-gl had a golden for macOS only, graphite-dawn had none at all — and nothing in the build said so.

This inverts the default. A GPU backend is required unless something declares otherwise, and a skip has to be a statement someone wrote down:

Mechanism Answers
GpuPolicy.RequiredOn (compiled-in table) Does this backend exist on this platform at all?
SKIASHARP_TEST_SKIP_GPU (env var, per CI leg) Can this particular agent run it today?

The table describes platforms; the env var describes agents. You never configure anything to make Metal skip on Windows — the table already says Metal is Apple-only. You do declare that a specific Windows pool has no software GL stack.

Anything not skipped must work. No device, no driver, no ICD, a null context or a broken binding is now a failure, and the message names the exact opt-out that would legitimise a skip.

What CI surfaced

Making backends required turned a set of invisible skips into visible failures — in CI, and on a real GPU once the tests actually ran. Five were real bugs, fixed here:

Bug Effect Fix
DllImport("libGL") / ("libX11") used the unversioned SONAMEs, which are linker symlinks shipped only in -dev packages Linux GL could never load; every GL test silently skipped libGL.so.1 / libX11.so.6
GlxContext.Destroy() never called XCloseDisplay — the binding wasn't even declared one leaked X11 connection per GPU test bind and call it
SKBlenderTest asserted exact colour equality between the blend-mode and blender paths llvmpipe returned #ff5e0000 vs #ff5d0000 raster stays exact; the GPU subclass allows ±1
Windows x86 had no Vulkan loader (the ICD script staged only win-x64) 21/25 Vulkan tests failed provision per-arch into System32/SysWOW64 plus both registry views
Win32VkContext built a Vulkan 1.0 instance (no ApplicationInfo) and set no MaxAPIVersion GRContext.CreateVulkan returned null on any device reporting 1.4, so the test's result depended on the agent's driver declare 1.1 on both the instance and MaxAPIVersion, as SilkVkContext already did

Three further gaps turned out to be environment limitations, not bugs, and are declared with the reason recorded inline:

One structural change came out of this: the .NET Framework leg is now two jobs, x64 and x86. SwiftShader's LLVM JIT can't resolve __chkstk in a 32-bit process, so software Vulkan crashes the host there while x64 runs the same suite green. GpuPolicy models the OS but not the architecture, so separate jobs are what let x86 skip Vulkan while x64 keeps it. It also makes any future x64/x86 divergence visible on its own leg. Mac Catalyst also stops being non-gating — it carried the repo's only continueOnError: true (from #3247), which is the same failure mode this PR exists to remove.

The trade-off

CI currently has no OpenGL and no Metal coverage, expressed as 14 declared opt-outs. That is not a regression — every one of them was already skipping silently. The difference is that they are now enumerable, each names its cause, and #4591 tracks closing them, including the investigation already done: Mesa mesa-dist-win verified working for Windows GL (blocked only on a package feed), Silk.NET.OpenGLES.ANGLE.Native verified broken (ships 32-bit binaries in runtimes/win-x64/ in every published version), and the WebGPU flag matrix above.

Also in here

The visual-regression harness had grown vocabulary and machinery that did not survive review:

  • The TRX markers were inconsistent and one was actively wrong — ##SKIA-GOLDEN-IMAGE## carried the actual image, and ##SKIA-VISUAL-IMAGE## conflated golden and diff behind a path suffix. Now ##SKIA-VISUAL-ACTUAL## / -GOLDEN## / -DIFF##, one role each, sharing one path.
  • An outcome= field and a ##SKIA-VISUAL-CELL## marker stated what the markers already imply. Both gone, along with the harvest script's outcome grouping; --failures-out became --images-out, since it was never only failures.
  • Golden and diff are now emitted whenever a golden was found rather than only on a mismatch, so a near-miss ships its diff.
  • Non-standard jargon ("cell", "seam", "failure discipline") replaced with test / interfaces / golden / actual / diff.
  • GoldenTolerance was two dictionaries, a composite key and a three-branch lookup expressing "raster is strict, everything else isn't". It is now a ternary.

Related issues

Related to #4555, #4590, #4591, #4598, #4599, #4600, #4601

Required skia PR

None.

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

None — tests, CI and documentation only. No file under binding/ or source/ is touched, so there is no public API or behavioral change.

Testing

CI: all 16 test legs green on the mono-SkiaSharp pipeline (dnceng-public), builds 1533171 and 1533598 — Windows .NET Core, Windows .NET Framework x64 and x86, Nano Server, Linux, 4 Linux/Alpine containers, macOS, Mac Catalyst, iOS, Android, and both WASM legs.

Local (Windows x64, net10.0 and net48, plus the Vulkan and Direct3D satellites):

Suite Result
Non-GPU, non-Visual 5927 total, 0 failed, 16 skipped
Visual 25 total, 5 failed, 5 succeeded, 15 skipped
GpuPolicyTests guards 3/3

The 5 local visual failures are ganesh-gl on Windows, unseeded on this machine and declared opted-out in CI.

The Vulkan fix was verified against both relevant drivers, because the bug only appears on one of them: 25/25 pass on an AMD device reporting Vulkan 1.4.329 (which exposed it) and on the SwiftShader build CI pins, reporting 1.3.0 (which hid it). CI's ICD was reproduced locally by downloading the exact package install-vulkan-icd.ps1 pins and checking its SHA-256. Each half of the fix was isolated with a one-variable build: instance 1.0 + no MaxAPIVersion fails, instance 1.0 + MaxAPIVersion 1.1 fails, instance 1.1 + no MaxAPIVersion fails, both together pass.

Opt-out parsing was verified empirically rather than by inspection — GANESH-GL, ganesh-gl, all, ALL, a;b and " a , b " are all accepted; raster and any typo throw; and SKIASHARP_TEST_SKIP_GPU=all yields 25 total / 0 failed / 5 raster passed / 20 skipped, confirming it is a genuine escape hatch that spares the CPU backend. Both opt-out sources name themselves correctly: the env var path reports via SKIASHARP_TEST_SKIP_GPU, and a -p:SkiaSharpTestSkipGpu build reports via SkiaSharp.Tests.SkipGpu after the value lands in runtimeconfig.json.

Marker round-trip was verified end to end with a golden deliberately swapped to force a mismatch:

ganesh-gl.windows/   *.actual.png only            ← no golden committed (unseeded)
raster.windows/      *.{actual,golden,diff}.png   ← compared
                     FilledCircle: golden 4 323 B vs actual 4 711 B   ← the mismatch
                     Text:         golden 4 323 B vs actual 4 323 B   ← a clean pass

Seeding (--dry-run) yields the same goldens as before the rename, and SAFE_PATH_RE was attacked with 20 hostile inputs (.., absolute paths, drive letters, UNC, backslashes, NUL, trailing newline) — all blocked.

Known flaky, unrelated to this PR: a family of GC-lifetime tests (SKTypefaceTest.GCStillCollectsTypeface, SKTypefaceTest.StreamLosesOwnershipAndCanBeGarbageCollected, SKColorSpaceTest.ColorSpaceIsNotDisposedPrematurely, SKDocumentTest.StreamIsNotCollectedPrematurely) intermittently fails. BaseTest.CollectGarbage documents this by name. Verified by stashing this branch's changes and re-running: the unmodified branch flakes identically, with a different member of the family each time.

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? Filed a docs issue in mono/SkiaSharp-API-docs so reference docs can be written later — n/a, no public API change
  • Native change? Companion mono/skia PR linked above and bindings regenerated — n/a, no native change

Every GPU code path in the test suite was written as "try to bring up the
backend; if anything throws, Assert.Skip". That made a genuine regression -- a
broken P/Invoke, a GRContext factory that starts returning null, a CI
provisioning step that silently stopped working -- indistinguishable from "this
agent has no GPU", so CI stayed green while coverage evaporated.

The committed goldens are the receipt: ganesh-gl had a golden for macOS only
(Windows and Linux had been skipping), and graphite-dawn had none at all.

Replace the catch-and-skip with a declared four-state model in GpuPolicy. Only
one state can fail, and only one is configured:

  Required     built and expected here    -> any failure is a test failure
  Disabled     opted out for this agent   -> SKIASHARP_TEST_SKIP_GPU
  Unsupported  API does not exist here    -> compiled in, never configured
  NotBuilt     API exists, we don't ship  -> compiled in, never configured

The matrix describes platforms; the environment variable describes agents.
Nothing about a platform's inherent capabilities is expressed as configuration:
Metal on Windows and Vulkan on macOS need no setup to skip. Each backend
declares ExistsOn and BuiltOn, with BuiltOn mirroring the gn args in
native/*/build.cake, so enabling macOS Vulkan later is a one-token change.

IRenderer.IsAvailable/UnavailableReason become a single Backend property and
RendererUnavailableException is deleted -- it existed only to launder failures
into skips. SKTest.CreateGlContext, VKTest, Direct3DTest and
SKGraphiteReleaseTestsBase now gate on the policy and let exceptions escape.
Failure messages carry GpuPolicy.OptOutHint so a red test names the exact
directive that would legitimise a skip.

The hidden TF_BUILD + x64 Metal sniff in the renderers is replaced by a visible
uname -m check in the macOS, iOS and Mac Catalyst CI legs. It is the only
pre-set opt-out, and it exists to avoid a two-hour shutdown hang on the
virtualized x64 Metal driver, not to hide a failure.

Device and browser hosts cannot read the agent environment, so the same value
reaches them as -p:SkiaSharpTestSkipGpu -> runtimeconfig -> AppContext.

GpuPolicyTests emits a ##SKIA-GPU-POLICY## line per backend into every TRX, so
each leg records which backends it required and why the rest were skipped. That
report is what makes a skip auditable.

Expect several legs to go red on the first run -- that is the point. Each
failure is coverage that was already missing and is now visible, and each comes
with the opt-out directive if the gap turns out to be legitimate.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
@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 -- 4575

PowerShell / Windows:

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

Step 2 — Add the local NuGet source

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

iOSExtensionsTests.GRContextDisposeDoesNotCrash still skipped when
MTLDevice.SystemDefault was null -- the exact pattern this change removes, just
in the iOS device host rather than the shared harness. Metal is Required on
every Apple platform, so a missing device there is a red test.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

📊 SkiaSharp benchmarks — PR #4575

⭐ 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 — 🔴 33 slower · 🟢 29 faster

  • 🟢 RuntimeEffectShaderBenchmark.DrawFrame · Windows · 1.15 ms → 771.49 µs (-33%)
  • 🟢 ColorMathBenchmark.UnPreMultiply(Colors: 4096) · Windows · 12.35 µs → 8.72 µs (-29%)
  • 🟢 ColorMathBenchmark.ToColor(Colors: 4096) · Linux · 15.35 µs → 11.67 µs (-24%)
  • 🟢 BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) · macOS · 259.20 µs → 200.09 µs (-23%)
  • 🔴 RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) · Windows · 100.12 µs → 121.87 µs (+22%)
  • …and 57 more (see details below)
Full per-OS benchmark deltas

Linux

⏱️ Time (vs 🌙 nightly 4.151.0-nightly.110)

Benchmark baseline this PR Δ
ColorMathBenchmark.ToColor(Colors: 4096) 15.35 µs 11.67 µs 🟢 -24%
MatrixMapPointsBenchmark.MapRect(Points: 4096) 180.00 µs 204.87 µs 🔴 +14%
MatrixMapPointsBenchmark.MapRect(Points: 256) 11.25 µs 12.78 µs 🔴 +14%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 13.61 µs 15.39 µs 🔴 +13%
ColorMathBenchmark.PreMultiply(Colors: 4096) 12.85 µs 14.51 µs 🔴 +13%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 4.51 µs 5.08 µs 🔴 +13%
MatrixOpsBenchmark.Invert(Count: 4096) 133.35 µs 149.84 µs 🔴 +12%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 11.45 µs 12.86 µs 🔴 +12%
MatrixOpsBenchmark.Concat(Count: 4096) 219.48 µs 245.35 µs 🔴 +12%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 73.90 µs 81.73 µs 🔴 +11%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 173.02 µs 189.88 µs 🔴 +10%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 105.77 µs 115.77 µs 🔴 +9%
MatrixMapPointsBenchmark.MapVector(Points: 256) 10.96 µs 11.80 µs 🔴 +8%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 228.63 µs 246.33 µs 🔴 +8%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.66 ms 2.86 ms 🔴 +7%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 685.78 µs 735.98 µs 🔴 +7%
PathBoundsBenchmark.TightBounds(Points: 1024) 10.53 µs 11.29 µs 🔴 +7%
RuntimeEffectShaderBenchmark.DrawFrame 2.82 ms 3.02 ms 🔴 +7%
ColorMathBenchmark.ToColorF(Colors: 4096) 13.12 µs 14.04 µs 🔴 +7%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 354.75 µs 377.67 µs 🔴 +6%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 250.45 µs 265.24 µs 🔴 +6%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 7.64 ms 8.08 ms 🔴 +6%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.34 ms 1.41 ms 🔴 +5%

Windows

⏱️ Time (vs 🌙 nightly 4.151.0-nightly.110)

Benchmark baseline this PR Δ
RuntimeEffectShaderBenchmark.DrawFrame 1.15 ms 771.49 µs 🟢 -33%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 12.35 µs 8.72 µs 🟢 -29%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 100.12 µs 121.87 µs 🔴 +22%
ColorMathBenchmark.PreMultiply(Colors: 4096) 13.23 µs 10.46 µs 🟢 -21%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 1024) 2.63 ms 2.15 ms 🟢 -18%
ColorMathBenchmark.ToColor(Colors: 4096) 14.30 µs 11.69 µs 🟢 -18%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 76.03 µs 63.26 µs 🟢 -17%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 10.19 ms 8.56 ms 🟢 -16%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 4.87 µs 4.09 µs 🟢 -16%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 246.62 µs 209.25 µs 🟢 -15%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 906.34 µs 771.64 µs 🟢 -15%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 2.66 µs 2.28 µs 🟢 -14%
ColorParseBenchmark.Parse(Iterations: 1000) 76.59 µs 65.82 µs 🟢 -14%
CanvasDrawBenchmark.Draw(Shapes: 64) 2.66 ms 2.28 ms 🟢 -14%
MatrixMapPointsBenchmark.MapRect(Points: 256) 7.96 µs 6.84 µs 🟢 -14%
CanvasDrawBenchmark.Draw(Shapes: 512) 21.10 ms 18.21 ms 🟢 -14%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 248.64 µs 276.40 µs 🔴 +11%
MatrixOpsBenchmark.Concat(Count: 4096) 224.50 µs 200.06 µs 🟢 -11%
MatrixOpsBenchmark.Invert(Count: 4096) 130.92 µs 118.56 µs 🟢 -9%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 337.44 µs 306.07 µs 🟢 -9%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 131.09 µs 119.43 µs 🟢 -9%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.23 ms 1.13 ms 🟢 -8%
PathBoundsBenchmark.TightBounds(Points: 1024) 15.84 µs 14.65 µs 🟢 -8%
ColorMathBenchmark.ToColorF(Colors: 4096) 13.37 µs 14.30 µs 🔴 +7%
PathBoundsBenchmark.TightBounds(Points: 64) 1.54 µs 1.44 µs 🟢 -7%
…and 3 more

macOS

⏱️ Time (vs 🌙 nightly 4.151.0-nightly.110)

Benchmark baseline this PR Δ
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 259.20 µs 200.09 µs 🟢 -23%
CanvasDrawBenchmark.Draw(Shapes: 512) 11.15 ms 13.29 ms 🔴 +19%
ColorMathBenchmark.ToColor(Colors: 4096) 18.60 µs 21.71 µs 🔴 +17%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 195.25 µs 165.46 µs 🟢 -15%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 63.47 µs 72.96 µs 🔴 +15%
ColorMathBenchmark.ToColorF(Colors: 4096) 4.92 µs 5.57 µs 🔴 +13%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 1.56 µs 1.75 µs 🔴 +12%
CanvasDrawBenchmark.Draw(Shapes: 64) 1.40 ms 1.57 ms 🔴 +12%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 131.8 ns 147.1 ns 🔴 +12%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 641.53 µs 600.58 µs 🟢 -6%
ColorMathBenchmark.PreMultiply(Colors: 4096) 8.38 µs 8.89 µs 🔴 +6%

📈 Full interactive perf-dashboard & run details →

Nano Server is now its own platform in the matrix. It runs a different native
build -- native/nanoserver/build.cake passes supportVulkan=false and
supportDirect3D=false -- so Vulkan and Direct3D are absent from libSkiaSharp.dll
there even though the OS is Windows. The matrix previously inherited the plain
Windows row and would have marked both Required. Not reachable today (the Nano
leg runs only the Console suite, which has no Vulkan/D3D tests), but the matrix
is the load-bearing artifact of this change and has to be factually right.
OpenGL stays Required there: it IS built for Nano, so a container with no
driver is an agent problem, which is the tier-3 case.

Normalise the opt-out list to commas before forwarding it. GpuPolicy documents
comma, semicolon or whitespace separators, but neither cake forwarding path
survived the last two: a space splits the /p: into two process arguments, and a
semicolon is MSBuild's own property-list separator. Only commas reached the test
host, so anyone following the documented contract by hand would have got a
broken build.

Drop the Trim metadata from the RuntimeHostConfigurationOption. ILLink collects
every option marked Trim=true as a feature switch and parses its value as a
bool; this one holds a backend-id list. Dormant today (no test project enables
trimming) but a latent landmine, and Trim metadata does not affect
runtimeconfig.json generation, so it bought nothing.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
@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.

The macOS test leg failed before running a single test:

    MSBUILD : error MSB1006: Property is not valid.
    Switch: graphite-metal

MSBuild's -p: switch splits on commas as well as semicolons, so the
/p:SkiaSharpTestSkipGpu=ganesh-metal,graphite-metal that RunDotNetTest built by
hand parsed as two properties. Confirmed directly: `-p:Foo=a,b` gives MSB1006
while `-p:Foo=a` evaluates fine.

RunDotNetTest never needed the property. Its test process is a child of the cake
process, so it already inherits SKIASHARP_TEST_SKIP_GPU and GpuPolicy reads it
straight from the environment; and with NoBuild=true no runtimeconfig.json is
regenerated, so the property was a no-op even when it parsed. Only the device and
browser hosts need it, and that path goes through Cake's DotNetMSBuildSettings,
which quotes the value properly -- proven by the iOS and Mac Catalyst legs, which
both applied the two-backend opt-out correctly.

Also drop the generic Vulkan sentence from the SharpVk not-built reason. On Linux
it read "Vulkan is not built for this host: the Apple builds have no MoltenVK..."
when Vulkan is in fact built there and only the SharpVk vehicle is Windows-only.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Artifact size report

Packages from this PR (build 1533903) vs the latest nightly baseline 4.151.0-nightly.110 (observed 2026-07-30).

Total .nupkg size: 569.1 MB → 568.6 MB (−473.0 KB, -0.1%)

Packages

⚠️ marks growth over 500.0 KB or 2%. Changes under 50.0 KB are treated as noise.

Package baseline this PR Δ Δ%
SkiaSharp.NativeAssets.WinUI 108.8 MB 108.2 MB 🟢 −574.6 KB -0.5%

+39 package(s) unchanged (< 50.0 KB).

Per-file changes

SkiaSharp.NativeAssets.WinUI

File Size
runtimes/win-x64/native/libGLESv2.pdb 66.6 MB → 66.5 MB (🟢 −112.0 KB)
runtimes/win-x86/native/libGLESv2.pdb 67.3 MB → 67.2 MB (🟢 −96.0 KB)
runtimes/win-arm64/native/libGLESv2.pdb 64.5 MB → 64.4 MB (🟢 −64.0 KB)

Informational only — this never blocks the PR. Native binaries are labelled by os/arch.

web-flow and others added 20 commits July 29, 2026 15:48
Replaces the uname -m sniff added earlier with a declarative mechanism. The
script was the same mistake as the TF_BUILD sniff it replaced -- inferring a
policy at runtime, and silently adapting if the pool changed instead of failing
loudly. What a host can do is now stated up front in the pipeline definition.

Adds an `env:` parameter to azure-templates-jobs-bootstrapper.yml that flows to
all four bootstrapper invocations: the Windows and non-Windows direct runs (via
the step env) and both Docker runs. Containers inherit nothing from the agent,
so the env is materialised into an env-file and passed to `docker run
--env-file`; the file is always written, empty when nothing is declared, so the
run command stays uniform. This is generic infrastructure -- nothing about it is
GPU-specific.

Corrects the Metal opt-out scope. macOS and Mac Catalyst drive real Metal on the
x64 pool and passed CI, so they are no longer opted out. Only the iOS leg is,
because it runs the *simulator*, whose virtualized Metal leaves dispatch-queue
state that hangs the test host on shutdown.

Declares ganesh-gl opt-outs for the five container legs. Those images have no X
server, no Mesa and no ICD, so OpenGL genuinely cannot come up there.

Fixes two P/Invoke library names that were the actual cause of the Linux and
container GL failures. DllImport("libGL") and DllImport("libX11") probe the
unversioned .so, which is a linker symlink shipped only in the -dev packages; a
runtime-only host has libGL.so.1 and libX11.so.6 and nothing else. So the Linux
leg was failing to load Mesa even though CI provisions it correctly, and had
been silently skipping that cell for as long as the harness existed.

Provisions the software Vulkan ICD for x86 as well as x64. The .NET Framework
leg runs the suite once per bitness and a 32-bit process cannot load a 64-bit
vulkan-1.dll, so x86 Vulkan had no loader at all: CI showed 25/25 passing on x64
and 21/25 failing on x86. Bitness resolution is delegated to Windows the way the
official Vulkan Runtime installer does it -- loader into System32 and SysWOW64,
each ICD manifest registered in the matching registry view -- because PATH
cannot disambiguate two files with one name.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The Windows agents have no GPU driver, so Windows falls back to the GDI generic
OpenGL 1.1 implementation, which advertises no WGL_ARB_* extensions and cannot
satisfy WglContext. Declared as an opt-out rather than left red, since there is
no fix available to land today.

This is a provisioning gap, not a platform limit, and the gap is documented so
it does not quietly become permanent: Mesa's llvmpipe would fix it with no
test-code change (its WGL extension string statically advertises both
WGL_ARB_pixel_format and WGL_ARB_pbuffer, and it reports
WGL_FULL_ACCELERATION_ARB), but there is no trustworthy feed for Mesa's Windows
binaries yet. Silk.NET ships no desktop-GL package, and its ANGLE package is
unusable -- every published version has 32-bit binaries in runtimes/win-x64.

Vulkan and Direct3D stay required on Windows: CI showed both working, 25/25 and
5/5 respectively.

Also documents the complete set of declared CI opt-outs in gpu-test-policy.md,
so what each leg can and cannot do is discoverable without reading the pipeline.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The policy is a lookup table and one Assert.Skip; it did not need 611 lines
across four files. Now 280 across two, with no behaviour change.

Collapses GpuBackend.cs, TestPlatforms.cs and GpuPolicy.cs into one file. Drops
the GpuAvailability enum in favour of the state token the report already needed,
which removes the enum, its doc block and the token mapper. Replaces the Entry
class and its constructor with a tuple array, so a backend row is one line.

Generates the skip reasons from the id and platform name rather than storing a
hand-written paragraph per backend. The detail those paragraphs carried -- which
gn arg to flip, which file to edit -- belongs in gpu-test-policy.md, where it is
already written, not repeated in every skip message.

Trims the call-site comments. "No catch: the policy already decided" appeared at
seven sites; the rule is stated once on IRenderer and once in the doc, so the
repetitions were noise next to a self-evident RequireOrSkip call. Also drops a
stale <see cref="GpuAvailability.Required"/> and the duplicated policy paragraph
from the two Vulkan renderers.

Verified identical behaviour: same policy report, same typo-guard error, and the
same 6092 tests with the same 2 pre-existing failures.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The policy still carried more machinery than the decision it makes. A GPU test
either skips with a reason, fails, or passes; everything else was ceremony.

Replaces the GpuBackend enum with GpuBackends string consts. The enum and the id
string were the same fact twice, with Id() and Find() only to map between them --
and every renderer declared both, since IRenderer.Name was documented as equal to
the id. So IRenderer.Backend is gone entirely and the matrix gates on Name.

Replaces the ExistsOn/BuiltOn pair with a single Dictionary<string, TestPlatforms>
of where each backend must work. ExistsOn was read in exactly one place, to
choose between "does not exist on" and "is not built for" -- a whole platform set
per row to pick a verb. The surviving reason, "'ganesh-metal' is not required on
windows", is complete; why it is not required belongs in the doc's table, is not
actionable at a skip, and was the same per-row prose the previous pass deleted.

Moves TestPlatforms and platform detection to TestConfig, which already owns
IsWindows, IsApple and IsNanoServer. Neither is a GPU concept, and this removes a
third copy of the same #if ladder: VisualPlatform hand-wrote the identical probe
order to build golden directory tags, and its strings map exactly onto the enum
names, so it now derives from TestConfig. Golden tags verified byte-identical
before and after -- that path decides which reference PNG a cell compares to.

Drops the messaging helpers. OptOutHint appended "here is how to opt out" to
eleven failure messages; the exception already says what broke. Describe() and
the ##SKIA-GPU-POLICY## marker duplicated what xUnit already publishes, since a
skipped test carries its reason into the same TRX. OptOutSource, the state token
and the Cpu special case go with them.

Drops Lazy for plain static readonly fields. The runtime already gives the
guarantee the Lazy was hand-rolling: a throwing static initializer caches a
TypeInitializationException that every later access rethrows, so a malformed
opt-out list still fails every GPU test identically. Verified the message is
still legible through the wrapper. Startup cost is irrelevant here.

Public surface is now two consts, RequireOrSkip and Validate. GpuPolicy.cs goes
from 241 lines to 131, and a new test asserts every renderer name is a known id,
catching drift the enum could not express.

Behaviour verified unchanged: 5927 non-GPU tests still pass with 16 declared
skips, the visual matrix still reports 25/5/5/15, golden tags are identical,
=all still spares raster, and the typo guard still names the valid ids.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
Deletes documentation/dev/gpu-test-policy.md. The policy is a table and one
skip; it does not need a page of its own, and the visual matrix is the main
consumer, so the table, the opt-out syntax, the CI opt-out list and the Windows
software-GL gap now live in golden-image-tests.md.

Merges SkipReason into RequireOrSkip -- SkipReason had no other caller once the
report was gone.

Replaces Validate() with a public Disabled(). Validate read disabled.Count to
force a static initializer, which reads as counting a set that obviously cannot
throw; the throw came from class init. Disabled() parses on each call and throws
directly, so the typo guard is now a plain InvalidOperationException instead of
one wrapped in TypeInitializationException, and the static-init ordering
constraint is gone. Tests do not need the cache.

Uses the GpuBackends consts for every renderer Name, which were still literals.

Rewrites comments that told a story rather than describing the code as it is:
the simulator Snap() note said what it "used to be", the Vulkan ICD header
narrated the x86 gap as a discovery, test-shared.cake explained what it was
deliberately not doing, and Directory.Build.targets did the same for Trim
metadata. Also drops comments that only restated the call below them, and fixes
two that referenced the removed Unsupported state.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
660 lines across one file becomes 281 across two, and the content now matches
the code.

Splits the GPU policy into its own 77-line page. It gates five test families --
the visual matrix, the GL, Vulkan and Direct3D tests, and the Graphite release
tests -- so scoping it under "golden image tests" was wrong. The previous policy
page was deleted for length, not for existing; this one is a table, an opt-out
syntax and a pointer to the pipeline.

Presents raster, Ganesh and Graphite as three equal families. The old text
described Graphite as in-flight, including a whole "Graphite seam" section that
was a rebase plan for a PR that has since landed, and per-host tables that listed
Graphite renderers as follow-ups.

Corrects claims that no longer held:

  * "every cell emits its PNG on pass and fail" was wrong in the case that
    matters -- RenderAsync runs before the marker is emitted, so a render failure
    emits nothing. The lifecycle section now says which outcomes carry an image.
  * "compared strictly" -- comparison is tolerance-based, always.
  * golden lookup is three-deep on Nano Server (nanoserver, windows, shared),
    not two.
  * GpuRenderGate does not exist; serialization is an xUnit collection.
  * there is no Direct3D visual renderer, so the coverage table invented one.
  * VisualPlatform.Tag is Tags, the tag list omitted nanoserver, and Linux GL is
    GLX rather than "GLX/EGL".
  * the Desktop/ folder rule claimed to cover Metal, which is shared.

Replaces the host coverage matrix, which conflated compiled, required and seeded
and drifted immediately, with the renderer list plus a pointer to the policy
table and the goldens directory. Merges three overlapping seeding sections into
one, and drops the storage, tolerance and CI rationale essays.

Also removes a dead "direct3d" key from GoldenTolerance -- no renderer has that
name -- and the Ganesh entries that only restated the fallback, leaving raster as
the one special case.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 03c0625a-14f0-4a6c-a1f6-b02ac5f8701a
The TRX markers used three inconsistent names and one was actively wrong:
##SKIA-GOLDEN-IMAGE## carried the *actual* rendered image, not the golden,
and ##SKIA-VISUAL-IMAGE## conflated the golden and the diff, distinguishing
them by a suffix baked into the path.

Rename to one role per marker, all sharing the golden key as their path:

  ##SKIA-VISUAL-ACTUAL## path=... outcome={pass|mismatch|unseeded} size=... base64=...
  ##SKIA-VISUAL-GOLDEN## path=... size=... base64=...
  ##SKIA-VISUAL-DIFF##   path=... size=... base64=...

This drops ##SKIA-VISUAL-CELL## by folding the verdict onto the actual image.
The verdict cannot be derived from the images alone -- a pass and an unseeded
test both emit only an actual -- so it still has to be stated, but it no longer
needs a marker of its own. Emitting it means the actual image now goes out
after the comparison rather than before.

The harvest script loses a regex, a dict and the key-mangling that rebuilt
'{scene}.golden.png' to look images up; the three roles are now just three
dicts keyed by the same path.

Vocabulary: 'cell' -> 'test', 'seam' -> 'interfaces', and 'lifecycle' /
'discipline' headings replaced with plain descriptions.

Verified: visual suite 25 total / 5 failed / 5 succeeded / 15 skipped
(unchanged); a forced mismatch emits all three markers and the script writes
actual+golden+diff into mismatch/ with correct bytes; seeding dry-run yields
the same 10 goldens; full non-GPU suite 5927 / 0 failed / 16 skipped.
The outcome= field on the actual-image marker duplicated what the markers
already imply. No golden marker means no golden was committed; a diff only
exists when there was something to diff against. The test result and its
message say whether a comparison passed -- the harvest script does not need
to re-derive that.

So drop the field, and emit the golden and diff whenever a golden was found
rather than only on a mismatch. A pass at 99.5% now ships its diff too, which
is the case actually worth eyeballing.

This deletes the outcome grouping in extract-visual-goldens.py: it no longer
sorts into unseeded/ and mismatch/, it just writes what it found, mirroring
the goldens tree as {renderer}.{platform}/{scene}.{actual,golden,diff}.png.
A scene with only an .actual.png had no golden. Renamed --failures-out to
--images-out to match, since it was never only failures.

Verified: with a forced mismatch, ganesh-gl.windows extracts 5 actual-only
images (unseeded) and raster.windows extracts actual+golden+diff for all 5,
the mismatch showing golden 4323 B against actual 4711 B. Seeding dry-run
unchanged at 10 goldens. Visual suite 25/5/5/15, full non-GPU suite
5927 / 0 failed / 16 skipped. YAML parses.
Two dictionaries, a composite string key and a three-branch lookup existed to
express 'raster is strict, everything else is not'. ByRendererScene was empty
and ByRenderer held a single entry, since the ganesh-* rows only restated the
fallback and the direct3d row named a renderer that does not exist.

Now it is a ternary, and sceneName leaves the signature because nothing read
it. If a scene ever needs its own tolerance, special-case it then.

Visual suite unchanged at 25/5/5/15.
Both said a missing display or ICD makes the GPU tests skip and that the
provisioning 'never turns the build red'. Under this policy ganesh-gl and
ganesh-vulkan are required on Linux, so missing provisioning fails.
A review against the code turned up five statements this change falsifies:

  * AGENTS.md said tests never skip 'except missing hardware' -- missing
    hardware is now precisely what fails.
  * native-dependency-update and update-skia (twice) told the reader that
    backends self-skip when unavailable.
  * golden-image-tests.md suggested special-casing a single scene in
    GoldenTolerance.For, which takes only the renderer name.
Graphite landed in #3968 and skia_enable_graphite=true on every platform, with
Vulkan on Windows/Linux/Android, Metal on Apple and Dawn on WASM. Six skills
still told the reader to filter those changes out:

  * security-audit classed Graphite, Vulkan and Dawn as NOT_REACHABLE compile
    flags 'we don't use', which would dismiss a live CVE. It now points at the
    gn args in native/*/build.cake instead of naming a fixed list.
  * update-skia scored Graphite changes as SKIP, marked skgpu::graphite:: and
    Dawn/wgpu as irrelevant, and framed shared GpuTypes.h changes as a
    Graphite-only trap rather than a change reaching both families.
  * skia-analyst excluded Graphite and Dawn changes outright.
  * sample-scout classified any file naming Graphite or Dawn as low and called
    Graphite 'not SkiaSharp'. Backend-internal GMs are still low; the test is
    now whether it exercises internals, not which backend it names.
  * api-docs used 'Vulkan (not yet supported)' as a formatting example.

Also documents the container legs' ganesh-gl opt-out, which this branch added
to five legs without saying so in containerized-testing.md.
The previous pass flipped 'exclude Graphite, we use Ganesh' into 'include
Graphite', which is the same mistake with the sign changed: naming one backend
as included implies the others are not, and the guidance still had to be
rewritten every time a backend lands. It also introduced three false claims --
skia_enable_graphite is not set on Tizen and is conditional on WASM, Nano Server
builds with Vulkan and Direct3D off, and Vulkan is not deprecated.

Rewritten around the real criteria instead:

  * update-skia's risk table categorises kinds of change, so the backend row is
    simply gone -- a GPU change is already Removed/Renamed/New/Behavior.
  * the relevance table now says relevance is whether our C API or a shipped
    build touches the code, and folds the four GPU prefixes into one row that
    points at native/*/build.cake rather than asserting a platform map.
  * skia-analyst just drops the exclusions: what is not excluded is included.
  * security-audit's NOT_REACHABLE names no backend at all. It asks for the
    platform and the flag, and notes a flag off in one build is often on in
    another -- which is the actual trap.
  * sample-scout keeps 'is it backend internals?' and drops the platform list.

Also fixes a pre-existing scope error: the 'full test suite' command ran
SkiaSharp.Tests.Console.csproj, which references neither the Vulkan nor the
Direct3D project, while claiming to run all three. It now runs the solution.
It was the only continueOnError: true in the repo (from #3247). A leg that
cannot turn the build red cannot report a regression either, which is the same
failure mode this branch exists to remove. The bootstrapper already defaults
the parameter to false, so deleting the line is the whole change.

Mac Catalyst has no graphite-metal.maccatalyst goldens, so this is expected to
surface as an unseeded failure until they are harvested.
Two findings from a review pass, both latent rather than live:

The bootstrapper's env: values were pasted into the generated shell and
PowerShell as source text, so a quote in a value would break out of the string,
and the file was cat'd to the build log before every containerised run. The
values are ours and are backend ids today, but the parameter is generic. Values
now travel in the step's own environment and are read at runtime, the contents
are no longer printed (the step's displayName already names the key), and the
file is removed in an always() step. Verified on both shells with a value
containing a double quote, dollar, backtick, apostrophe and %s.

SAFE_PATH_RE anchored with \$, which in Python also matches before a trailing
newline, so 'a/x.png\\n' passed the guard. Unreachable today because the marker
regex captures [^\\s]+, but the guard should not depend on its caller. Anchored
with \\Z instead.

Verified: 20 attack paths still blocked, valid keys still allowed, visual suite
25/5/5/15, extraction 20 images, seeding 10 goldens.
The published TRX from build 159115 shows graphite-dawn failing on both WASM
legs with 'navigator.gpu.requestAdapter returned null - WebGPU is unavailable in
this browser'. That is a hard failure, not a missing golden, so no amount of
harvesting turns it green.

The headless browser is launched by the DeviceRunners CLI, whose 'wasm test'
command accepts only --app, --results-directory, a logger, a filter and a
timeout. There is no browser-argument passthrough, so the WebGPU flags cannot be
supplied without an upstream change to that preview package.

Declared rather than left red, with the reason and the blocker recorded at the
opt-out. The gap is now named instead of being an invisible skip, which is the
point of the policy.
Three things CI surfaced once GPU backends became required. All three are
pre-existing; this branch only made them visible.

GlxContext.Destroy() released the context, the GLX pixmap and the pixmap, then
dropped the display handle without calling XCloseDisplay -- Xlib.cs did not even
bind it. Every GPU test builds a context, so a run leaked one X11 connection per
test along with the driver state behind it. The Linux leg then died with exit
code 7 partway through SKBitmapThreadingTest, the one test that deliberately
stresses allocation. WglContext and CglContext both release properly; GLX was
the outlier.

SKBlenderTest asserted that the blend-mode and blender paths produce an
identical colour. They are different shaders on a GPU and round independently:
llvmpipe returned #ff5e0000 and #ff5d0000 for Luminosity. Raster keeps exact
equality; the GPU subclass now allows one unit per channel, well under the 12
the golden comparison already allows.

Mac Catalyst cannot run Metal at all: a Catalyst app sees iOS-style GPU
families, never Mac2, so the device satisfies neither Ganesh nor Graphite and
bring-up throws. Declared as an opt-out with that reason recorded.

Verified: blend tests 232/232 (raster exact, GPU tolerant), non-GPU suite
5927 / 0 failed, visual unchanged at 25/5/5/15. The GLX fix is Linux-only and
cannot be exercised from this host.
The macOS test job hung for 168 minutes with no output and was killed at the
180 minute timeout, publishing no TRX at all -- so the whole leg was lost, not
just its Metal tests.

The cause was already known and documented in the renderers this branch
rewrote. GaneshMetalRenderer carried an IsAzureDevOpsX64Host check (TF_BUILD
plus OSArchitecture == X64) that short-circuited before touching Metal, because
'the mere act of calling MTLCreateSystemDefaultDevice + newCommandQueue on that
device leaves state that hangs the test host's post-session shutdown for 2h+'.
GraphiteMetalRenderer deferred to the same reasoning. Removing that sniff was
deliberate -- runtime detection is what this branch replaces -- but the
declaration that should have taken its place was missed for macOS, so the
observed 168 minutes is that comment coming true.

Declared per the policy, with the reason recorded at the opt-out. All three
Apple legs now opt out of Metal, which means CI has no Metal coverage at all;
issue #4555 has been broadened from the narrow iOS-simulator gradient bug to
track that, including the shutdown hang and the Catalyst GPU-family gap.
SKTest already exposes AssertSimilarColor(expected, actual, tolerance) with the
same per-channel logic and better failure messages. The private helper added
alongside the GPU tolerance duplicated it; SurfaceTestBase derives from SKTest,
so it was already in scope.

Blend tests unchanged at 232/232 -- raster exact, GPU within one unit.
@mattleibow
mattleibow requested a review from Copilot July 30, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Human review recommended

It makes broad, cross-cutting changes across test infrastructure, CI provisioning, and platform gating that warrant final human review despite only minor fixups identified.

Pull request overview

This PR tightens SkiaSharp’s test/CI posture by making GPU backends required by default and only skippable through an explicit, declared policy (GpuPolicy.RequiredOn + SKIASHARP_TEST_SKIP_GPU / AppContext), eliminating “catch-and-skip” coverage holes. It also simplifies and standardizes the visual-regression TRX markers and updates CI provisioning and documentation to match.

Changes:

  • Introduces GpuPolicy/GpuBackends + TestPlatforms/TestConfig.Platform to centralize “required vs. skipped” GPU decisions and remove runtime “probe-and-skip” patterns.
  • Updates visual-regression harness + extractor to emit role-specific TRX markers (ACTUAL/GOLDEN/DIFF) and to support CI-friendly image extraction.
  • Adjusts CI templates and provisioning (notably Windows Vulkan loader + opt-outs) so missing GPU stacks become explicit declarations rather than silent skips.
File summaries
File Description
tests/VulkanTests/VKTest.cs Gates Vulkan context creation via GpuPolicy instead of try/catch skip.
tests/VulkanTests/Visual/VulkanVisualTests.cs Renames harness entrypoint to RunTestAsync and updates docs.
tests/VulkanTests/Visual/GraphiteVulkanRenderer.cs Removes availability probing/skip conversion; uses policy-gated hard failures.
tests/VulkanTests/Visual/GaneshVulkanRenderer.cs Same as above for Ganesh/Vulkan renderer.
tests/VulkanTests/SKGraphiteReleaseVulkanTests.cs Switches release tests to backend-id gating and hard failures on bring-up.
tests/Tests/Utils/X11/Xlib.cs Uses versioned libX11.so.6 and adds XCloseDisplay P/Invoke.
tests/Tests/TestPlatforms.cs Adds a flags enum for host/platform identification.
tests/Tests/TestConfig.cs Adds Platform + PlatformName and centralized platform detection.
tests/Tests/SkiaSharp/Visual/VisualPlatform.cs Derives golden tags from TestConfig.Platform, with Nano Server fallback tags.
tests/Tests/SkiaSharp/Visual/Tests/VisualMatrixTestsBase.cs Moves to policy gating, new TRX markers, and RunTestAsync pipeline.
tests/Tests/SkiaSharp/Visual/Tests/VisualMatrixTests.cs Updates to call RunTestAsync.
tests/Tests/SkiaSharp/Visual/RendererUnavailableException.cs Deletes exception used for “skip via exception” flow.
tests/Tests/SkiaSharp/Visual/Renderers/RasterRenderer.cs Aligns renderer name with GpuBackends.
tests/Tests/SkiaSharp/Visual/Renderers/GraphiteMetalRenderer.cs Removes runtime skip paths; treats Metal bring-up failures as real failures.
tests/Tests/SkiaSharp/Visual/Renderers/GraphiteDawnRenderer.cs Makes WebGPU bring-up failures hard failures on required hosts.
tests/Tests/SkiaSharp/Visual/Renderers/GaneshMetalRenderer.cs Same as Graphite/Metal regarding runtime skip removal.
tests/Tests/SkiaSharp/Visual/Renderers/Desktop/GaneshGlRenderer.cs Removes catch-and-convert-to-skip GL bring-up behavior.
tests/Tests/SkiaSharp/Visual/RendererCatalog.cs Updates narrative for new “visual tests” terminology.
tests/Tests/SkiaSharp/Visual/IRenderer.cs Simplifies interface; removes IsAvailable/UnavailableReason and skip contract.
tests/Tests/SkiaSharp/Visual/GoldenTolerance.cs Simplifies tolerance selection to renderer-only.
tests/Tests/SkiaSharp/Visual/GoldenStore.cs Updates wording from “cell” to “test” and clarifies platform-only fallback.
tests/Tests/SkiaSharp/SKTest.cs Gates GL context creation through GpuPolicy.
tests/Tests/SkiaSharp/SKGraphiteReleaseTestsBase.cs Switches from UnsupportedReason to backend id + policy gating.
tests/Tests/SkiaSharp/SKGraphiteReleaseMetalTests.cs Uses policy gating and hard failures for Metal bring-up checks.
tests/Tests/SkiaSharp/SKGraphiteReleaseDawnTests.cs Uses policy gating and hard failures for Dawn bring-up checks.
tests/Tests/SkiaSharp/SKBlenderTest.cs Adds GPU-specific tolerance to avoid brittle exact equality on GPU paths.
tests/Tests/SkiaSharp/Gpu/GpuPolicyTests.cs Adds tests to ensure platform recognition and backend id consistency.
tests/Tests/SkiaSharp/Gpu/GpuPolicy.cs Introduces backend ids + required-platform table + opt-out parsing logic.
tests/Tests/SkiaSharp/GlContexts/Glx/GlxContext.cs Fixes X11 connection lifetime by closing display in Destroy().
tests/Tests/SkiaSharp/GlContexts/Glx/Glx.cs Switches to versioned libGL.so.1 for runtime hosts.
tests/SkiaSharp.Tests.Devices/Tests/iOS/iOSExtensionsTests.cs Uses GpuPolicy and treats missing Metal device as failure post-gate.
tests/SkiaSharp.Direct3D.Tests.Console/Direct3DTest.cs Gates Direct3D context creation via GpuPolicy.
tests/Directory.Build.targets Plumbs skip list into runtimeconfig/AppContext for device/browser hosts.
scripts/infra/tests/test-shared.cake Adds --skipGpu normalization and forwards it into MSBuild/device runners.
scripts/infra/tests/extract-visual-goldens.py Updates marker parsing; adds --images-out for CI triage extraction.
scripts/infra/native/windows/install-vulkan-icd.ps1 Provisions Vulkan loader+ICD for both x64 and x86 and registers both views.
scripts/azure-templates-stages-test.yml Declares backend opt-outs per leg and switches to --images-out extraction.
scripts/azure-templates-jobs-bootstrapper.yml Adds generic env: forwarding (including into Docker runs).
documentation/dev/README.md Links new GPU policy + golden-image test docs.
documentation/dev/gpu-test-policy.md Adds policy documentation for required vs skipped backends.
documentation/dev/golden-image-tests.md Refreshes harness docs to match policy + new marker scheme.
documentation/dev/containerized-testing.md Documents container GPU opt-out expectations under new policy.
AGENTS.md Updates contributor guidance to reflect declared GPU skips via GpuPolicy.
.agents/skills/update-skia/SKILL.md Updates validation guidance re: required GPU backends and solution-level test run.
.agents/skills/update-skia/references/validation-prompt.md Adjusts GPU change review prompts to include Graphite and Ganesh.
.agents/skills/update-skia/references/known-gotchas.md Updates test runner notes to match GpuPolicy behavior.
.agents/skills/update-skia/references/breaking-changes-checklist.md Fixes relevance guidance for GPU-related changes.
.agents/skills/skia-analyst/references/analysis-instructions.md Removes “exclude Graphite/Dawn” heuristics in analysis instructions.
.agents/skills/security-audit/references/skia-cve-resolution.md Clarifies reachability as per-platform build-flag dependent.
.agents/skills/sample-scout/references/analysis-instructions.md Refines “low interest” heuristics to focus on internals vs backend names.
.agents/skills/native-dependency-update/SKILL.md Updates test validation guidance to reflect required GPU backends.
.agents/skills/api-docs/references/patterns.md Updates an example summary string in API docs patterns reference.
Review details
  • Files reviewed: 52/52 changed files
  • Comments generated: 2
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread tests/Tests/SkiaSharp/Gpu/GpuPolicy.cs Resolved
Comment thread scripts/infra/tests/test-shared.cake Resolved
Three changes, two from PR review and one from the CI run.

The Linux leg still crashes with exit code 7 after the XCloseDisplay fix: four
retries died at 523, 312, 5068 and 0 tests with zero failures each time, and
none published a TRX, so the whole leg is lost rather than just its GL tests.
The cause is that the nine classes calling CreateGlContext() are in no xUnit
collection, so they create and destroy llvmpipe contexts concurrently -- only
the visual tests are serialised. That race was unreachable until this branch
fixed the libGL SONAME. Declared as an opt-out and filed as #4590; the real fix
is one shared collection, which needs a Linux host to verify.

RequireOrSkip reported every skip as coming from SKIASHARP_TEST_SKIP_GPU, but
device and browser hosts never see that variable -- the value arrives through
AppContext from the MSBuild property. Split the read into OptOut() and Parse()
so a skip names whichever one actually set it. Verified both ways: the env var
path prints 'via SKIASHARP_TEST_SKIP_GPU' and a -p:SkiaSharpTestSkipGpu build
prints 'via SkiaSharp.Tests.SkipGpu'.

NormalizeGpuOptOut described its separators as whitespace but did not split on
newlines, unlike GpuPolicy, so a YAML block value could carry one into an
MSBuild property. Now consistent.

Also gave every opt-out a tracking issue (#4555 Metal, #4590 Linux GL, #4591
umbrella) and corrected the iOS comment, which still claimed macOS and Mac
Catalyst were not opted out.

Verified: opt-out parsing unchanged (case, separators, 'all', raster and typo
both throw), policy guards 3/3, visual 25/5/5/15, non-GPU 5927 with only the
documented GC-lifetime flakes, which reproduce identically on the unmodified
branch.
The netfx leg ran x86 and x64 in one job, so an opt-out could not differ between
them -- GpuPolicy models the OS, not the architecture. That mattered once the x86
Vulkan ICD was provisioned: SwiftShader's LLVM JIT cannot resolve __chkstk in a
32-bit process, so the software driver crashes the host outright rather than
failing a test:

    JIT session error: Symbols not found: [ __chkstk ]
    SkiaSharp.Vulkan.Tests.exe (.NET Framework 4.8|x86) - exit code is '7'

Four retries, all x86, all identical; x64 ran the same suite green. Before the
x86 ICD existed the loader was simply absent and the tests failed instead, so
this is provisioning revealing a real limitation rather than a new fault.

Two jobs now, each passing --arch and carrying its own opt-out: x64 skips only
ganesh-gl, x86 also skips the three Vulkan backends. Direct3D stays required on
both. The split also makes any future x64/x86 divergence visible on its own leg
instead of hidden inside a combined one.

The cake target already accepted --arch, so no script change was needed.
The image marker path carries the OS tag, not the architecture or the retry
number, so the same scene appears in several TRX files on one leg. extract_images
wrote each role independently as it found it, so a triple could pair one run's
actual with another run's golden -- misdirecting whoever reads the triage images.
Each path is now taken whole from the first TRX that has it. Verified against two
TRX with identical paths: 20 images written rather than 40, seeding unchanged at
10 goldens.

Two comments had drifted from the code. SKGraphiteReleaseVulkanTests still said
Vulkan 'skips cleanly otherwise', which is what this branch removes, and the
gpu-test-policy summary of current opt-outs never gained Linux after ganesh-gl
was opted out there.

Not addressed, and noted on #4591: extract-visual-goldens blocks lexical path
traversal but does not resolve symlinks under the output directory. That needs a
pre-existing hostile link inside a fresh agent workspace to matter.
Brings in #4588, which fixes the benchmark-source native build: vcvarsall was
handed a Windows SDK version the hosted runner does not have, and >nul hid the
error. That was the one red GitHub check.

A docs review against the code found four contradictions:

The Mac Catalyst comment still said macOS 'is NOT opted out'. That was true when
written and stopped being true when macOS was opted out — the same stale claim
already fixed on the iOS leg, missed here.

review-skia-update's C# checklist still allowed 'no skipped tests (except
hardware-dependent: GPU, display)', which is exactly the inference this branch
removes.

gpu-test-policy claimed a backend is required on every host we build it for, and
that RequiredOn mirrors the gn args. Neither is literally true: the browser build
enables Ganesh without ganesh-gl being required there, and Tizen builds Ganesh
with no test leg at all. RequiredOn lists test hosts, and now says so.

golden-image-tests placed the Vulkan renderers in the Console satellite. The
sources are under tests/VulkanTests/ and also build into the platform-restricted
SkiaSharp.Vulkan.Tests library that the Android and Windows device hosts
register.

Also notes that a platform tag need not have goldens yet — tvos and
graphite-dawn.browser have none, so their first run fails as unseeded by design.
#4555 was broadened to cover all three Metal failures because they share a root
cause: no CI host has a real Metal device. That was wrong for tracking. #4586
carries 'Fixes #4555' and addresses only the iOS simulator's gradient pipeline,
so merging it would have silently closed the macOS shutdown hang and the Mac
Catalyst GPU-family gap along with it.

#4555 is back to its original scope. The other two are now #4598 (macOS
virtualized Metal hangs the test host on shutdown, killing the whole leg) and
#4599 (Mac Catalyst reports no MTLGPUFamily that Ganesh or Graphite accepts).
Each has its own cause and its own likely fix -- an Apple Silicon pool for the
first, possibly a probe change for the second -- so each closes on its own.

Repointed the opt-out comments and the policy doc at whichever issue explains
that leg, and updated the #4591 umbrella table. The iOS leg cites both #4598 and
#4555, because the simulator has the shutdown hang *and* the gradient bug.
gpu-test-policy listed which legs skip which backends and why, with issue
numbers. That is a snapshot of open bugs, so it goes stale the moment one is
fixed -- fixing Metal on iOS would have meant editing a document about the
policy, which is the wrong shape.

The docs now describe the mechanism and point at the YAML for the live list. The
YAML keeps the reasons and issue numbers inline, next to the declaration they
explain, which is where they are useful when someone asks why a leg skips
something.

containerized-testing named a specific backend for the same reason; it now
states the durable property (these images deliberately ship no GPU stack) and
lets the YAML say which backends that rules out.

Docs should change when the code or the shipped binary changes -- a new backend,
a new platform, a new gn arg -- not when an agent is fixed or a bug is closed.
VkGpuSurfaceIsCreatedSharpVkTypes built its instance with no ApplicationInfo,
which is a Vulkan 1.0 instance, and passed no MaxAPIVersion. Skia has required
1.1 unconditionally since m139 and acquires the core 1.1 device procs without a
version gate; vkGetDeviceProcAddr gates those on the instance's apiVersion, so
every one of them came back null, GRContext.CreateVulkan returned null, and the
test handed that null to SKSurface.Create and reported an ArgumentNullException
three frames from the actual problem.

This is not a regression and not a CI break -- the unfixed test passes against
the SwiftShader ICD CI provisions, which reports device 1.3.0. It only fails
where the device reports 1.4: with MaxAPIVersion unset Skia takes the loader's
version as its ceiling rather than what the instance asked for, so on a 1.4
driver it also demands the 1.4 entry points. The test's result therefore
depended on the agent's GPU driver, which is the kind of silent per-agent
behaviour this branch exists to remove.

Both halves are needed and neither is sufficient alone: the ApplicationInfo
makes the 1.1 device procs resolve at all, and MaxAPIVersion stops Skia
over-declaring from the loader. SilkVkContext already does exactly this, so the
two contexts now agree.

Features and the enabled extension lists move together with them. Skia trusts
fDeviceFeatures rather than re-querying, so the device enables what is passed
and passes what it enabled -- claiming a feature the device never turned on
would have Skia emit commands the driver rejects.

Verified 25/25 on net10.0 and net48, against both an AMD device reporting
1.4.329 and the SwiftShader build CI pins, so the fix holds on the driver that
exposed the bug and on the one that hid it.
@mattleibow
mattleibow merged commit 28dd1df into main Jul 31, 2026
116 checks passed
@mattleibow
mattleibow deleted the mattleibow-gpu-test-skip-policy branch July 31, 2026 03:04
mattleibow added a commit that referenced this pull request Jul 31, 2026
#4575 landed on main as a squash, so its content arrives again as commits this
branch already had. Conflicts resolved by taking main's reviewed version of
everything that belongs to #4575 and re-applying this branch's changes on top:

- gpu-test-policy.md goes back to main's wording exactly. Review deliberately
  removed the enumerated list of current opt-outs from that document -- it
  describes the mechanism, and the YAML is the live list -- so the paragraph
  this branch had grown there is dropped rather than updated.
- containerized-testing.md and the Apple tracking-issue references (#4598,
  #4599) take main's corrected text.
- The container-leg comments combine both: main's #4591 reference with this
  branch's point that the images have no GPU stack by design and the desktop
  legs carry the ganesh-gl coverage.

Two things the automatic merge got wrong and are fixed here: it reinstated the
three desktop `SKIASHARP_TEST_SKIP_GPU: ganesh-gl` opt-outs this branch removes
(Windows .NET Framework x64, Windows .NET Core, Linux), and it brought back the
XCloseDisplay binding that no longer has a caller now that GlxContext shares one
connection.

Re-verified after merging: 33/33 GL tests on a real driver, and 165/165 GPU plus
10/10 visual on Mesa softpipe.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: e64dd29f-b733-47ef-b7e5-65cf3fe98530
mattleibow added a commit that referenced this pull request Jul 31, 2026
[tests] Run ganesh-gl on the Windows and Linux CI legs (#4605)

Context: #4605
Context: documentation/dev/gpu-test-policy.md
Fixes: #4590

#4575 made a GPU backend required on every platform GpuPolicy.RequiredOn names
and turned the silent skips into an enumerable list. ganesh-gl was the largest
entry on it: required on Windows, macOS and Linux, but opted out of the two
desktop legs that had no working GL stack. This closes those, so the Ganesh GL
backend now runs on all three desktop platforms.

This is not "GL was untested until now". GL was already covered in several
places, and this fills in the ones that were not:

  * macOS already ran ganesh-gl through CGL. That is why ganesh-gl.macos was
    the only committed golden set — under the rules #4575 introduced, an
    unseeded backend fails, so those goldens exist because macOS was rendering.
  * Android, iOS and Mac Catalyst already exercise the views layer against real
    GL surfaces: MemoryLeakTests.SKGLViewHandlerDoesNotLeak runs and passes on
    all three device legs.
  * Windows had no OpenGL implementation at all, and Linux had GLX loading and
    then killing the host. Both are the low-level GRContext.CreateGl path the
    desktop console suite covers, and both are what this fixes.

The five container legs and Nano Server keep their opt-out, and the comment now
reads as a decision rather than a pending item: those images exist to prove
SkiaSharp works with the bare minimum installed, so giving them an X server and
Mesa would defeat their purpose.

Two gaps this does not close, both pre-existing: SKGLView on WinUI has no device
leg in this pipeline, and the Blazor SKGLView/WebGL test lives in
SkiaSharp.Tests.Integration, which this pipeline does not run. ganesh-gl is not
required on Browser at all; WASM's GPU backend is graphite-dawn, still opted out
because the headless browser exposes no adapter. #4591 tracks the remainder.

Every problem below was reproduced and measured before it was fixed: Mesa on
Windows, and Ubuntu under WSL with Xvfb and GLX for Linux, which reproduced the
CI crash faithfully enough to bisect it.

~~ Windows: no OpenGL at all ~~

The agents have no display driver carrying an OpenGL ICD, so opengl32.dll
answers with the in-box generic implementation: OpenGL 1.1, no
WGL_ARB_pixel_format, no WGL_ARB_pbuffer. WglContext cannot come up on that, and
Ganesh needs 3.0+ regardless.

scripts/infra/native/windows/install-mesa-gl.ps1 provisions Mesa the way Mesa
documents for machines with no OpenGL driver [0]: libgallium_wgl.dll becomes
System32\mesadrv.dll and SysWOW64\mesadrv.dll, registered under
OpenGLDrivers\MSOGL. It follows install-vulkan-icd.ps1 — pinned version, SHA-256
pin, both bitnesses, fatal on any failure — and checks what provisioning is
responsible for and no more: the driver is where opengl32 will look for it, its
version resource matches the version just pinned rather than a leftover from an
earlier run, and the registration reads back. Proving it renders belongs to the
suite, and GRContextTest.CreateDefaultContextIsValid already does that on every
leg where the policy requires ganesh-gl.

~~ Windows: SetPixelFormat and wglSetPixelFormat are not interchangeable ~~

With Mesa registered, provisioning still failed, and the diagnostics named it:

    mesadrv=C:\Windows\SYSTEM32\mesadrv.dll; pixelFormats=1332; chosenFormat=121
    FAILED: wglCreateContext returned NULL (2000)

Mesa is loaded and serving its own 1332 pixel formats, and 2000 is
ERROR_INVALID_PIXEL_FORMAT. gdi32's ChoosePixelFormat reports Mesa's formats and
SetPixelFormat returns true, but Mesa's per-HDC state is only created by its own
wglSetPixelFormat, so wglCreateContext has nothing to look up.

The two APIs turn out to be exactly inverted, consistently per driver: a
hardware ICD is set up through GDI and refuses a context when the format was set
the other way, and Mesa is the reverse. So the Wgl bootstrap tries GDI first —
every real driver, and every developer running these tests locally — and falls
back only when the context actually fails. A pixel format can be set once per
DC and the class is CS_OWNDC, so the retry needs a fresh window; the first is
destroyed before it is replaced.

~~ Linux: the crash was one test, not a race ~~

#4590 attributed the exit-7 host crash to nine test classes creating GLX
contexts concurrently. That diagnosis was wrong. The crash reproduces with the
suite serialized onto a single thread, and a trace shows every context created,
used and destroyed on that one thread.

The real cause is GRGlInterfaceTest.AssembleInterfaceIsValid, which resolved
Skia's proc addresses with glXGetProcAddress alone. Under GLVND — the
vendor-neutral libGL every current distro ships — that returns a dispatch stub
for any name at all; glTotallyNotARealFunction comes back non-null. Skia was
handed pointers that are not functions and walked off the end of the extension
list in GrGLExtensions::init. It now resolves through dlsym on libGL.so.1,
exactly as the macOS branch already did.

The death point only looked random because the run order varied.

~~ Both: llvmpipe cannot compile one of Skia's shaders ~~

Mesa's LLVM shader JIT segfaults inside LLVMTypeOf, under
GrGLOpsRenderPass::onDraw, building the fragment shader Skia generates for a
runtime blender. Reproduced on two independent stacks — Mesa 25.2 with LLVM 20
on Linux, and 26.1 with LLVM 22 on Windows — so both legs pin softpipe, the
non-JIT gallium rasterizer, which runs the identical tests green on both and
caps at GL 3.3, well past the 3.0 Ganesh needs. Filed as #4604.

Ruled out along the way, so nobody re-treads it: thread parallelism
(--parallel none --max-threads 1 crashes identically), managed thread stack size
at 2, 16 and 64 MB, LP_NUM_THREADS of 0 and 1, file-descriptor limits at 256,
1024 and 65536, and GL context churn — 400 create/use/destroy cycles are fine.

~~ Supporting changes ~~

  * every class that creates a GPU context joins the existing
    GpuRenderingCollection, mirroring VulkanGpuRenderingCollection. This is what
    #4590 and #4591 asked for; it was not the crash fix, but concurrent GPU
    context use is a real hazard worth closing. Where only a nested class does
    GPU work (SKBlenderTest, SKRuntimeEffectTest) only that class joins, so its
    raster sibling stays parallel — roughly 300 of 6100 tests are serialized
  * GlxContext shares one X11 connection for the process instead of opening and
    closing one per test. That is the leak XCloseDisplay was added for in #4575,
    fixed at the source: one connection instead of 128 and counting, and no
    closing a display while a context minted from it is still current
  * XInitThreads runs before any other Xlib call
  * ganesh-gl.windows and ganesh-gl.linux goldens are harvested and committed,
    since a backend that renders for the first time is unseeded and fails until
    they exist

~~ Result ~~

  * Windows (.NET Framework, x64) — 7415 tests, 0 failed, 23 skipped
  * Windows (.NET Framework, x86) — 7415 tests, 0 failed, 25 skipped
  * Windows (.NET Core)           — 6117 tests, 0 failed, 31 skipped
  * Linux                         — 6117 tests, 0 failed, 34 skipped

Linux previously exited 7 and published nothing at all. Measured locally, GL on
versus off is 6079 against 5910 passing: 169 tests that had never run once.

[0]: https://docs.mesa3d.org/drivers/llvmpipe.html#windows

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Copilot App <[email protected]>
mattleibow added a commit that referenced this pull request Aug 4, 2026
[tests] Make GPU tests required; skip only when declared (#4575)

Context: #4575
Context: documentation/dev/gpu-test-policy.md

GPU tests brought a backend up inside a try/catch and called Assert.Skip on any
exception. That made "this agent has no GPU" and "this binding is broken"
indistinguishable, and reported both as green. The committed goldens recorded
what it cost: ganesh-gl had a golden for macOS only, and graphite-dawn had none
at all, so those backends had been skipping everywhere for as long as they had
existed. Nobody could answer which backends actually ran.

Invert the default. A backend is now required on every platform listed in
GpuPolicy.RequiredOn, which mirrors the gn args in native/*/build.cake, and a
skip has to be declared. Failing to bring a required backend up is a test
failure, so RendererUnavailableException is deleted along with every catch that
swallowed it.

Skips come from exactly two places, kept separate because that distinction is
what a reader needs when a test skips:

  * the compiled-in table is a statement about a platform — Metal is not
    required off Apple because we do not build it there
  * SKIASHARP_TEST_SKIP_GPU is a statement about one agent, declared per leg in
    scripts/azure-templates-stages-test.yml with its reason and tracking issue
    inline, so it can be removed when that agent gains the capability without
    touching the policy or the documentation

Device and browser hosts never see the agent environment, so the same list
reaches them through the SkiaSharpTestSkipGpu MSBuild property baked into
runtimeconfig.json. An unrecognised backend id is an error, so a typo cannot
quietly leave a backend required.

~~ Latent bugs the required tests surfaced ~~

Five real bugs, every one of them previously invisible as a skip:

  * DllImport used the unversioned libGL and libX11 SONAMEs, which are linker
    symlinks shipped only in -dev packages. Linux GL could never load, and
    every GL test skipped silently for as long as that binding existed.
  * GlxContext.Destroy never called XCloseDisplay — the binding was not even
    declared — leaking an X11 connection per GPU test.
  * SKBlenderTest asserted exact colour equality across two GPU shader paths.
    llvmpipe returns #ff5e0000 where the other path returns #ff5d0000. Raster
    stays exact; the GPU subclass allows a tolerance of one.
  * The Windows software Vulkan ICD was staged for win-x64 only, so x86 had no
    loader and 21 of 25 Vulkan tests failed.
  * Win32VkContext built a Vulkan 1.0 instance and set no MaxAPIVersion, so
    GRContext.CreateVulkan returned null and the test reported an
    ArgumentNullException three frames from the real problem. Skia has required
    1.1 unconditionally since m139 [0] and acquires the core 1.1 device procs
    with no version gate; vkGetDeviceProcAddr gates those on the instance's
    apiVersion, so all nine came back null. It passed against CI's SwiftShader,
    which reports device 1.3.0, and failed on an AMD device reporting 1.4.329 —
    the result depended on the agent's driver.

~~ Limits that are declared, not fixed ~~

Fourteen opt-outs remain, each naming its cause. This is not a regression —
every one was already skipping silently — but they are now enumerable, and

  * Metal is unusable on all three Apple hosts, for three unrelated reasons:
    virtualized Metal hangs the macOS host on shutdown (#4598), Mac Catalyst
    never sees the Mac2 GPU family (#4599), and the iOS simulator cannot
    compile Graphite's gradient pipeline (#4555)
  * Linux GL crashes the host once GLX loads, exiting 7 after 523, 312, 5068
    and 0 tests with zero test failures and no TRX published. The XCloseDisplay
    fix above did not resolve it (#4590)
  * the headless browser the runner launches exposes no WebGPU adapter and the
    runner has no flag passthrough; reported upstream

~~ Structural fallout ~~

The .NET Framework leg is now two jobs. SwiftShader's LLVM JIT cannot resolve
__chkstk in a 32-bit process, so software Vulkan crashes the host on x86 while
x64 runs the same suite green. GpuPolicy models the OS but not the
architecture, so separate jobs are what let x86 opt out while x64 keeps Vulkan
required, and any future x64/x86 divergence becomes visible on its own leg.

Mac Catalyst also stops being non-gating. It carried the repo's only
continueOnError: true, added in #3247, which is the same failure mode this
change exists to remove.

~~ Filed from the Vulkan investigation ~~

  * #4600 — MaxAPIVersion's default of 0 makes Skia trust the loader's version
    rather than the instance's. Worse, since m140 [1] the minimum-version check
    is SK_ABORT rather than a graceful null, so a consumer who correctly
    declares Vulkan 1.0 now aborts the process instead of being able to fall
    back to raster.
  * #4601 — fDeviceLostProc and fDeviceLostContext are not exposed, so
    consumers get no notification on VK_ERROR_DEVICE_LOST.

[0]: https://skia.googlesource.com/skia/+/0a3150b03b
[1]: https://skia.googlesource.com/skia/+/dfea59a30f

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot App <[email protected]>
mattleibow added a commit that referenced this pull request Aug 4, 2026
[tests] Run ganesh-gl on the Windows and Linux CI legs (#4605)

Context: #4605
Context: documentation/dev/gpu-test-policy.md
Fixes: #4590

#4575 made a GPU backend required on every platform GpuPolicy.RequiredOn names
and turned the silent skips into an enumerable list. ganesh-gl was the largest
entry on it: required on Windows, macOS and Linux, but opted out of the two
desktop legs that had no working GL stack. This closes those, so the Ganesh GL
backend now runs on all three desktop platforms.

This is not "GL was untested until now". GL was already covered in several
places, and this fills in the ones that were not:

  * macOS already ran ganesh-gl through CGL. That is why ganesh-gl.macos was
    the only committed golden set — under the rules #4575 introduced, an
    unseeded backend fails, so those goldens exist because macOS was rendering.
  * Android, iOS and Mac Catalyst already exercise the views layer against real
    GL surfaces: MemoryLeakTests.SKGLViewHandlerDoesNotLeak runs and passes on
    all three device legs.
  * Windows had no OpenGL implementation at all, and Linux had GLX loading and
    then killing the host. Both are the low-level GRContext.CreateGl path the
    desktop console suite covers, and both are what this fixes.

The five container legs and Nano Server keep their opt-out, and the comment now
reads as a decision rather than a pending item: those images exist to prove
SkiaSharp works with the bare minimum installed, so giving them an X server and
Mesa would defeat their purpose.

Two gaps this does not close, both pre-existing: SKGLView on WinUI has no device
leg in this pipeline, and the Blazor SKGLView/WebGL test lives in
SkiaSharp.Tests.Integration, which this pipeline does not run. ganesh-gl is not
required on Browser at all; WASM's GPU backend is graphite-dawn, still opted out
because the headless browser exposes no adapter. #4591 tracks the remainder.

Every problem below was reproduced and measured before it was fixed: Mesa on
Windows, and Ubuntu under WSL with Xvfb and GLX for Linux, which reproduced the
CI crash faithfully enough to bisect it.

~~ Windows: no OpenGL at all ~~

The agents have no display driver carrying an OpenGL ICD, so opengl32.dll
answers with the in-box generic implementation: OpenGL 1.1, no
WGL_ARB_pixel_format, no WGL_ARB_pbuffer. WglContext cannot come up on that, and
Ganesh needs 3.0+ regardless.

scripts/infra/native/windows/install-mesa-gl.ps1 provisions Mesa the way Mesa
documents for machines with no OpenGL driver [0]: libgallium_wgl.dll becomes
System32\mesadrv.dll and SysWOW64\mesadrv.dll, registered under
OpenGLDrivers\MSOGL. It follows install-vulkan-icd.ps1 — pinned version, SHA-256
pin, both bitnesses, fatal on any failure — and checks what provisioning is
responsible for and no more: the driver is where opengl32 will look for it, its
version resource matches the version just pinned rather than a leftover from an
earlier run, and the registration reads back. Proving it renders belongs to the
suite, and GRContextTest.CreateDefaultContextIsValid already does that on every
leg where the policy requires ganesh-gl.

~~ Windows: SetPixelFormat and wglSetPixelFormat are not interchangeable ~~

With Mesa registered, provisioning still failed, and the diagnostics named it:

    mesadrv=C:\Windows\SYSTEM32\mesadrv.dll; pixelFormats=1332; chosenFormat=121
    FAILED: wglCreateContext returned NULL (2000)

Mesa is loaded and serving its own 1332 pixel formats, and 2000 is
ERROR_INVALID_PIXEL_FORMAT. gdi32's ChoosePixelFormat reports Mesa's formats and
SetPixelFormat returns true, but Mesa's per-HDC state is only created by its own
wglSetPixelFormat, so wglCreateContext has nothing to look up.

The two APIs turn out to be exactly inverted, consistently per driver: a
hardware ICD is set up through GDI and refuses a context when the format was set
the other way, and Mesa is the reverse. So the Wgl bootstrap tries GDI first —
every real driver, and every developer running these tests locally — and falls
back only when the context actually fails. A pixel format can be set once per
DC and the class is CS_OWNDC, so the retry needs a fresh window; the first is
destroyed before it is replaced.

~~ Linux: the crash was one test, not a race ~~

#4590 attributed the exit-7 host crash to nine test classes creating GLX
contexts concurrently. That diagnosis was wrong. The crash reproduces with the
suite serialized onto a single thread, and a trace shows every context created,
used and destroyed on that one thread.

The real cause is GRGlInterfaceTest.AssembleInterfaceIsValid, which resolved
Skia's proc addresses with glXGetProcAddress alone. Under GLVND — the
vendor-neutral libGL every current distro ships — that returns a dispatch stub
for any name at all; glTotallyNotARealFunction comes back non-null. Skia was
handed pointers that are not functions and walked off the end of the extension
list in GrGLExtensions::init. It now resolves through dlsym on libGL.so.1,
exactly as the macOS branch already did.

The death point only looked random because the run order varied.

~~ Both: llvmpipe cannot compile one of Skia's shaders ~~

Mesa's LLVM shader JIT segfaults inside LLVMTypeOf, under
GrGLOpsRenderPass::onDraw, building the fragment shader Skia generates for a
runtime blender. Reproduced on two independent stacks — Mesa 25.2 with LLVM 20
on Linux, and 26.1 with LLVM 22 on Windows — so both legs pin softpipe, the
non-JIT gallium rasterizer, which runs the identical tests green on both and
caps at GL 3.3, well past the 3.0 Ganesh needs. Filed as #4604.

Ruled out along the way, so nobody re-treads it: thread parallelism
(--parallel none --max-threads 1 crashes identically), managed thread stack size
at 2, 16 and 64 MB, LP_NUM_THREADS of 0 and 1, file-descriptor limits at 256,
1024 and 65536, and GL context churn — 400 create/use/destroy cycles are fine.

~~ Supporting changes ~~

  * every class that creates a GPU context joins the existing
    GpuRenderingCollection, mirroring VulkanGpuRenderingCollection. This is what
    #4590 and #4591 asked for; it was not the crash fix, but concurrent GPU
    context use is a real hazard worth closing. Where only a nested class does
    GPU work (SKBlenderTest, SKRuntimeEffectTest) only that class joins, so its
    raster sibling stays parallel — roughly 300 of 6100 tests are serialized
  * GlxContext shares one X11 connection for the process instead of opening and
    closing one per test. That is the leak XCloseDisplay was added for in #4575,
    fixed at the source: one connection instead of 128 and counting, and no
    closing a display while a context minted from it is still current
  * XInitThreads runs before any other Xlib call
  * ganesh-gl.windows and ganesh-gl.linux goldens are harvested and committed,
    since a backend that renders for the first time is unseeded and fails until
    they exist

~~ Result ~~

  * Windows (.NET Framework, x64) — 7415 tests, 0 failed, 23 skipped
  * Windows (.NET Framework, x86) — 7415 tests, 0 failed, 25 skipped
  * Windows (.NET Core)           — 6117 tests, 0 failed, 31 skipped
  * Linux                         — 6117 tests, 0 failed, 34 skipped

Linux previously exited 7 and published nothing at all. Measured locally, GL on
versus off is 6079 against 5910 passing: 169 tests that had never run once.

[0]: https://docs.mesa3d.org/drivers/llvmpipe.html#windows

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@mattleibow mattleibow added this to the 4.152.0-preview.1 milestone Aug 8, 2026
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.

3 participants