6 ms·
Kinda hard to find actually working WASM showcases, but this one... https://uado.platform.uno/ https://uado.platform.uno/ ...loads 8.1 MBytes compressed (32 M
by flohofwoe 6y ago
Kinda hard to find actually working WASM showcases, but this one...
https://uado.platform.uno/ https://uado.platform.uno/
...loads 8.1 MBytes compressed (32 MBytes uncompressed) until the login button appears.
This simple calculator:
https://calculator.platform.uno/ https://calculator.platform.uno/
...10.1 MBytes compressed, 53.8 MBytes uncompressed. Needs a splashscreen and 10 seconds to start (on a 50 MBit connection)
It's one thing to "simply" port some cross-platform-code to WASM and make it run in the browser, but making it a proper web application takes some actual effort. I feel that "efforts" like this just give WASM a bad reputation. Sorry to be blunt.
- tasogare 6y agoThe CLR and BLC provided a lot of services, of course this code taking some space. It’s totally a WASM problem since there is not other way to ship the C# runtime and libraries than downloading them each time. Exactly what plugins (Flash, Silverlight) were avoid...
- achn 6y agoThere are some big improvements in .net 5 that allow more granular linking and should help reduce solitary binary size, and that may trickle down to Mono and Wasm soon.
- flohofwoe 6y agoIMHO the main problem is choosing a language which needs a big runtime in the first place. UNO seems to be at a point where the Unity game engine was about 5 years ago in their asm.js/WASM efforts. In the end they realized that it's impossible to get the .NET runtime small enough for the web (at least for typical C# code which uses common standard library features). The way Unity solves this is by creating their own C# dialect, compiler and minimal runtime (without GC etc). Sort of a brute-force approach, but until the standard .NET ecosystem solves the bloat problem it would have been better to build on a different language ecosystem.
- withinboredom 6y agoThis is basically the same thing that Android did with Java. I think it’s probably best to pick a productive language and solve the problem from there. Low level languages are rough to work with when compared to what you get from unity.
- kevingadd 6y agoWhile you're correct that Unity "solved" the problem, you can't generalize their solution to things other than games. You end up needing a bunch of custom ecosystems for specific problems and when we're talking about enterprise, education, etc apps they often end up needing everything because sometimes you just end up with a massive Our Company's App that has 20 different responsibilities. To put it another way: Adobe can ship Photoshop using Emscripten, and big companies can probably eventually ship their internal C# business apps using Uno or Blazor, but you're not going to ship either of those using Unity's stock approach without building out all of the platform APIs they stripped out and adding back runtime features that were removed. The decisions they made were perfect for games, but people building general-purpose platforms can't cut all those corners.
- gamblor956 6y agoUnity has supported the .Net Framework (using .Net 4x) for several years... However, they do not guarantee that the APIs in the .Net framework will work on all platforms, as some of them are still Windows specific. https://docs.unity3d.com/2019.1/Documentation/Manual/dotnetProfileSupport.html https://docs.unity3d.com/2019.1/Documentation/Manual/dotnetP...
- gamblor956 6y agoUnity uses normal C#. They switched to using the Rosyln compiler several years ago. https://yadiyasheng.medium.com/confusing-threesome-in-unity-c-mono-and-il2cpp-df2a2e85949a https://yadiyasheng.medium.com/confusing-threesome-in-unity-... They do take the IL generated by Rosyln and convert it to executable code using their own custom transpiler.
- 6y ago
- madeofpalk 6y agoIs this a "WASM" problem or is a "hey we decided to ship all of C# to the browser" problem? I think this is a fine tradeoff for certain contexts and usages, but I don't think the general usecase for WASM is to build general web applications in C# and ship all of the CLR for things like gmail.
- flohofwoe 6y agoThere's some inherent overhead in a .NET runtime which will be hard to get rid of, like the garbage collector. In the end it probably comes down to .NET being "too dynamic", making it hard to identify and eliminate dead code. Also typical high-level C# code tends to use a lot of 'standard library' features, basically the opposite of the 'embedded coding mindset' needed for small WASM apps.
- jlaban-uno 6y ago- Uno dev here If anything, the BCL or common libraries are too "static", where some pieces of code reference statically all features available. One great example is JSON.NET: That library has basically one big method that type-checks all possible inputs, making unconditionally reachable every dependency for all features of the library. In this case, JSON.NET pulls the XML reader, DataSets, and many huge libraries that are generally not needed. In Uno, we generally don't AOT those libraries and use the interpreter for that (otherwise the payload would explode). Such libraries need to be changed to be configurable, and dynamically enable dependencies as per the user's needs. Conversely, many pieces of code are excluded by configuration because of reflection uses, but the .NET team is improving that scenario (https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-5/#trimming https://devblogs.microsoft.com/dotnet/performance-improvemen...) with attributes to tag dependencies and hint the linker.
- flohofwoe 6y agoA similar problem exists in the C/C++ world: designing a library in a way that supports good dead-code-elimination isn't something that many library authors think about. Interestingly plain C libraries often do this better than C++ libraries (e.g. too generous use of virtual-method-interfaces in C++ libraries, or making heavy use of C++ stdlib containers when simple C-style arrays would do as well). The Unity engine also suffered from a similar problem: If you used a simple physics feature like a stabbing collision check somewhere in your code, the entire physics module was pulled in, even though the code needed for stabbing checks is only a few percent of that physics module. This is why I'm a bit sceptical that improvements in the .NET "machinery" alone can solve this problem. You also need to restrict language features and select the right dependencies. This is a general problem, not just web-specific, it's just that reducing the output binary size typically isn't a high-priority problem outside the web.
- chabad360 6y agoI guess we'll just have to wait for WASM binaries to support dynamic linking, at which point we'll get services like "cdnwasm" or "wasmdelivr".
- madeofpalk 6y agoWhile I definitely can't see this being useful for general websites/web applications, I guess I could see it being useful for "line of business" internal web apps for businesses? But then, I don't understand why you wouldnt just make it with web tech to begin with and 'port' it to native platforms with Electron.
- baq 6y agobecause web tech isn't really the best solution for quick and dirty UIs. source: been involved in quick and dirty UIs in a business for the past decade
- SiVal 6y agoSo what has that decade taught you is the best solution for quick and dirty UIs?
- qzw 6y agoVisualBasic, back in the day.
- baq 6y agohaven't found a universally good option yet; delphi was close 15 years ago, but the world forgot about it mostly. hoping for WASM+compiled language framework somewhat like this one to fit the bill so I don't have to worry about supporting multiple browsers, multiple browser versions, cross platform support, css... WASM (language independence) on electron (fixed, controlled browser version) with delphi-like UI designer could work, maybe.
- SenHeng 6y agoPowerBuilder, in the EMR industry.
- acuozzo 6y agoHyperCard.
- 0x10c0fe11ce 6y ago
- smoyer 6y agoI've been playing with compiling Go into WASM for the last year. The size of the "binaries" created is entirely based on which libraries you include. Surprisingly, including the _fmt_ library adds about 2MBytes to the size of the code. Once you include the relatively few libraries you need, you can write a ton of code and the size of the code effectively stops growing.
- kodablah 6y ago> Surprisingly, including the _fmt_ library adds about 2MBytes to the size of the code. Part of including unicode package itself (transitively or otherwise) has a ton of package-level vars that bloat the WASM. Also, they slow down init because a bunch of code has to be run to initialize them. Also, due to the fact that WASM doesn't have arbitrary jumping, in order to support coroutine yielding and resumption, Go's WASM support puts big br_tables[0] at the top. A while back, I brought up some efficiency concerns w/ data size and init instruction count[1] but they were dismissed as WASM concerns not Go ones and there weren't any easy/obvious wins. Also a while back, I used an interpreter to run the Go WASM up until actual main, then bake in the data that was initialized and remove init for packages where I didn't need their values[2]. I kinda gave up on using Go and WASM after all of that, but there is real room for improvement there. 0 - https://webassembly.github.io/spec/core/exec/instructions.html#xref-syntax-instructions-syntax-instr-control-mathsf-br-table-l-ast-l-n https://webassembly.github.io/spec/core/exec/instructions.ht... 1 - https://github.com/golang/go/issues/26622 https://github.com/golang/go/issues/26622 2 - https://github.com/cretz/go-wasm-bake https://github.com/cretz/go-wasm-bake
- smoyer 6y agoThat's some great insight! I just learned to avoid certain packages altogether and I've been living with the results. Precomputing init() is an interesting idea and I could see it both increasing or decreasing the resulting binary depending on what's in it (similar to how running LZW compression on an already compressed value will often create a larger result). Of course, you also need to consider the init() execution time and I've generally built my "main" application to load really fast and then load sub-applications as libraries in the background. Note that these are experiments and I don't have a major WASM-based UI in production.
- jeswin 6y agoI agree. IMHO Microsoft made a rather poor choice earlier by pushing Mono-based Ahead-of-time (AOT) compilation - when they should have thrown their weight behind CoreRT (now called native AOT). It looks like it's moving in the right direction now with native AOT [1]. Ability to target native code and WASM (without the baggage you mentioned above) with C# can give Go a run for its money. 1: https://github.com/dotnet/runtimelab/ https://github.com/dotnet/runtimelab/
- csharptwdec19 6y agoI get why they did it to some extent, although I agree with the sentiment they didn't put enough weight behind CoreRT (Honestly I blame their cloud-centric view; the result is ASPNETCORE has been swarmed with developers while CoreRT has a few that also tend to have to work on the main runtime.) BUT, putting Mono out there let everyone else in the community start developing tooling (that Microsoft will take the best ideas from before politely acting like the community didn't keep the whole idea afloat.)
- zigzag312 6y ago+1 Trying to quickly build something based on Mono will probably result in a subpar solution, that they won't be able to really fix later on, because it would break backwards compatibility. End result will be half-fixed solution with some great technology, but with just enough underlying issues that will remain there forever. Classic Microsoft.
- kevingadd 6y agoThe strengths or weaknesses of CoreRT aside, it's a simple fact that Mono was ready and CoreRT was not. No number of strategic or tactical decisions will change whether a piece of software is ready to ship. Uno going all-in on CoreRT would have meant they shipped a working product later. For context, the Blazor team started with their own interpreter compiled to WASM (via emscripten) instead of using either Mono or CoreRT - because shipping and getting user feedback is really important, and you can't do that while waiting for the ideal tech to be ready. It was swapped out later. CoreRT is pretty cool tech but I rarely encounter anyone using it. Hopefully that will change in the future. The only CoreRT-based production app I know of is Streets of Rage 4 and it's a very recent release.
- jlaban-uno 6y ago- Uno dev here Fair comment. Here are some other live Wasm apps examples: https://github.com/unoplatform/uno#live-webassembly-apps https://github.com/unoplatform/uno#live-webassembly-apps. Note that .NET for WebAssembly is still in its early stages and the .NET team is likely to continue working on AOT compilation in the coming months, and the Uno team is going to help. This will be improving the payload size and performance that is currently very much lacking in that mode. Interpreted IL mode (the UADO app) is used where the AOT engine is not yet working properly, providing a base to get the framework itself progressing, while the infrastructure rest is improving. Many of the .NET constructs are expecting exception handling (https://github.com/WebAssembly/exception-handling https://github.com/WebAssembly/exception-handling), which has to be emulated as it is not yet available in WebAssembly, adding significant code to the payload. Same for other features like null reference checking or indirect invocations (some may know more on that last one). Other features like lazy WebAssembly loading (for more than 4KB at least) and Interface Types to remove any Javascript (https://github.com/WebAssembly/interface-types/blob/master/proposals/interface-types/Explainer.md https://github.com/WebAssembly/interface-types/blob/master/p...) will also improve the actual and perceived performance significantly. The immediate goal of the project is to provide the ability for new and existing C# apps (and not Web sites, not yet at least) to be available for non-walled garden environments. We expect the field to progress significantly in the coming years on many fronts, making this kind of apps more useful and viable. Finally, you'll find that the Windows Calculator port to Uno is actually stretching thin the browsers resources because of the size of the Wasm payload (browser's memory and CPU is going really high because of the internal WebAssembly management). Yet, once the tiered compiler has cached the result, the load time goes down significantly.
- ComodoHacker 6y agoI'd guess you'll be shipping precompiled essential .NET assemblies with Edge?
- jlaban-uno 6y agoThat would be a question for the Edge and .NET team, but unfortunately that does not seem to be an option. The IL Linker (tree shaking) is removing unused parts of the binaries for the purpose of removing very large portions of code in the final binary. If binaries were to be bundled, or CDN hosted, we'd end up downloading extremely large unnecessary portions of code. Yet, this simple fact that a WebAssembly app needs to download everything its needing to run puts it at disadvantage with Javascript (you download a browser with all the base libraries only once, and that's not lightweight). For now, WebAssembly apps (in general and not just .NET ones) are more similar to mobile apps than websites, just because of this significant difference.
- sippeangelo 6y agoThis first example just gives me a pop-up saying "Download the application for a better experience" and sends me to the play store, and the second shows a distorted icon and never loads. Touché.
- Cthulhu_ 6y agoSo admittedly it's not as fast and compact as a 'native' web application (ironically), but zooming out a bit, how do you feel about it as a write once, run anywhere framework? I mean the webapp is a fallback for when you don't want to or cannot install one of the 'native' apps, which probably weigh in at similar sizes all things considered. I don't think this is intended for public facing, low bandwidth/mobile websites.
- flohofwoe 6y agoI think there's still a lot of room for improvement ;) For instance when you look at these demos: https://floooh.github.io/sokol-html5/ https://floooh.github.io/sokol-html5/ These are also "write once, run anywhere" but with more focus on keeping the binary size small (both in WASM and for the native versions). These demos start at 23 KBytes compressed and go to 537 KBytes compressed for the biggest UI sample (over half of those 537 KB is embedded TTF font data though). At the same time, if I'd be using Qt instead of Dear ImGui to create the UI, the resulting WASM size probably would be similar to the UNO samples, Writing cross-platform code that also works well on WASM really needs a different mindset from the ground up IMHO.
- jcelerier 6y agofor some reason the text looks quite a bit more blurry and less readable than the same thing rendered with Qt on my machine. You should really consider using Freetype, Harfbuzz and friends, right now it looks like there is no hinting or something like that - see e.g. https://i.imgur.com/YgKFcd0.png https://i.imgur.com/YgKFcd0.png (yours top, Qt version bottom - I tried to match the font sizes visually but did not manage to decipher your code to find out exactly what they should be x) )
- flohofwoe 6y agoYeah, that's one downside of focusing on size alone, you'll have to make many compromises what to include and what to leave out. I'd love if browsers would have font- and text-rendering APIs that are low-level enough to integrate with WebGL/WebGPU.
- MarkyC4 6y agouado isn't quite "pixel-perfect" on Firefox (82.0.2, Mac): https://i.imgur.com/EYFzTv3.png https://i.imgur.com/EYFzTv3.png
- MarkyC4 6y agoseems fixed now!
- carldebilly 6y agoIt's a known bug with the caching of fonts. If you clear all your browser cache and restart it again, you'll see it once again.
- reaperducer 6y agoThis simple calculator... Needs a splashscreen and 10 seconds to start (on a 50 MBit connection) Consider yourself lucky. It doesn't do anything on my machine except show the splash screen. macOS 10.15.6 / Safari 14.0
- greggman3 6y agoFurther, going though gallery and clicking the stuff on the left column, each one takes 1/2 second to 2 seconds to respond. Maybe it's loading something over the net (too lazy to check) but it's not a good impression.
- oscargrouch 6y agoI think thats because WASM were not meant to serve those cases. I see WASM more as an "accelerator". The big chunk of code continues to be Javascript that can consume WASM modules. I dont think this case of whole complex applications in WASM will fly. It looks like ActiveX 2.0 all over again. Of course some things will happen as full apps in WASM, but they are mostly tools people already use outside of the Web, so that particular crowd just want to reach the tool, it doesnt matter the medium.
- azakai 6y agoYou're right that this is not optimized for the Web, but I also think there is a use case for this. Sometimes you just want for code to be able to run at all, even with a sizable download, if it means you don't need to do any porting work. For example if you have many years of work on a codebase, and you can run it on the web with almost no effort, that can be really useful. I agree that we want most things on the web to be optimized for the web. But sometimes business or other reasons matter more than code size.
- filleduchaos 6y agoI'm genuinely struggling to think of a situation where users would be happy to sit through loading a _fifty megabyte_ web page but unwilling to just download a damn desktop app and be done with it.
- azakai 6y agoMaybe many users would prefer a desktop app if they use it repeatedly, I agree. But if it's a website you just visit once, it's simpler and safer to just download 10MB of compressed data than to install an app.
- kevingadd 6y agoMany people can't install an app. Period. "Can solve my problem after a 2 minute load time" vs "can't solve my problem" is a pretty easy decision to make.
- deleted 6y ago[deleted]
- andrekandre 6y agothat calculator took 35 seconds to load on my ipad pro... not a great first impression (and the ui lag was quite noticable as well)
- jlaban-uno 6y ago- Uno dev here The Safari Support for large WebAssembly binaries is not particularly great at this point. We hope that the Safari team will improve the performance aspects of WebAssembly, but it does not seem to be a priority at this point (see the Wasm feature map here: https://webassembly.org/roadmap https://webassembly.org/roadmap). For the iPad, the iOS built version of the same app works lots better (https://apps.apple.com/us/app/uno-calculator/id1464736591 https://apps.apple.com/us/app/uno-calculator/id1464736591).
- andrekandre 6y agoi see, thanks for the pointers, i guess apple doesnt have much incentive to speed up web assembly...
- qwerty456127 6y ago> This simple calculator … 53.8 MBytes uncompressed. So it's no better than Electron? I'm primarily interested in the cross-platform desktop part.
- lostmsu 6y agoI understand this is th web version. If you build native, it is going to be smaller and faster.
- w0mbat 6y agoIt's a terrible calculator, quite apart from the ludicrous launch time. Just try driving it from the keyboard, which is how most people use calculators. Doesn't respond to enter, return is not mapped to equals, no key is mapped to CE or Clear. Did they even try using it?