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

Web Assembly doesn't work after following documentation #16989

Closed
davidgiga1993 opened this issue Sep 11, 2024 · 12 comments · Fixed by #17362
Closed

Web Assembly doesn't work after following documentation #16989

davidgiga1993 opened this issue Sep 11, 2024 · 12 comments · Fixed by #17362

Comments

@davidgiga1993
Copy link

davidgiga1993 commented Sep 11, 2024

Describe the bug

When following the steps described in the documentation and running the web server using dotnet run the web app can't load due to 404 http://127.0.0.1:62860/_framework/avalonia.js

To Reproduce

Follow the guide, effectively:

dotnet workload install wasm-tools
dotnet new install avalonia.templates
mkdir BrowserTest
cd BrowserTest
dotnet new avalonia.xplat
cd BrowserTest.Browser
dotnet run

Expected behavior

The sample app should work

Avalonia version

11.1.0

OS

WebAssembly

Additional context

The template used <TargetFramework>net8.0-browser</TargetFramework>, but I also tested with net9.0-browser.

I've also noticed that the path described in the documentation under Testing AppBundle locally doesn't seem to be correct (or at least for me this doesn't match up at all, maybe it's related to the issue above?)

@maxkatz6
Copy link
Member

Make sure you have up-to-date .NET SDK installed. I.e. latest patch releases.
There were reports of similar problems on older .NET 8 builds.

@davidgiga1993
Copy link
Author

Yep I actually just installed .net sdk 9 (rc1) when going through the document, so should be latest

@houstonhaynes
Copy link

houstonhaynes commented Sep 16, 2024

FYI - I'm running into a marginally related issue #17036

@hypeartist
Copy link

hypeartist commented Sep 20, 2024

Same here. Latest.NET (RC1), Avalonia 11.1.0.
PS: After changing project target to net9-browser and Avalonia 11.1.3 error changed from not finding avalonia.js into:
image

@maxkatz6
Copy link
Member

@davidgiga1993 you are running "net8.0" target on .NET 9 SDK. .NET Runtime team sometimes breaks compatibility between SDK versions, especially with WASM workloads.
If you want to run "net8.0", which is in stable, but using .NET 9 SDK, then you need to install another workload dotnet workload install wasm-tools-net8. As confusing it is.
We probably should add a general advice in our documentation to keep these versions in sync.

I just tested, and net8.0-browser target works well with .NET 9 SDK with wasm-tools-net8.

As for another issue when you switch to net9.0-browser, somebody of you should report it to https://github.com/dotnet/runtime.

@maxkatz6
Copy link
Member

Just added wasm-tools-net8 note to our documentation AvaloniaUI/avalonia-docs#548

@maxkatz6
Copy link
Member

Also, thanks for noticing that dotnet publish output path was changed. I updated documentation accordingly.

@maxkatz6
Copy link
Member

.NET 9 issue is most likely caused by .NET runtime migrating to a newer Emnscripten version: dotnet/runtime#100334
We are blocked on SkiaSharp release, which should happen before .NET 9 stable release.

@gpatrut-matica
Copy link

gpatrut-matica commented Oct 3, 2024

I'm actually running in the same issue. I started with a clean slate. Ran all the commands in the documentation and when I went and tried running the browser project I got the missing "_framework/avalonia.js" issue. I did not change anything in the project.

.NET SDK 8.0.400
Avalonia 11.1.0
Both projects have <TargetFramework>net8.0</TargetFramework> and <TargetFramework>net8.0-browser</TargetFramework>

I tried running it with .NET 9 and the wasm-tools-net8 workload, no luck, altought I could not even build the project as I got a gigantic dump of text in the output console (none with useful information to be honest).

Edit:
I ran all the commands again now the same behaviour I experienced when running .NET 9 with wasm-tools-net8 is happening, I can no longer build the project at all. The output console got filled logs of which I'm not getting any useful information...
You can check the full log here.

@maxkatz6
Copy link
Member

maxkatz6 commented Oct 3, 2024

@gpatrut-matica I can't help you without project itself, and the best I can advice:

  1. Recreate Browser project from the template (it was changed between 11.0 and 11.1).
  2. Make sure you have latest .NET 8 SDK patches
  3. Latest Avalonia itself (11.1.0 is OLD)

@houstonhaynes
Copy link

Thanks - still recovering from a hurricane hit in Asheville, NC but will give it a try as soon as other matters have settled down. 👍

@ztl8702
Copy link

ztl8702 commented Oct 6, 2024

I can confirm that .NET 9 SDK targeting net8.0-browser with wasm-tools-net8 workload works for me. I am using the Avalonia.XPlat template from Avalonia.Templates::11.1.0 and manually updated Avalonia version to 11.1.3.

I also noticed:

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.

6 participants