Repository navigation
Ship emdawnwebgpu's webgpu.cpp inside libSkiaSharp.a - #5316
Conversation
📦 Try the packages from this PRWarning 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 -- 5316PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 5316"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-5316/packages --name skiasharp-pr-5316More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-5316 |
|
Hey there @@ramezgerges! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Dawn's emdawnwebgpu port ships webgpu.cpp as source, so the WASM targets passed it, its include paths and -std=c++20 through EmccExtraLDFlags. The .NET WebAssembly SDK compiles every source on that one link line, so the -std flag also reached the app's C sources and clang rejected it: invalid argument '-std=c++20' not allowed with 'C' Any app linking a C file failed, Uno Platform 7 apps included. The native build now passes the port's directory to Skia's GN build (skiasharp_emdawnwebgpu_dir, from mono/skia), which compiles webgpu.cpp with the rest of SkiaSharp and the same per-variant flags, into libSkiaSharp.a. Apps link an object: no source, no compile flag and no DEFAULT_TO_CXX reach their link. The port's JS libraries go to the link as js-library Content, added just before the SDK writes the link response file so hosts that deploy every .js Content item (Uno Platform's bootstrapper) don't publish them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ddc778a to
88670ed
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The full native build and variant compatibility remain unvalidated, and raster-only builds have an unresolved link failure.
1 open finding
What changed in this PR
Moves emdawnwebgpu compilation into the native WASM archive so C++ flags no longer break apps linking C sources, including Uno 7 apps.
Changes:
- Passes the port directory to Skia’s native build.
- Removes source compilation flags from app linking.
- Adds JavaScript libraries immediately before linking to avoid deployment.
| File | Description |
|---|---|
| native/wasm/build.cake | Enables native compilation of the WebGPU port. |
| binding/SkiaSharp.NativeAssets.WebAssembly/buildTransitive/SkiaSharp.targets | Updates packaged link flags and JavaScript inputs. |
| binding/IncludeNativeAssets.SkiaSharp.targets | Applies matching changes to in-repository builds. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Use the squash commit from mono/skia#396 in the submodule and component manifest. Its tree matches reviewed commit f58e2b3d8a9fd645dc9e9fd78612eb3852e35d37 exactly. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f174e671-3c47-4bff-8ae6-fa4a64991ab1
[m155] Backport Skia security fixes and WASM build hook (#462) Context: mono/SkiaSharp#5797 Context: #396 Context: mono/SkiaSharp#5316 Changes: 168d720...221ae11 Backport four Google m156 security fixes and the existing WASM hook to 4.155. Preserve the m155 baseline, prior fork changes, C API and DEPS. ~~ CVE-2026-118340: image-filter cache ID wraparound ~~ 32-bit filter IDs can wrap and collide with live cache entries. Backport c68d7fd (upstream 8700229): use 64-bit filter/cache IDs and initialize key padding for byte hashing. The regression distinguishes IDs differing by 1 << 32 and checks independent cache results. ~~ CVE-2026-119261: reserved SkSL types outside declarations ~~ Private runtime-effect types alias the invalid type. Checking variable declarations misses struct fields. Backport 961c7e8 (upstream 0a8b2fc): reject aliases in Parser::type, suppress duplicate diagnostics and carry the struct-field regression and expected-error updates. ~~ CVE-2026-121086: conic region edge-buffer sizing ~~ Two budgeted edges per conic are insufficient for up to 32 subdivided quadratics and 64 monotonic edges. Backport c433a0f (upstream 50a301a): share SkConic's subdivision limit, budget the worst case and return an empty region on checked edge-count overflow. Changed lines match upstream; m155's existing array syntax explains the context difference, not a custom rewrite. Carry Region_ConicMaxEdges; its 32-span trigger requires SK_SUPPORT_LEGACY_CONIC_CHOP. ~~ CVE-2026-126912: clipped convex rasterization ~~ Right-boundary edge cancellation can leave a convex walker without both edges; stale scan positions across Y-gaps can overflow fixed-point X. Backport 0ac7dc6 (upstream 866b61c): preserve required edges, advance/flush across gaps, saturate/clamp X and reject non-positive runs. Keep SK_LEGACY_ALPHA_RUNS guards and the convex-path/oval regression. ~~ Compile the WASM port before the application's mixed-language link ~~ Compiling webgpu.cpp on the app's emcc link line applies -std=c++20 to C inputs too. Clang rejects this; Uno Platform 7's uno_gl_shim.c exposes it. Backport #396 unchanged as 221ae11. A nonempty skiasharp_emdawnwebgpu_dir on WASM builds the port into a static library that SkiaSharp depends on; unset, it adds no target or dependency. mono/SkiaSharp#5797 supplies the directory and backports the consumer changes from mono/SkiaSharp#5316. Retain mono/SkiaSharp#5316's accepted constraint: custom GPU-disabled WASM archives can omit port exports required by .NET 9+ targets. Shipping WASM packages remain GPU-enabled; this backport does not fix the unsupported custom configuration. Co-authored-by: alexis cruz-ayala <[email protected]> Co-authored-by: Nathan Sanchez <[email protected]> Co-authored-by: Thomas Smith <[email protected]> Co-authored-by: Ramez Ragaa <[email protected]> Co-authored-by: Ramez Ragaa <[email protected]> Co-authored-by: Matthew Leibowitz <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: Copilot App <[email protected]>
…5316) (#5797) * [4.155] Backport four Skia CVE fixes and the emdawnwebgpu link fix (#5316) Pin externals/skia to an m155 backport carrying four more upstream Skia security fixes, and backport #5316 (and its Skia half, mono/skia#396) so WASM apps that link C sources build again. ~~ Skia security fixes (all Chrome-assigned, Chromium severity High) ~~ - CVE-2026-118340, integer overflow leaking cross-origin data. Chromium bug 568936530, upstream 8700229923 "[skif] Update SkImageFilter_Base uniqueID to 64-bit" (M156: c68d7fd343). - CVE-2026-119261, SkSL buffer overflow. Chromium bug 574213633, upstream 0a8b2fc486 "[SkSL] Reject invalid types when parsing" (M156: 961c7e83d9). - CVE-2026-121086, heap OOB write in SkRgnBuilder for conic paths. Chromium bug 569674218, upstream 50a301ac1c (M156: c433a0fce9). - CVE-2026-126912, heap-buffer-overflow in RunBasedAdditiveBlitter and the AAA convex walker. Chromium bug 569286603, upstream reland 866b61ca92 (M156: 0ac7dc6087). Google backported these to m156 and later but not m155. All four M156 cherry-picks applied to m155 without conflicts. ~~ Ship emdawnwebgpu's webgpu.cpp inside libSkiaSharp.a (#5316) ~~ 4.155 includes #3968, so its WASM targets compile Dawn's webgpu.cpp on the app's emcc link line with -std=c++20, which clang rejects for any C source the app links (for example Uno Platform 7's uno_gl_shim.c). Build the port into libSkiaSharp.a through mono/skia#396's skiasharp_emdawnwebgpu_dir GN argument instead, and stop putting the source, -std=c++20 and DEFAULT_TO_CXX on the link line. The targets and build.cake changes are identical to #5316; only the submodule and cgmanifest pins differ. C API declarations, DEPS, managed APIs and package versions are unchanged, and upstream_merge_commit still names the last incorporated chrome/m155 commit. (cherry picked from commit 9745920) Co-Authored-By: Claude Opus 5.5 <[email protected]> * [m155] Repin Skia to the ancestry-preserving CVE repair Context: mono/skia#465 Point externals/skia and the matching component manifest entry at e6cfc7a5d6dea7e8c21a59782c672a00b1fff28c. The repaired native history contains all seven original reviewed commits from mono/skia#461 and mono/skia#462 while retaining both squash landings. The native tree is identical to reviewed head 221ae11c5318. This changes only the two pins, not the security or WASM implementation. For this combined repair, verify original-commit ancestry and tree equality explicitly rather than requiring a direct-parent relationship. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Matthew Leibowitz <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
Since #3968, the WASM targets hand Dawn's emdawnwebgpu port to the app's link as source:
webgpu.cpp, its include paths and-std=c++20all go throughEmccExtraLDFlags. The .NET WebAssembly SDK compiles every source on that oneemcclink line with the same flags, so the C++ standard also reaches any C file the app links, and clang rejects it:Clang has no per-language
-std, so no flag can serve both languages on that line. The fix is to stop compiling on it:native/wasm/build.cakepasses the port's directory to Skia's GN build asskiasharp_emdawnwebgpu_dir(added in Build emdawnwebgpu's webgpu.cpp into SkiaSharp on WASM skia#396). GN buildswebgpu.cppas a static library thatSkiaSharpdepends on, so it lands inlibSkiaSharp.acompiled with the same flags as the rest of SkiaSharp (C++20, no exceptions, optimized,NDEBUG, plus the variant's SIMD/threads/exceptions flags), with no flag list of its own to keep in sync with the port.buildTransitive/SkiaSharp.targetsand the in-repoIncludeNativeAssets.SkiaSharp.targets): the source, its include paths,-std=c++20and-s DEFAULT_TO_CXX=1are gone fromEmccExtraLDFlags. The port's four JS libraries go to the link asContentwithKind="js-library", which the SDK links as--js-library. They're added in a target just before the SDK writes the link response file, not as static items, because hosts that deploy every.jsContentitem would otherwise publish them (Uno Platform's bootstrapper does).What still reaches the link from SkiaSharp is
-s USE_WEBGL2=1.Who hits the bug today: any WASM app on 4.152 or later that links a C source of its own. Uno Platform 7's WebAssembly runtime links
uno_gl_shim.c(itsGLCanvasElementsupport), so every Uno Platform 7 WASM app fails once it moves past SkiaSharp 4.151. That's why #5174's samples needed it.Transition: the targets now expect the port inside
libSkiaSharp.a. Archives built before this change don't contain it, so linking against them (e.g. natives fetched byexternals-downloadbefore this lands on the artifact server) fails with undefinedwgpu*symbols until the WASM natives are rebuilt.Related issues
Related to #3968 (introduced the link-line compile) and #5174 (Uno Platform 7, which links a C source).
Required skia PR
Requires mono/skia#396 (this PR bumps
externals/skiato it).Areas affected
binding/)externals/skia/src/c,include/c)externals/skiabump for Build emdawnwebgpu's webgpu.cpp into SkiaSharp on WASM skia#396Changes
Behavior
WASM apps no longer compile
webgpu.cppat link time, and SkiaSharp no longer puts-std=c++20orDEFAULT_TO_CXXon their link line, so apps that link C sources build. No API change.Testing
The native build itself was not run: it's Linux-only and needs a full Skia WASM build. In its place:
gn genfor WASM with the Graphite args and the new arg://:emdawnwebgpuresolves,SkiaSharpdepends on it, andgn descshows the flags it will build with (-std=c++20 -fno-exceptions -O3 -DNDEBUG -fvisibility=hidden, the variant's-msimd128, the port's include dirs).webgpu.cppcompiled by hand with exactly those flags through the .NET WASM SDK's own emscripten (3.1.56), andemar'd into the existinglibSkiaSharp.a/3.1.56/st/libSkiaSharp.a.Against that archive, with these targets, on Windows:
net10.0-browserwasm, on the [FEATURE] Uno Platform 7.0 support for SkiaSharp.Views.Uno.WinUI #5174 branch, which also links Uno'suno_gl_shim.c): before, the link fails with the error above; after, it publishes, the link response file carries the four--js-libraryentries and no-std/ source /DEFAULT_TO_CXX, nothing from the port lands inwwwroot, and the app runs in Edge with no console errors.DEFAULT_TO_CXX, and_wgpuCreateInstance/_wgpuTextureReleasestay exported despite-fvisibility=hidden.Not covered: the
mt/simdvariants, emsdk 5.x/6.x (.NET 11), and WebGPU rendering at runtime (the Uno app renders through WebGL).Checklist
Changesabove lists all public API and behavioral changes (or "None.")///documentation and regenerated bindings when applicable: no API change.mono/skiaPR linked above and bindings regenerated: Build emdawnwebgpu's webgpu.cpp into SkiaSharp on WASM skia#396 is GN-only, no C API change, so no bindings to regenerate.🤖 Generated with Claude Code