Skip to content

[WASM] Add preview-.NET WASM test job to catch exception-handling regressions - #4488

Merged
mattleibow merged 1 commit into
mainfrom
mattleibow-net11-wasm-tests
Jul 20, 2026
Merged

mattleibow merged 1 commit into
mainfrom
mattleibow-net11-wasm-tests

Conversation

@mattleibow

@mattleibow mattleibow commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds automated preview-.NET WebAssembly regression coverage by running the existing tests/SkiaSharp.Tests.Wasm suite as the preview .NET (currently net11) in CI. It is off by default; only this one test job opts in, so the rest of CI stays on net10 and the shipping TFMs are unchanged.

Why

The emsdk 5.0.6 WASM libSkiaSharp can emit legacy wasm exception-handling instructions while the preview .NET links WASM apps with the new exnref model (WASM_LEGACY_EXCEPTIONS=0). Mixing them makes the WASM app fail at runtime in the browser with:

CompileError: WebAssembly.compileStreaming(): module uses a mix of legacy and new exception handling instructions

There was no CI test that would have caught this. This PR is that guard: it runs the real WASM suite on the preview runtime, so an EH mismatch — or any preview-runtime WASM breakage — turns the build red.

How

  • source/SkiaSharp.Build.props — opt-in UsePreviewTFM toggle (default off): shifts the .NET version window forward one release (dropping the now-EOL oldest version) so projects build cleanly under a preview .NET SDK.
  • scripts/infra/tests/tests-wasm.cake — --previewtfm=true runs the suite with -p:UsePreviewTFM=true. The cake is the run; it does not provision.
  • scripts/azure-templates-jobs-bootstrapper.yml — reusable installPreviewSdk + previewWorkloads params (install the preview SDK, pin global.json to it, install the requested preview workloads) so other jobs can opt into a preview-runtime run.
  • scripts/azure-templates-variables.yml — DOTNET_VERSION_PREVIEW + DOTNET_WORKLOAD_VERSION_PREVIEW (default DOTNET_VERSION stays net10).
  • scripts/azure-templates-stages-test.yml — tests_wasm_preview_linux job (consumes the native artifact, installPreviewSdk: true, previewWorkloads: wasm-tools, runs tests-wasm --previewtfm=true). The net10 tests_wasm_linux job is unchanged.

Validation

Locally verified end-to-end both paths (preview SDK, DeviceRunners headless browser, real 5.0.6 st,simd natives from CI artifacts):

  • Pass path (new-EH _wasmeh,_newexc,st,simd lib): the module compiles and the suite runs (1180 total / 1081 passed / 0 failed / 99 skipped).
  • Fail path (legacy-EH _wasmeh,st,simd lib, i.e. main today): the browser fails with the exact module uses a mix of legacy and new exception handling instructions CompileError and the job goes red.

Note on branching

This is currently based on main, which has the 5.0.6 native builds but not the EH fix (PR #4487), so the tests_wasm_preview_linux job is expected to be red here — that red is the negative control proving the guard works. Once #4487 lands on main (5.0.6 built with _newexc) and this branch is rebased, it goes green.

@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 -- 4488

PowerShell / Windows:

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

Step 2 — Add the local NuGet source

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

@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch from bf9517c to ec5b6ce Compare July 20, 2026 14:47
@mattleibow
mattleibow changed the base branch from mattleibow-dev-wasm-net11-exception-handling to main July 20, 2026 14:47
@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch from ec5b6ce to 1db9168 Compare July 20, 2026 15:06
@mattleibow
mattleibow changed the base branch from main to mattleibow-dev-wasm-net11-exception-handling July 20, 2026 15:10
@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch from 1db9168 to 256341e Compare July 20, 2026 15:21
@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.

@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch from 256341e to dcfd80c Compare July 20, 2026 15:51
@mattleibow
mattleibow changed the base branch from mattleibow-dev-wasm-net11-exception-handling to main July 20, 2026 15:51
@mattleibow

mattleibow commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor Author

⚠️ The tests_wasm_preview_linux job is expected to be RED here — this is the negative control

This PR is based on main, which has the 5.0.6 WASM native builds (#4459) but not the exnref exception-handling fix (#4487). So main builds libSkiaSharp with legacy wasm EH, and running the new net11 WASM test against it reproduces exactly the regression this test is meant to catch:

MONO_WASM: instantiate_wasm_module() failed CompileError:
WebAssembly.compileStreaming(): Compiling function #14265 failed:
module uses a mix of legacy and new exception handling instructions

The app never boots, so the DeviceRunners runner hits its 300s --timeout and exits non-zero → the job goes red (a bounded timeout failure, not a hang or a silent pass).

Both paths were validated locally with real 5.0.6/st,simd natives pulled from CI artifacts:

Native lib Outcome
new-EH (_wasmeh,_newexc,st,simd, from #4487 build) module compiles, suite runs 1180 total / 1081 passed / 0 failed / 99 skipped → ✅ green
legacy-EH (_wasmeh,st,simd, current main) mix of legacy and new exception handling instructions CompileError → ❌ red

This goes green once #4487 lands on main (5.0.6 rebuilt with _newexc → new-EH) and this branch is rebased. The red here is proof the guard works.

@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch from dcfd80c to 9e6f6d2 Compare July 20, 2026 16:43
@mattleibow mattleibow changed the title [WASM] Add .NET 11 WASM test job to catch exception-handling regressions [WASM] Add preview-.NET WASM test job to catch exception-handling regressions Jul 20, 2026
@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch 2 times, most recently from e56507f to 8a7b683 Compare July 20, 2026 20:41
@mattleibow mattleibow added this to the 4.151.0-rc.1 milestone Jul 20, 2026
…ressions

Runs the existing tests/SkiaSharp.Tests.Wasm suite as the preview .NET (net11) so a
legacy/new WASM exception-handling mismatch in the emsdk 5.0.6 native libSkiaSharp
(which fails at runtime in the browser with "module uses a mix of legacy and new
exception handling instructions") — or any WASM breakage on the newer runtime —
turns CI red. The preview runtime is used for TESTS ONLY; net10 stays the default
for all other CI.

- source/SkiaSharp.Build.props: add opt-in UsePreviewTFM toggle (default off) that
  shifts the TFM window forward (current=net11, previous=net10), dropping the now-EOL
  net9.0 so projects build cleanly under a preview .NET SDK.
- scripts/infra/tests/tests-wasm.cake: add --previewtfm=true, which runs the suite
  with -p:UsePreviewTFM=true. The cake is the run; it does not provision.
- scripts/azure-templates-jobs-bootstrapper.yml: add reusable installPreviewSdk +
  previewWorkloads parameters that install the preview SDK, pin global.json to it, and
  install the requested workloads (via the shared install-dotnet-workloads.ps1, pinned
  to the exact preview workload set) — so other jobs can opt into a preview run.
- scripts/azure-templates-variables.yml: add DOTNET_VERSION_PREVIEW and
  DOTNET_WORKLOAD_VERSION_PREVIEW (default DOTNET_VERSION stays net10).
- scripts/azure-templates-stages-test.yml: add tests_wasm_preview_linux job (consumes
  the native artifact, installPreviewSdk=true, previewWorkloads=wasm-tools,android, runs
  tests-wasm --previewtfm=true). The android workload is needed because the WASM test
  still restores the -android TFMs of referenced projects. tests_wasm_linux (net10) is
  unchanged.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: a10a6eaa-d107-41bc-bc5c-1357d9ef2408
@mattleibow
mattleibow force-pushed the mattleibow-net11-wasm-tests branch from 8a7b683 to 3834671 Compare July 20, 2026 21:39
@mattleibow
mattleibow merged commit 4d56e00 into main Jul 20, 2026
26 of 88 checks passed
@mattleibow
mattleibow deleted the mattleibow-net11-wasm-tests branch July 20, 2026 23:11
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.

1 participant