Get the full WebAssembly pipeline working for much smaller web build#417
Conversation
| @@ -1,4 +1,4 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
| <Project Sdk="Microsoft.NET.Sdk.WebAssembly"> | |||
There was a problem hiding this comment.
Problem exists between line 1 and line 2
| // identify runtime/assembly payloads | ||
| const isBootResource = (url, res) => { | ||
| const u = (typeof url === "string" ? url : url.url || "").toLowerCase(); | ||
|
|
There was a problem hiding this comment.
Not too sure, but after getting publish working regular Visual Studio launched builds wouldn't work. Gemini suggested this and it fixed it.
|
It doesn't load in browser when I build it as release. I get this error: System.DllNotFoundException: libSkiaSharp I built it using and then ran it with I wanted to test the performance. The performance was really bad before we added AoT and you disabled AoT so I have doubts (but things may have improved in .NET 10). |
|
Also, the web app is currently hosted as a GitHub Pages site, and they do not serve precompressed .gz or .br files even if they exist. It will just do on-the-fly Gzip compression. So generating those files won't help unless we change to something else (which I don't think is worth it.) It's good to have the option to generate them in the future tho. |
|
Here's exactly what I did to build and serve it: H:\Emulation\Z2Randomizer-dev\CrossPlatformUI.Browser>dotnet publish -c Release I can also, in Visual Studio, open it with CrossPlatformUI.Browser -> Debug -> Start New Instance / Start Without Debugging. Both methods allow me to load it and generate a ROM. Not clear what's different for you. |
Hum. That sucks. |
|
Thanks for clarifying. I got it working too. I had to reinstall wasm-tools (at least I think that was it). Hm... it's definitely slower than the current live version that has AoT for me. If you find a flag & seed combination that takes a little while to generate, you can compare with the same seed on https://z2r.app/ |
|
So getting trimming working turned out to be easier than I expected. Actually I took one look at the 806 trim warnings it generated and assumed it was not going to work, without seeing that the AppBundle version itself had as many trim warnings, and both work just fine. Thus I can add trimming and AOT to this PR. Now, there were two things I didn't realize before this PR:
That changes the value equation. The uncompressed AppBundle directory before this PR is 105 MB (estimated to be ~30 MB compressed on the fly). This PR, with trimming and AOT, is 85 MB uncompressed, or 20% smaller. According to Gemini it's possible to manually download and decompress the compressed files in main.js, but that's beyond my capabilities. If somebody can get that working that would bring it down to like 17 MB, or 45% smaller than pre-PR compressed form. |
|
Running dotnet serve with --gzip and --brotli respectively, and fully reloading the page gave me these numbers: 28.6 MB downloaded with gzip It would be a small further improvement but does not seem worth it. Anyway, this looks good to me now. I will squash and merge this to main |
Previously the web version was using a frankenbuild that wasn't doing important WASM steps like compressing files. This PR gets it properly set up for a WASM build. This reduces the files published from 61.7 MB to 14.2 MB.
Currently trimming is disabled. It may be possible to shrink it another few megs by getting trimming working, but it will take additional work.