Skip to content

fix(wasm): Link SkiaSharp's emdawnwebgpu when it brings one - #26254

Merged
ramezgerges merged 3 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-skiasharp-emdawn
Nov 9, 2026
Merged

ramezgerges merged 3 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-skiasharp-emdawn

Conversation

@ramezgerges

@ramezgerges ramezgerges commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #26253

PR Type:

🐞 Bugfix

What changed? 🚀

SkiaSharp 4.155+ links its own copy of Dawn's emdawnwebgpu into every WebAssembly app. Uno's WebGPU backend links the same emdawnwebgpu release through --use-port, so an app with both Skia and the WebGPU backend (the SamplesApp always has both) loads the same four JS libraries twice and the link fails:

SyntaxError: Identifier 'structInfo32' has already been declared

This blocks the SkiaSharp bump in #26165 (#26179).

Both copies are the same Dawn release (v20260624.223603), and their webgpu.h matches the standard header Uno's binding is generated from: the same 202 functions, 86 struct layouts and 493 enum values. So when SkiaSharp brings a copy, Uno now links that one instead of its own:

  • Uno.WinUI.Composition.WebGpu.targets:
    • _UnoWebGpuLinkEmdawn adds Uno's --use-port (and -sDEFAULT_TO_CXX=1) at link time, and only when SkiaSharp doesn't link emdawnwebgpu itself. That check covers both 4.155, which passes link flags, and 4.156+, which adds js-library content. It runs in a target because SkiaSharp's properties may not be set yet while the project loads.
    • _UnoWebGpuExportRuntimeObject exports the WebGPU runtime method, deduplicated against SkiaSharp's export.
  • WebGpuInit.ts imports the JS-created device and offscreen texture, and resolves readback buffers, through the stock Module.WebGPU (importJsDevice, importJsTexture, Internals.jsObjects). Both copies export it. Before, it used aliases that only Uno's patched copy defined.
  • wgpu-wasm.targets no longer adds those aliases. It keeps the stackSave/stackRestore patch, which SkiaSharp's copy carries too.
  • When SkiaSharp brings Dawn, emcc keeps the app's cache (the SDK's frozen one by default) instead of Uno's writable copy, which is seeded with 400-500 MB of the SDK's cache and is only needed to build Uno's port.

Apps on SkiaSharp without emdawnwebgpu (4.151.1, today's default), and WebGPU apps without Skia, keep linking Uno's copy.

Validation:

  • Compile: WASM SamplesApp publish (the CI Build Wasm Skia Head command) on this branch, with -p:SkiaSharpVersion=4.156.0-rc.1.26553.11 and with the default 4.151.1.
    • 4.156: the link has only SkiaSharp's copy, with no Uno --use-port or -sDEFAULT_TO_CXX.
    • 4.151.1: the link has only Uno's port.
    • Both export WebGPU once.
  • Runtime: in Edge with WebGPU on SwiftShader and env=UNO_WEBGPU=1, Given_RenderTargetBitmap passed 6/6 on both builds. Those tests cover device import, offscreen texture import and buffer readback.
  • Not run: the full WASM suites and the SkiaSharp 4.155.0 packaging. The cache change (b988e8f) was pushed without a local rebuild.

PR Checklist ✅

🤖 Generated with Claude Code

SkiaSharp 4.155+ links its own copy of Dawn's emdawnwebgpu into every
WebAssembly app. With Uno's WebGPU port also linked, emcc loads the same
JS libraries twice and the link fails ("Identifier 'structInfo32' has
already been declared"). Both copies are the same release and the same
standard webgpu.h ABI, so drop Uno's port when SkiaSharp provides one.

WebGpuInit.ts now reaches emdawnwebgpu through Module.WebGPU, which both
copies export, instead of the Module aliases only Uno's patched copy had.

Fixes unoplatform#26253

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

ramezgerges and others added 2 commits November 9, 2026 12:36
Decide at link time whether Uno's port is needed instead of adding it
while the project loads and removing it again when SkiaSharp brings its
own copy. This also leaves out Uno's -sDEFAULT_TO_CXX=1 in that case.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Uno's targets point emcc at a writable cache, seeded with a copy of the
SDK's (400-500 MB), only so emcc can build Uno's emdawnwebgpu port. When
SkiaSharp links its own copy there is no port to build, so keep the app's
cache, the SDK's frozen one by default, as an app with SkiaSharp alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@ramezgerges
ramezgerges enabled auto-merge November 9, 2026 18:54
@ramezgerges
ramezgerges merged commit 3c04a4e into unoplatform:master Nov 9, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WASM link fails with SkiaSharp 4.155+ and the WebGPU backend: 'structInfo32' has already been declared

4 participants