Skip to content
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

Project fails to load in a browser with a cryptic error in 11.2 #17416

Closed
BAndysc opened this issue Nov 2, 2024 · 4 comments · Fixed by #17507
Closed

Project fails to load in a browser with a cryptic error in 11.2 #17416

BAndysc opened this issue Nov 2, 2024 · 4 comments · Fixed by #17507

Comments

@BAndysc
Copy link
Contributor

BAndysc commented Nov 2, 2024

Describe the bug

After an upgrade to Avalonia 11.2, my wasm project stopped working, I can only see this in the console:

  | Ll | @ | invoke-js.ts:116
-- | -- | -- | --
  | Promise.then |   |  
  | mo | @ | marshal-to-cs.ts:329
  | (anonymous) | @ | marshal-to-cs.ts:83
  | (anonymous) | @ | invoke-js.ts:202
  | Ll | @ | invoke-js.ts:276
  | $do_icall | @ | dotnet.native.wasm:0x63110d
  | $do_icall_wrapper | @ | dotnet.native.wasm:0x62c052
  | $mono_interp_exec_method | @ | dotnet.native.wasm:0x61df64
  | $interp_runtime_invoke | @ | dotnet.native.wasm:0x62d967
  | $mono_jit_runtime_invoke | @ | dotnet.native.wasm:0x742bcb
  | $do_runtime_invoke | @ | dotnet.native.wasm:0x70342b
  | $mono_runtime_invoke_checked | @ | dotnet.native.wasm:0x7033c5
  | $mono_runtime_try_invoke_byrefs | @ | dotnet.native.wasm:0x709ade
  | $ves_icall_InternalInvoke | @ | dotnet.native.wasm:0x6ced5f
  | $ves_icall_InternalInvoke_raw | @ | dotnet.native.wasm:0x6d7bd6
  | $do_icall | @ | dotnet.native.wasm:0x6311c6
  | $do_icall_wrapper | @ | dotnet.native.wasm:0x62c052
  | $mono_interp_exec_method | @ | dotnet.native.wasm:0x61df64
  | $interp_runtime_invoke | @ | dotnet.native.wasm:0x62d967
  | $mono_jit_runtime_invoke | @ | dotnet.native.wasm:0x742bcb
  | $do_runtime_invoke | @ | dotnet.native.wasm:0x70342b
  | $mono_runtime_try_invoke | @ | dotnet.native.wasm:0x703eab
  | $mono_runtime_invoke | @ | dotnet.native.wasm:0x706a28
  | $mono_wasm_invoke_method_bound | @ | dotnet.native.wasm:0x8d871a
  | (anonymous) | @ | dotnet.native.8.0.10.zsxk4nykel.js:936
  | ccall | @ | dotnet.native.8.0.10.zsxk4nykel.js:8977
  | (anonymous) | @ | dotnet.native.8.0.10.zsxk4nykel.js:8996
  | kr | @ | invoke-cs.ts:273
  | l.javaScriptExports.call_entry_point | @ | managed-exports.ts:60
  | Fc | @ | run.ts:44
  | (anonymous) | @ | main.js:13

To Reproduce

  1. Clone https://github.com/BAndysc/Classic.Avalonia
cd samples/AvaloniaVisualBasic.Browser
dotnet run
  1. See it fails to load.

You can also change versions to 11.1 in Directory.Build.props to see the same solution worked fine before:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <AvaloniaVersion>11.1.4</AvaloniaVersion>
        <ClassicAvaloniaVersion>11.2.0.0</ClassicAvaloniaVersion>
        <DockVersion>11.1.0.4</DockVersion>
    </PropertyGroup>
</Project>

(also open TimePicker.axaml and remove line 279)

Expected behavior

No response

Avalonia version

11.2

OS

WebAssembly

Additional context

No response

@maxkatz6
Copy link
Member

maxkatz6 commented Nov 5, 2024

@BAndysc Classic.Avalonia works for me here on BAndysc/Classic.Avalonia@afd034b commit:

Screenshot 2024-11-04 at 6 08 35 PM

@maxkatz6
Copy link
Member

maxkatz6 commented Nov 5, 2024

Can you try to update your .NET SDK to latest stable builds? Update workloads. If you use .NET 9 SDK, you also need to install wasm-tools-net8 (or change target framework to net9, while still installing wasm-tools workload). Resetting browser cache might also work.

@BAndysc
Copy link
Contributor Author

BAndysc commented Nov 5, 2024

Thanks for the response, wow, so in the end I was able to run it.

  1. .NET 8.0.403 (latest as of now) + <TargetFramework>net8.0</TargetFramework>
    Upgrading to the latest .NET 8 didn't change anything, same error with Avalonia 11.2, no error with Avalonia 11.1.4

  2. .NET 9.0.100-rc.2.24474.11 (latest as of now) + <TargetFramework>net8.0</TargetFramework> + workload wasm-tools-net8
    The same as the above.

  3. .NET 9.0.100-rc.2.24474.11 (latest as of now) + <TargetFramework>net9.0</TargetFramework>
    I had to apply this workaround, due to a bug in .NET 9, with it Avalonia 11.2 works, but Avalonia 11.1.4 stopped working with an error:

marshal-to-js.ts:420 Uncaught ManagedError: One or more errors occurred. (Error: AvaloniaDOM.getGlobalThis must be a Function but was undefined
    at http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:170312
    at http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:170386
    at Fc (http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:171742)
    at dotnet.native.wasm.do_icall (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2074]:0x12b9cb)
    at dotnet.native.wasm.do_icall_wrapper (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[1993]:0x127e4d)
    at dotnet.native.wasm.mono_interp_exec_method (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[1984]:0x1191ea)
    at dotnet.native.wasm.interp_entry (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2063]:0x12b014)
    at dotnet.native.wasm.interp_entry_static_0 (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2107]:0x12cf1e)
    at dotnet.native.wasm.wasm_native_to_interp_System_Threading_System_Private_CoreLib_ThreadPool_BackgroundJobHandler (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[31277]:0x8e6eb2)
    at dotnet.native.wasm.mono_background_exec (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[3056]:0x16149d))
    at http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:170312
    at http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:170386
    at Fc (http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:171742)
    at dotnet.native.wasm.do_icall (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2074]:0x12b9cb)
    at dotnet.native.wasm.do_icall_wrapper (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[1993]:0x127e4d)
    at dotnet.native.wasm.mono_interp_exec_method (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[1984]:0x1191ea)
    at dotnet.native.wasm.interp_entry (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2063]:0x12b014)
    at dotnet.native.wasm.interp_entry_static_0 (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2107]:0x12cf1e)
    at dotnet.native.wasm.wasm_native_to_interp_System_Threading_System_Private_CoreLib_ThreadPool_BackgroundJobHandler (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[31277]:0x8e6eb2)
    at dotnet.native.wasm.mono_background_exec (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[3056]:0x16149d))
    at sn (http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:26907)
    at Kt.resolve_or_reject (http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:26462)
    at http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:172539
    at http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:172603
    at fr (http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:35059)
    at Fc (http://localhost:5235/_framework/dotnet.runtime.ju77aherdp.js:3:172186)
    at dotnet.native.wasm.do_icall (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2074]:0x12b9b8)
    at dotnet.native.wasm.do_icall_wrapper (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[1993]:0x127e4d)
    at dotnet.native.wasm.mono_interp_exec_method (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[1984]:0x1191ea)
    at dotnet.native.wasm.interp_entry (http://localhost:5235/_framework/dotnet.native.m2ecb8aszw.wasm:wasm-function[2063]:0x12b014)

So the latest Avalonia + latest .NET 9 combo seem to work. Is it what you used? I am not sure if Avalonia 11.2 + .NET 8 are worth further investigation, I am satisfied with the results, so to me the issue can be closed, but there is something weird (I guess to some degree the whole .net wasm is weird :)))

@maxkatz6
Copy link
Member

maxkatz6 commented Nov 5, 2024

@BAndysc no, I was able to run .NET 8 project with no changes, on .NET 9 SDK (with correct workloads).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants