runtime: WASM: GL object no longer accessible in .net 7 (Skiasharp)

Description

If you have a wasm-browser or blazor wasm app.

In .net 6 ES6 module (iiuc) were not used… that means that the javascript that gets added to dotnet.js

image

This added js (note the var GL =… etc)

becomes global and allows webgl interop in skiasharp and others.

Now the ES6 modules are used… my understanding is that this is no longer accessible outside of dotnet.js.

Reproduction Steps

clone --recursive https://github.com/AvaloniaUI/Avalonia/tree/features/blazorless-wasm

cd into src/Web/Avalonia.Web.Sample

dotnet run

then open in dev tools, put a breakpoint in line 5794 dotnet.js, confirm GL object created.

note that in main.js its lost from scope, after dotnet runtime create() function ends.

Expected behavior

some mechanism to capture this variable or for this to be global.

Actual behavior

no longer available.

Regression?

yes, this worked fine in net 6 and many libraries are relying on this.

Known Workarounds

No response

Configuration

No response

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 18 (16 by maintainers)

Most upvoted comments

I got this working again by writing a bit of JS and doing a call in that to set it up: https://github.com/mono/SkiaSharp/pull/2268

re:EXPORTED_RUNTIME_METHODS, we can add a property to allow extending it.