Skip to content

[WebAssembly] WebAssemblyRuntime.InvokeAsync and InvokeJSUnmarshalled depend on JavaScript that is no longer shipped #24515

Closed

Description

@MartinZikmund

Current behavior 🐛

Two public APIs on Uno.Foundation.WebAssemblyRuntime call JavaScript globals that no WebAssembly app built on the Skia renderer loads:

API JavaScript it needs What happens
InvokeAsync(string) / InvokeAsync(string, CancellationToken) Uno.UI.Interop.AsyncInteropHelper.Invoke The generated script (Runtime.wasm.cs:284-295) throws TypeError: Cannot read properties of undefined (reading 'Invoke') inside InvokeJS, so the returned Task faults.
InvokeJSUnmarshalled(string, IntPtr) / InvokeJSUnmarshalled(string, IntPtr, IntPtr) MonoSupport.jsCallDispatcher.invokeJSUnmarshalled The [JSImport] in WebAssembly.Runtime.cs:21 targets a function that does not exist. GetMethodId calls it outside any try, so the call throws.

Those globals were defined only in src/Uno.UI/ts (Interop/AsyncInteropHelper.ts, MonoSupport.ts, WindowManager.ts). The only project that compiled that TypeScript was the native WebAssembly DOM head, Uno.UI.Wasm.csproj:

  • 6.x: at 6.7.103, the Skia WebAssembly Browser runtime's tsconfig.json pulled in only ../Uno.UI/ts/types/** and WebView.ts from that folder. Uno.UI.Wasm.csproj is the only project that compiled the rest. By that inspection, these APIs worked on the native DOM renderer but never on the Skia renderer.
  • 7.0: commit c3608f4 removed the native WebAssembly DOM project heads. Since then nothing compiles src/Uno.UI/ts, so both APIs are broken for every WebAssembly app. docs: Close out the 7.0 documentation and reconciliation leftovers #24351 deletes the orphaned sources; the implementations remain in history at 6.7.103.

The 7.0 migration guide doesn't mention either API. Its legacy JS interop entry says only that InvokeJS(string) is kept as a legacy API, so both read as supported.

Expected behavior 🎯

Either:

  • both APIs work on the Skia WebAssembly renderer, or
  • they are removed (or marked obsolete) as a documented 7.0 breaking change, pointing to [JSImport]/[JSExport], as the guide already does for the rest of the legacy JS interop.

How to reproduce it (as minimally and precisely as possible) 🔬

Verified at runtime. I opened the Skia WebAssembly SamplesApp staging builds and evaluated in the browser console:

typeof Uno.UI.Interop.AsyncInteropHelper   // "undefined"
typeof Uno.UI.WindowManager                // "undefined"
typeof MonoSupport                         // ReferenceError: MonoSupport is not defined
Object.keys(Uno.UI.Interop)                // ["Runtime"]

// The exact script InvokeAsync generates, run through the same entry point InvokeJS uses:
Uno.UI.Interop.Runtime.InvokeJS("const __f = ()=>Promise.resolve('x');\nUno.UI.Interop.AsyncInteropHelper.Invoke(1, __f);")
// TypeError: Cannot read properties of undefined (reading 'Invoke')

Both builds give identical results.

Expected managed-side behavior (from the code; this C# was not run). In a Skia WebAssembly app:

// Faults: the JS TypeError surfaces from InvokeJS and InvokeAsync returns Task.FromException.
var result = await Uno.Foundation.WebAssemblyRuntime.InvokeAsync("Promise.resolve('ok')");

Workaround 🛠️

Use [JSImport]/[JSExport] from System.Runtime.InteropServices.JavaScript directly. For a promise, a [JSImport] method returning Task<string> does the same job as InvokeAsync.

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

WebAssembly

Uno.Sdk version (and other relevant versions) 📦

  • 7.0 development builds (master since c3608f4): broken for all WebAssembly apps. Verified at runtime.
  • 6.x on the Skia renderer: broken by inspection of 6.7.103. Not verified at runtime.

IDE version 🧑‍💻

N/A

Anything else we need to know? 💬

Options

  1. Restore: reimplement AsyncInteropHelper.Invoke in src/Uno.UI.Runtime.Skia.WebAssembly.Browser/ts/Runtime/, and the unmarshalled dispatcher too if it is kept. Ideally don't reintroduce eval: InvokeAsync builds and evaluates a script string today, which is the pattern [WebAssembly] Uno.UI requires 'unsafe-eval' in the page's Content Security Policy #24429 wants to remove.
  2. Remove for 7.0: drop InvokeAsync and InvokeJSUnmarshalled from WebAssemblyRuntime. That means a migrating-to-uno-7.md entry next to the existing legacy JS interop entry, plus PackageDiffIgnore.xml entries. Downstream Uno libraries may still call them, so check before choosing.

Dead code found while tracing this (safe to remove with either option):

  • src/Uno.WinRT/UI/Core/CoreWindow.Interop.wasm.cs: a SetCursor [JSImport] targeting globalThis.Uno.UI.WindowManager.current.setCursor. It has no callers; the Skia WebAssembly cursor goes through BrowserPointerInputSource's own import.
  • TSInteropMarshaller: no callers outside src/Uno.Foundation.Runtime.WebAssembly/Interop/. Not yet verified: whether TSBindingsGenerator and the tsBindings/** entries in the Uno.WinRT and Browser runtime tsconfig.json files are dead as well.
  • doc/articles/uno-development/uno-internals-wasm.md still says C# calls into JavaScript through the WindowManager TypeScript class.

Related: #24429 ('unsafe-eval' CSP requirement of the eval-based interop).

Activity

  1. added
    platform/wasm 🌐
    triage/untriaged
    on Sep 15, 2026
  2. added
    7.0
    on Oct 14, 2026
  3. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
  4. self-assigned this
    on Nov 2, 2026
  5. added 5 commits that reference this issue on Nov 2, 2026
    328d759
    ba68bdb
    de5e48a
    838d9b1
    13eb00b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

platform/wasm 🌐

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions