Repository navigation
Description
Description
A Blazor WebAssembly Release AOT build either traps with MONO_WASM: function signature mismatch or hangs while ImageSharp 4.0.0 decodes a PNG into Rgba32.
The strongest indication that this is a Mono WASM AOT generic-instantiation/codegen issue is that merely adding a reachable direct call to PixelOperations<Rgba32>.FromRgba32Bytes makes the previously failing Image.LoadAsync<Rgba32> complete. No PNG data or decoder configuration changes between the failing and working builds.
Library-side tracking with the full diagnosis is SixLabors/ImageSharp#3151.
Reproduction Steps
Clone:
git clone https://github.com/littletoxic/ImageConverterWasm.git
cd ImageConverterWasmThe app uses ImageSharp 4.0.0, which performs build-time license validation. A valid local open-source/commercial license is therefore required to build the v4 dependency. The reporter cannot publish that license. The ImageSharp maintainers can reproduce from SixLabors/ImageSharp#3151.
Publish with WASM AOT enabled:
dotnet publish .\src\ImageConverter\ImageConverter.csproj `
-c Release `
-p:RunAOTCompilation=true `
-p:PublishDir="$env:TEMP\ImageConverterAot\"
dotnet serve --directory "$env:TEMP\ImageConverterAot\wwwroot"Open the printed URL and upload:
The original app calls:
_image = await Image.LoadAsync(stream);More focused diagnostic builds established:
// Hangs
using var rgbaImage = await Image.LoadAsync<Rgba32>(stream);
// Completes for the same RGBA PNG
using var rgbImage = await Image.LoadAsync<Rgb24>(stream);The inverse control also hangs: an RGB PNG that normally completes hangs when explicitly decoded using Image.LoadAsync<Rgba32>.
These calls complete independently:
_ = new Image<Rgba32>(32, 32);
var source = new byte[4];
var destination = new Rgba32[1];
PixelOperations<Rgba32>.Instance.FromRgba32Bytes(
Configuration.Default,
source,
destination,
destination.Length);Most importantly, keeping the direct FromRgba32Bytes call reachable in the application also makes the formerly hanging Image.LoadAsync<Rgba32> call complete. This changes the AOT generic instance set without changing the decoded input.
Expected behavior
Image.LoadAsync<Rgba32> should decode the 32x32 PNG and return normally in a Release WASM AOT build.
Actual behavior
With the original browser file stream, the runtime traps:
MONO_WASM: function signature mismatch
RuntimeError: function signature mismatch
at dotnet.native.wasm:wasm-function[...]
After buffering the browser stream into a MemoryStream, the focused Image.LoadAsync<Rgba32> diagnostic hangs indefinitely before returning. Depending on which generic calls are reachable, the symptom changes between a signature-mismatch trap and a hang.
Rgb24 and several other pixel/format controls complete normally.
Regression?
ImageSharp 3.1.12 completes the same explicit Image.LoadAsync<Rgba32> test on the same .NET SDK/workload. ImageSharp 4.0.0 does not.
A relevant library code-shape change is:
- ImageSharp 3: the generic pixel loop calls the mutable struct instance method
dp.FromRgba32(sp). - ImageSharp 4: the loop uses the static abstract interface call
TPixel.FromRgba32(...).
This establishes a library-version regression surface but does not by itself prove which runtime change is responsible.
Known Workarounds
Either:
- Decode into
Rgb24when dropping alpha is acceptable, or - Keep a reachable direct call to
PixelOperations<Rgba32>.Instance.FromRgba32Bytes(...)in the application so the required AOT instance appears to be generated.
Disabling RunAOTCompilation also avoids the AOT-specific failure.
Configuration
.NET SDK: 11.0.100-preview.5.26302.115
Runtime: 11.0.0-preview.5.26302.115
WASM workload: 11.0.100-preview.5.26302.115
OS: Windows 10.0.26200 x64
Browser: Microsoft Edge
ImageSharp: 4.0.0
AOT publish succeeds and reports AOT'ing 48 assemblies; the failure occurs only when the browser executes the decode path.
Other information
Related issues:
- [WASM AOT] Image.LoadAsync<Rgba32> hangs unless PixelOperations<Rgba32> is directly rooted SixLabors/ImageSharp#3151 contains the library-side report and detailed format/pixel controls.
- [IOS Xamarin] System.ExecutionEngineException: Attempting to JIT compile method 'void SixLabors.ImageSharp.Formats.Png.PngScanlineProcessor:ProcessRgbScanline<SixLabors.ImageSharp.PixelFormats.Rgba32> SixLabors/ImageSharp#1708 is an older AOT failure where a PNG/Rgba32 specialization was not generated; ImageSharp maintainers classified it as an upstream AOT compiler issue.
- [wasm][AOT] null function or function signature mismatch - #119143 tracks a WASM AOT generic-sharing signature mismatch. The error family and direct-root workaround are similar, but this report has not been proven to have the same root cause.
Attempts to reduce the issue to only a static-abstract-interface generic loop, including a cross-assembly version, completed normally. Therefore the report does not claim that static abstract dispatch alone is sufficient; an additional ImageSharp dispatch/instantiation condition is involved.
This issue was investigated and prepared with assistance from OpenAI Codex.
Activity
[mono][wasm][AOT] Generate gsharedvt out-sig wrappers for Nullable<T>…
[mono][wasm][AOT] Generate gsharedvt out-sig wrappers for Nullable<T>…
pavelsavara commentedon Aug 4, 2026
@littletoxic does this have same symptoms with Net10 as with Net11 ? (wipe bin/obj folders before you recompile)
I wonder why #119004 on Net11 doesn't fix this.
@BrzVlad thoughts ?
pavelsavara commentedon Aug 4, 2026
Or maybe it cold be fixed by @lewing's #131049 in Net11 preview 7, but I'm not sure because
PixelOperationsis aclassnotstruct.BrzVlad commentedon Aug 4, 2026
invalid function signature, presence of static abstract interface calls, repro being affected by presence of unrelated methods -> to me it points to some issue around resolving of method. So I imagine somwhere there is a call that gets resolved incorrectly either at compiled time or at runtime. Example of a fix for such a issue #131219, which might be related. Your case might be reabstraction for static virtuals though, which should be statically known. I believe we might not have all the static virtual tests enabled for mono, so might be useful to double check there first.
littletoxic commentedon Aug 4, 2026
Yes. I reproduced the same signature-mismatch trap on .NET 10 after deleting the reproduction project's
binandobjdirectories immediately before publishing.Environment:
This is a standalone Blazor WebAssembly reproduction containing only a button which loads the same 32x32 RGBA PNG into a
MemoryStreamand calls:The AOT publish succeeds and reports
AOT'ing 40 assemblies. At runtime, thebeforemarker is printed, followed by:The
aftermarker is never printed.So .NET 10 also reproduces the trap symptom. In this minimal code shape it traps rather than hanging, consistent with the original report where small reachability/stream changes switch the symptom between a trap and a hang.
I haven't retested .NET 11 Preview 7 yet. I have the standalone reproduction ready locally and can publish it as a branch of the linked repository if that would help.
pavelsavara commentedon Aug 4, 2026
I can reproduce with latest main, here is dump with symbols
pavelsavara commentedon Aug 4, 2026
static lazy rock'n roll
https://github.com/SixLabors/ImageSharp/blob/b81b9a2792b441788975eb4d2e54d470fdb168e2/src/ImageSharp/PixelFormats/PixelOperations%7BTPixel%7D.cs#L22-L25
https://github.com/SixLabors/ImageSharp/blob/main/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs#L24-L26
pavelsavara commentedon Aug 5, 2026
I reduced this to a self-contained repro with no ImageSharp dependency (so no license needed). It reproduces the exact
MONO_WASM: function signature mismatchtrap under Mono WASM AOT.Minimal repro
Actual output (Mono WASM AOT)
REPRO: after Decode<Rgba32>is never printed — the runtime traps inPixelOperations<Rgba32>..cctor(theLazy<>built from the static-abstractTPixel.CreatePixelOperationsmethod group), reached through gsharedvt-shared code.Notes on the ingredients that matter
Decode<TPixel>) must be reached through gsharedvt-shared code — here I force that viaMakeGenericMethod(...).Invoke(...); in ImageSharp it's the delegate/Func<>-driven decode path. CallingDecode<Rgba32>()directly (fully-specialized) does not trap, which is consistent with the "adding a reachable direct call fixes it" workaround in the report.Lazy<PixelOperations<TPixel>>static field initialized from the static-abstractTPixel.CreatePixelOperationsmethod group is the trigger — this is the "static lazy" shape from ImageSharp'sPixelOperations{TPixel}.Repro reproduces in both Release and Debug AOT
I verified it in-tree using
src/mono/sample/wasm/browser:The trap is not optimizer-dependent — it also reproduces in a Debug-config AOT build (via
_WasmAllowAOTDebug=true), producing the identicalfunction signature mismatch/WASM EXIT 1.Note
This comment (and the reduced repro) was prepared with the assistance of GitHub Copilot.
dotnet-policy-service commentedon Aug 5, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.