Skip to content

Fix Graphite/Metal GradientBlend on the iOS simulator + shader-error diagnostic API (#4555) - #4586

Open
ramezgerges wants to merge 8 commits into
mono:mainfrom
ramezgerges:dev/issue-4555-graphite-shader-error-handler
Open

ramezgerges wants to merge 8 commits into
mono:mainfrom
ramezgerges:dev/issue-4555-graphite-shader-error-handler

Conversation

@ramezgerges

@ramezgerges ramezgerges commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes the Graphite/Metal GradientBlend failure on the iOS simulator by selecting texture-copy destination reads instead of unsupported framebuffer fetch. Exposes shader and Metal pipeline-creation diagnostics through SKGraphiteContextOptions.ShaderErrorHandler; the managed callback stays rooted until the native context and its caller-owned handler bridge are destroyed.

The review follow-up preserves explicitly requested zero-byte GPU budgets and removes the independent Dawn shader-test capability skip. All Graphite backend scenarios use the same diagnostic handler, the process-shared Dawn context verifies matching options, and shader errors are asserted after scenario cleanup. Skips are controlled only by the existing GpuPolicy.

Current verification is structural only. The follow-up regression tests and rebuilt-native GPU/device behavior have not been executed at the current head. Native builds, device runs, and heavy restores remain paused; historical device/Vulkan results are not current-head proof.

Related issues

Fixes #4555

Required skia PR

Requires mono/skia#308. The submodule remains pinned to 2e210c699456831d90d413775646d9d44116b569; the companion PR is still open.

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

Added delegate and members on SKGraphiteContextOptions:

public delegate void SKGraphiteShaderErrorHandlerDelegate(string shader, string errors, bool shaderWasCached);

// SKGraphiteContextOptions
public SKGraphiteContextOptions();
public SKGraphiteShaderErrorHandlerDelegate ShaderErrorHandler { get; set; }

Existing SKGraphiteContext.CreateDawn, CreateMetal, and CreateVulkan signatures are retained. The handler is supplied through the options property, not through new three-parameter factory overloads. The review follow-up changes no public declarations or constructor defaults.

Behavior

  • Graphite/Metal destination reads use texture copies on iOS/tvOS simulators; framebuffer-fetch behavior on real Apple devices and macOS is unchanged. A null Recorder.Snap() remains a hard failure.
  • Installed handlers receive shader diagnostics and Metal render-pipeline creation failures.
  • An explicit zero-byte GPU cache budget, including default(SKGraphiteContextOptions), passes through as zero. Negative values retain their default-budget sentinel meaning. The parameterless constructor and no-options factories retain this PR's existing -1 initialization.

Testing

  • git --no-pager diff --check 085a3a619c1af059a022a41f0718c195bdac753d..HEAD — passed.
  • git --no-pager diff --exit-code 085a3a619c1af059a022a41f0718c195bdac753d..HEAD -- scripts tests/SkiaSharp.Tests.Samples tests/SkiaSharp.Tests.Samples.Analyzers tests/SkiaSharp.Tests.Samples.slnx tests/Tests/SkiaSharp/Gpu/GpuPolicy.cs documentation/dev/building-samples.md — passed; canonical CI/Samples contracts and GPU policy are unchanged.
  • git --no-pager diff --exit-code 5ec253f7ffa82a9d999469f730de97af7c74f2d7..HEAD -- externals/skia binding/SkiaSharp/Generated binding/SkiaSharp/Gpu/Graphite/SKGraphiteContext.cs — passed; the scoped follow-up leaves the native pin, generated interop, factory signatures, and native ownership code unchanged.
  • Static source-contract checks — passed for direct budget forwarding, unchanged public declarations/constructor body, policy-only gating of all four scenarios, shared Dawn options, diagnostic assertions after cleanup, and presence of regression cases. These are not compilation or runtime tests.
  • Added SKGraphiteContextOptionsTest coverage for -2, -1, 0, 1, 268435456, and long.MaxValue, plus default-initialized and parameterless-constructor options. These native-call-free conversion cases have not been executed.
  • dotnet cake --target=externals-macos --arch=arm64 — not run, under the native-build pause. The submodule is uninitialized and output/native is absent. externals-download is not a valid substitute for this native pin.
  • dotnet test tests/SkiaSharp.Tests.Console.slnx -p:TargetFramework=net10.0 -p:TargetFrameworks=net10.0 — not run; native binaries and managed restore assets are absent, with heavy restores paused.
  • iOS/tvOS simulator rendering and browser/Dawn execution — not run at the current head. The existing tests/Content/Goldens/graphite-metal.ios/GradientBlend.png is retained unchanged; fresh rendering comparison and before/after screenshots remain outstanding. Earlier author-reported device/Vulkan runs are historical and are not reused as verification of this revision.
  • Bindings were already committed with the native API changes; regeneration was not rerun for the scoped follow-up because no C headers, generated declarations, or binding mappings changed.

Checklist

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

@github-actions

github-actions Bot commented Jul 30, 2026 •

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 -- 4586

PowerShell / Windows:

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

Step 2 — Add the local NuGet source

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

mattleibow added a commit that referenced this pull request Jul 30, 2026
#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.
@mattleibow

mattleibow commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@ramezgerges
ramezgerges force-pushed the dev/issue-4555-graphite-shader-error-handler branch from 0b92317 to 9ab7523 Compare August 3, 2026 17:18
@ramezgerges

Copy link
Copy Markdown
Contributor Author

Rebased onto the current main and resolved the GraphiteMetalRenderer.cs conflict (kept the version that removes the null-Snap workaround, which is exactly what this PR fixes). The two failed /azp run attempts happened while I was force-pushing; the branch is stable now.

@ramezgerges
ramezgerges force-pushed the dev/issue-4555-graphite-shader-error-handler branch from 9ab7523 to a12b2b3 Compare August 3, 2026 17:41
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

Pull request overview

This PR fixes a Graphite/Metal iOS-simulator rendering failure (null Recorder.Snap() in the GradientBlend scene) and introduces a managed shader-error diagnostic hook by wiring a new native fShaderErrorHandler option through to SKGraphiteContext creation.

Changes:

  • Adds SKGraphiteShaderErrorHandlerDelegate and new CreateDawn/CreateMetal/CreateVulkan overloads that accept a shader-error handler, with lifetime management via pinned delegates and a native bridge handle.
  • Removes the simulator-specific null-Snap() special-casing in the Graphite/Metal visual renderer so regressions fail consistently across hosts.
  • Adds a Vulkan smoke test ensuring installing a shader-error handler does not break context teardown and basic submission.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/VulkanTests/GraphiteVkBackendContextTest.cs Adds a Vulkan smoke test for the new shader-error handler overload and lifetime/teardown behavior.
tests/Tests/SkiaSharp/Visual/Renderers/GraphiteMetalRenderer.cs Makes Recorder.Snap() null a hard failure on all hosts (including simulator) now that the underlying issue is fixed.
binding/SkiaSharp/SkiaApi.generated.cs Adds new P/Invoke surface and struct field for sk_graphite_shader_error_handler_t and SKGraphiteContextOptions.fShaderErrorHandler.
binding/SkiaSharp/Gpu/Graphite/SKGraphiteContext.cs Adds handler-overload factories and pins/tears down managed + native handler bridge resources.
binding/SkiaSharp/DelegateProxies.cs Adds the managed callback proxy implementation for shader-error handler invocations.
binding/SkiaSharp.Skottie/SkottieApi.generated.cs Regenerates typedefs to include the new Graphite shader-error handler type alias.
binding/SkiaSharp.SceneGraph/SceneGraphApi.generated.cs Regenerates typedefs to include the new Graphite shader-error handler type alias.
binding/SkiaSharp.Resources/ResourcesApi.generated.cs Regenerates typedefs to include the new Graphite shader-error handler type alias.

Comment thread binding/SkiaSharp/DelegateProxies.cs Resolved
Comment thread binding/SkiaSharp/SkiaApi.generated.cs Resolved

@mattleibow mattleibow 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.

Requesting changes: the shader-handler test does not verify callback delivery, and the new backend-specific test setup should be consolidated with the existing Graphite backend harness so future Graphite scenarios can run consistently across Vulkan, Metal, and Dawn.

@github-project-automation github-project-automation Bot moved this to Changes Requested in SkiaSharp Backlog Aug 3, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

5 similar comments
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

📦 Artifact size report

Packages from this PR (build 1539617) vs the latest nightly baseline 4.151.0-nightly.124 (observed 2026-08-04).

Total .nupkg size: 569.4 MB → 569.1 MB (−296.6 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 109.1 MB 108.6 MB 🟢 −451.5 KB -0.4%
SkiaSharp.NativeAssets.WebAssembly 69.6 MB 69.6 MB 🔴 +67.5 KB +0.1%

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

Per-file changes

SkiaSharp.NativeAssets.WebAssembly

File Size
🧬 wasm 5.0.6/mt · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/5.0.6/mt/libSkiaSharp.a) 17.9 MB → 17.9 MB (🔴 +1.5 KB)
🧬 wasm 5.0.6/st,simd · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/5.0.6/st,simd/libSkiaSharp.a) 18.2 MB → 18.2 MB (🔴 +1.5 KB)
🧬 wasm 5.0.6/mt,simd · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/5.0.6/mt,simd/libSkiaSharp.a) 18.2 MB → 18.2 MB (🔴 +1.5 KB)
🧬 wasm 5.0.6/st · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/5.0.6/st/libSkiaSharp.a) 17.9 MB → 17.9 MB (🔴 +1.5 KB)
🧬 wasm 3.1.56/mt · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/3.1.56/mt/libSkiaSharp.a) 17.7 MB → 17.7 MB (🔴 +1.5 KB)
🧬 wasm 3.1.56/st · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/3.1.56/st/libSkiaSharp.a) 17.8 MB → 17.8 MB (🔴 +1.5 KB)
🧬 wasm 3.1.56/mt,simd · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/3.1.56/mt,simd/libSkiaSharp.a) 18.0 MB → 18.0 MB (🔴 +1.5 KB)
🧬 wasm 3.1.56/st,simd · libSkiaSharp.a (buildTransitive/netstandard1.0/libSkiaSharp.a/3.1.56/st,simd/libSkiaSharp.a) 18.0 MB → 18.0 MB (🔴 +1.5 KB)

SkiaSharp.NativeAssets.WinUI

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

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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

5 similar comments
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

2 similar comments
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ramezgerges
ramezgerges force-pushed the dev/issue-4555-graphite-shader-error-handler branch from a12b2b3 to 077354b Compare August 4, 2026 16:54
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@ramezgerges
ramezgerges force-pushed the dev/issue-4555-graphite-shader-error-handler branch 4 times, most recently from 3c4749f to a073aec Compare September 16, 2026 01:47
@ramezgerges
ramezgerges force-pushed the dev/issue-4555-graphite-shader-error-handler branch from a073aec to fbec948 Compare September 21, 2026 18:07
@mattleibow

Copy link
Copy Markdown
Contributor

Thanks for the iOS-simulator GradientBlend fix. The framebuffer-fetch change is narrowly scoped. I have a few requests on the diagnostic API and its companion native changes in mono/skia#308:

Callback API

In SKGraphiteContextOptions.cs, ShaderErrorHandler suggests an implementation of Skia’s entire handler class, while the delegate handles only compileError. Could we name the property ShaderCompileErrorCallback and its type SKGraphiteShaderCompileErrorDelegate? The named delegate can continue to document shader, errors, shaderWasCached, and the callback thread without adding an info object.

GPU budget

ToNative currently converts every zero to the default budget:

fGpuBudgetInBytes = gpuBudgetInBytes == 0 ? -1 : gpuBudgetInBytes;

This also changes an explicit GpuBudgetInBytes = 0, which is a valid zero-byte budget. Could the private backing field be long?, with null meaning “not set”? For example:

private long? gpuBudgetInBytes;

public long GpuBudgetInBytes {
    readonly get => gpuBudgetInBytes.GetValueOrDefault();
    set => gpuBudgetInBytes = value;
}

// In ToNative:
fGpuBudgetInBytes = gpuBudgetInBytes ?? -1;

The public property stays long; the constructor can still seed -1. Please test the untouched default(SKGraphiteContextOptions) and an explicitly assigned zero separately.

Exception-safe ownership

In CreateDawn, CreateMetal, and CreateVulkan, the sequence is options.ToNative(...) followed by backendContext.ToNative() and sk_graphite_context_make_*(). The first call allocates the bridge and roots the callback; the null-result branches clean up, but exceptions in the later calls do not. SKGraphiteContextOptions.ToNative likewise allocates the GCHandle before calling sk_graphite_shader_error_handler_new, with no exception cleanup around that call. Please cover those paths while retaining the correct successful-context teardown order. Native sk_graphite.cpp also lacks _new/_delete stubs under !SK_GRAPHITE, so a missing symbol throws rather than reaching the current “Graphite not built?” null check.

Metal failure diagnostics

On pipeline-state failure, MtlGraphicsPipeline.mm calls:

sharedContext->caps()->shaderErrorHandler()->compileError(
        label.c_str(), diag.c_str(), /*shaderWasCached=*/false);

But sk_graphite.h and the managed delegate describe the first argument as shader source, not a pipeline label. Could we supply source or distinguish this case in the contract? This call also reaches Skia’s asserting default handler when no callback is installed; previously the failure logged and returned null. Please preserve the no-callback behavior or document and justify the change.

Failure-path coverage

SKGraphiteShaderErrorHandlerTest forwards synthetic strings directly through the managed proxy. ShaderErrorHandlerWiringSurvivesFullRoundTrip checks that a real context does not invoke it. Neither demonstrates a native failure reaching the callback with the expected arguments. Please add that test or provide captured results of a reproducible diagnostic run. The same harness currently discards Submit()’s boolean result; it should assert success.

@ramezgerges
ramezgerges force-pushed the dev/issue-4555-graphite-shader-error-handler branch from fbec948 to 91c4759 Compare October 7, 2026 13:50
@mattleibow
mattleibow force-pushed the dev/issue-4555-graphite-shader-error-handler branch from 91c4759 to 5ec253f Compare October 13, 2026 05:07
@mattleibow
mattleibow force-pushed the dev/issue-4555-graphite-shader-error-handler branch from 5f843a8 to 9cffbc8 Compare November 15, 2026 08:20

@mattleibow mattleibow 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.

One additional follow-up not covered by my earlier review: the callback decodes shader and errors with Marshal.PtrToStringAnsi. On Windows that uses the active ANSI code page rather than UTF-8, so non-ASCII shader source or diagnostics can be corrupted. Please decode these native UTF-8 strings explicitly (for example, with Marshal.PtrToStringUTF8) and add a non-ASCII forwarding test.

@ramezgerges

Copy link
Copy Markdown
Contributor Author

@mattleibow requesting a re-review: all five threads from your August review were addressed and resolved on 2026-08-04 (callback-delivery coverage via SKGraphiteShaderErrorHandlerTest, the shared GraphiteBackendTestBase harness, the public options struct now carrying a real delegate instead of a raw handle, null-pointer normalization in the proxy, and an explicit failure when the native handler cannot be created). The CHANGES_REQUESTED state is from before those changes.

ramezgerges and others added 6 commits November 17, 2026 22:58
Wraps the new sk_graphite_context_options.fShaderErrorHandler C API
so managed callers can capture Graphite shader compile failures. The
motivating case is the Metal iOS simulator gradient scene where
Recorder.Snap() silently returns null with no diagnostic — Skia's
default handler prints via SkDebugf + asserts, which is invisible in
shipping apps on Apple platforms.

* new CreateDawn/CreateMetal/CreateVulkan overloads taking
  SKGraphiteShaderErrorHandlerDelegate (backwards-compatible additions,
  no signature changes)
* SKGraphiteShaderErrorHandlerDelegate proxy in DelegateProxies never
  throws across the FFI boundary — a bad handler cannot crash Skia's
  shader-compile path
* GCHandle pinned for the Context's lifetime, freed in DisposeNative
  after the native context tears down its internal handler pointer

Includes GraphiteVkContextAcceptsShaderErrorHandler smoke test that
proves the wiring survives Context create + trivial draw + dispose on
Vulkan (Lavapipe compiles cleanly so the callback does not fire —
the important assertion is no double-free / no EntryPointNotFound on
teardown). The Metal simulator failure path requires an iOS host to
reproduce and is out of scope for CI.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Root cause (diagnosed with the fShaderErrorHandler hook from this
branch, plus PSO-failure forwarding added to it): Graphite's MtlCaps
enabled framebuffer fetch for every Apple-family GPU and
Caps::getDstReadStrategy() then always used it for dst reads. The iOS
simulator advertises an Apple GPU family but cannot read a render
target from a fragment shader — the MSL compiles, but
newRenderPipelineStateWithDescriptor fails with CompilerError Code=2
"reading from a rendertarget is not supported" — so the Multiply-blend
draw in GradientBlend (the only matrix scene needing a dst read) nulled
its pipeline and Recorder.Snap() returned null. Ganesh/Metal never uses
framebuffer fetch and real devices/macOS support it, which is why only
this one cell failed.

Submodule changes (mono/skia dev/issue-4555-graphite-shader-error-handler):
* Metal PSO-creation failures are now reported through the
  ShaderErrorHandler (previously SkDebugf-only, invisible on iOS)
* framebuffer fetch is disabled under TARGET_OS_SIMULATOR; dst reads
  fall back to DstReadStrategy::kTextureCopy there

Test harness:
* remove the simulator-only null-Snap() skip seam from
  GraphiteMetalRenderer — a null Snap() is a hard failure everywhere
  again, so regressions can no longer hide behind the skip
* seed the graphite-metal.ios/GradientBlend golden (rendered on an
  iPhone 16 / iOS 26.1 simulator; pixel-identical to the
  graphite-metal.macos golden)

Verified on the iOS simulator: full SkiaSharp.Tests.Devices run is
green (1219 total, 0 failed, 1138 succeeded, 81 skipped), with the
GradientBlend cell rendering and matching its golden.

Fixes mono#4555.

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: bf9e0803-2d6c-49eb-b83a-ed4d81ebbc31
Pass explicit zero-byte GPU budgets through unchanged and cover the managed options conversion with exact-value regression cases.

Use one stable diagnostic handler for the shared Dawn harness so shader coverage follows GpuPolicy without a separate capability skip. Assert diagnostics after scenario cleanup and fail when shared-context options differ.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: bf9e0803-2d6c-49eb-b83a-ed4d81ebbc31
SKGraphiteContext.Create{Dawn,Metal,Vulkan} called options.ToNative(),
which allocates a GCHandle and native bridge for the shader-error
handler, before backendContext.ToNative(), which throws on incomplete
backend handles. A throwing backend left the handler rooted forever.
Convert the backend first so nothing is allocated before validation.

Adds FailedCreateDoesNotRootShaderErrorHandler (Metal/Vulkan/Dawn),
which failed 3/3 before the reorder and passes after.

Also adapts the shader-error proxy to the generator's byte-marshalled
bool after rebasing onto main.

Co-authored-by: Copilot App <[email protected]>
Exercise non-ASCII callback strings and both cache flags. Require successful Snap and Submit in the shared backend harness.

Co-authored-by: Copilot App <[email protected]>
@mattleibow
mattleibow force-pushed the dev/issue-4555-graphite-shader-error-handler branch from 9cffbc8 to 574d678 Compare November 17, 2026 21:04
Copilot AI and others added 2 commits November 17, 2026 23:18
Inject a pipeline-state creation failure via an ObjC swizzle and assert
the handler receives MSL source rather than the pipeline label. Repin
externals/skia to the native fix.

Co-authored-by: Copilot App <[email protected]>
…no (mono#4555)

Skia reports shader source and compiler errors as UTF-8, but the proxy
decoded them with PtrToStringAnsi, which uses the system code page on
Windows and mangled every non-ASCII character. Decode explicitly with
Encoding.UTF8, which works on every target including netstandard2.0 and
.NET Framework where Marshal.PtrToStringUTF8 is unavailable.

FailedCreateDoesNotRootShaderErrorHandler relies on a WeakReference being
cleared, which Mono's conservative stack scanning does not guarantee, so it
failed on Android even though no handler is pinned on that path. Use the
existing SkipOnMono policy like the other collection tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

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

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

[BUG] Graphite/Metal: Recorder.Snap() returns null for the gradient scene on the iOS simulator

4 participants