-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebAssembly fails to generate trampoline for delegates decorated with UnmanagedFunctionPointer
#76930
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionI'm updating a project from dotnet 6 to dotnet 7, which uses WebGL, and WaveEngine/Evergine's OpenGL bindings, these bindings declare functions that can be called dynamically thru a pointer like so: [UnmanagedFunctionPointer(CallConv)]
private delegate void glClearDepth_t(double depth);
private static glClearDepth_t p_glClearDepth;
public static void glClearDepth(double depth) => p_glClearDepth(depth); Invoking this function from BlazorWebassembly results in the following error being raised: Reproduction StepsOn either net7 rc.1 or rc.2, The https://github.com/AshleighAdams/dotnet-webgl-sample/tree/dotnet7 Expected behaviorExpected the invocation to succeeed and subsequently the canvas cleared Actual behaviorAn error ir raised with just "disabled". The full stacktrace is:
Regression?Yes, this is a regression. This worked in .NET 6 Known WorkaroundsIf you force the trampoline to be generated by adding the following, and if AOTing, add [DllImport("libEGL", EntryPoint = "glClearColor")]
internal static extern void glClearColor_tramp(float red, float green, float blue, float alpha); Configuration$ dotnet --info Runtime Environment: Host: .NET SDKs installed: .NET runtimes installed: Other architectures found: Environment variables: global.json file: Learn more: Download .NET: Other informationNo response
|
…r] in the interp-to-native generator. Fixes dotnet#76930.
#77709) * [mono][wasm] Handle delegates decorated with [UnmanagedFunctionPointer] in the interp-to-native generator. Fixes #76930. * Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain <radical@gmail.com> Co-authored-by: Ankit Jain <radical@gmail.com>
…r] in the interp-to-native generator. Fixes #76930.
…FunctionPointe… (#78426) * [mono][wasm] Handle delegates decorated with [UnmanagedFunctionPointer] in the interp-to-native generator. Fixes #76930. * Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain <radical@gmail.com> * Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain <radical@gmail.com> Co-authored-by: Zoltan Varga <vargaz@gmail.com> Co-authored-by: Ankit Jain <radical@gmail.com>
Description
I'm updating a project from dotnet 6 to dotnet 7, which uses WebGL, and WaveEngine/Evergine's OpenGL bindings, these bindings declare functions that can be called dynamically thru a pointer like so:
(https://github.com/EvergineTeam/OpenGL.NET/blob/master/OpenGLGen/Evergine.Bindings.OpenGL/GL.cs#L97-L100)
Invoking this function from BlazorWebassembly results in the following error being raised:
Reproduction Steps
On either net7 rc.1 or rc.2,
The
dotnet7
branch over here has a minimal sample that triggers the bug:https://github.com/AshleighAdams/dotnet-webgl-sample/tree/dotnet7
Expected behavior
Expected the invocation to succeeed and subsequently the canvas cleared
Actual behavior
An error ir raised with just "disabled". The full stacktrace is:
Regression?
Yes, this is a regression. This worked in .NET 6
Known Workarounds
If you force the trampoline to be generated by adding the following, and if AOTing, add
-s ERROR_ON_UNDEFINED_SYMBOLS=0
toEmccFlags
, then everything works as expected:Configuration
$ dotnet --info
.NET SDK:
Version: 7.0.100-rc.2.22477.23
Commit: 0a5360315a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\
Host:
Version: 7.0.0-rc.2.22472.3
Architecture: x64
Commit: 550605c
.NET SDKs installed:
5.0.404 [C:\Program Files\dotnet\sdk]
6.0.201 [C:\Program Files\dotnet\sdk]
6.0.401 [C:\Program Files\dotnet\sdk]
7.0.100-preview.6.22352.1 [C:\Program Files\dotnet\sdk]
7.0.100-rc.2.22477.23 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-preview.6.22330.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-preview.6.22324.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-preview.6.22351.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.2.22472.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
arm64 [C:\Program Files\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Other information
No response
The text was updated successfully, but these errors were encountered: