by CharlesW · 2y ago · 0 comments
"Avalonia is akin to Flutter for .NET, both using Skia for UI rendering. Key differences include Avalonia's use of .NET and XAML, contrasting with Flutter's Dart language. While Flutter excels in mobile, Avalonia has recently expanded to mobile, offering a more mature desktop experience. For teams skilled in .NET and XAML, Avalonia is likely the better fit."
So this might be a great choice if you're a .NET shop, if your app doesn't need a platform-native native look or feel, and if your project is desktop-focused.
Case in point, none of the Flutter examples are smooth on my 4K laptop. But I can play Assassin's Creed Mirage (released a few months ago) just fine at 70+ fps.
Edit: And my Android phone also can't handle scrolling up in this Flutter demo app without severe stuttering: https://play.google.com/store/apps/details?id=com.gskinner.f...
My understanding is that rendering large text blocks with Skia will max out the CPU. So they would need to chunk the content of the div inside the scroll container, like what Chrome does.
In both cases it uses GPU rendering and I see no problems with scrolling in them - 60 FPS kinetic scrolling by mouse wheel and touchpad.
You can try by yourself by running usciter.exe demo browser from
- https://gitlab.com/sciter-engine/sciter-js-sdk/-/tree/main/b... - Direct2D backend. - https://gitlab.com/sciter-engine/sciter-js-sdk/-/tree/main/b... - Skia backend.
You can load in usciter this document:
https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/s...
It shows pretty large colorized texts so you can estimate how Direct2D and Skia handle GPU accelerated text rendering. For these two binaries the difference is only in graphics used - Direct2D and Skia.
Last time I tried Avalonia UI on Mac, the CPU usage was really high (like in the 70s sometimes without doing anything). They might have addressed that since then though.
https://www.noesisengine.com/xamltoy/61c071a0b3a34ff82dfb0e2...
"rendering 2D UIs is just slow in general"
I think mostly it's just that many existing tools use CPU rendering. Without "modern" pixel shaders, crisp anti-aliased text rendering was pretty much impossible on GPU. At 800x600, rendering the UI on CPU used to be no problem. But with retina and high-DPI it became 4x slower and, thereby, unusable.
And yes, that high CPU usage is exactly the issue with Skia. Ideally, it should require a few percent on load and then afterwards everything should be running inside the GPU at almost 0% CPU cost.
Other frameworks like Flutter which use Skia don't have such a high CPU load on my computer so I'm pretty sure the high CPU usage is because of Avalonia specifically. (Although Skia might very well contribute to it.)
Just opened Chrome and Firefox (both of which use Skia) and both used about 1% CPU while idle while Avalonia is there with up to 70% CPU usage while idle.
The only problem I had is that IDE support is limited. At least at the time I was using it, Microsoft Blend felt very much like a half functioning and abandoned project that was just being dragged along for the sake of maintaining something at least reminiscent of an IDE.
[0] https://traineq.org/ImGuiBundle/emscripten/bin/demo_imgui_bu...
I never even had that during the alpha days of Avalonia. Give it a shot again.
Others found high CPU usage too, but not as high as 70% (more like half that). https://github.com/AvaloniaUI/Avalonia/issues/11070
https://github.com/servo/webrender/blob/master/wr_glyph_rast...
"GPU accelerated rendering means that the GPU is used for composition."
https://www.electronjs.org/docs/latest/tutorial/offscreen-re...
And that page says that's also how Chromium does it.
I agree with you that both Chrome and Android work quite well in general. But that doesn't change the fact that some of the design decisions have aged badly:
"Chrome is still the king resource hog on macOS"
"In previous tests, which included a lot more tab switching, and no WebGL and media consumption, Safari was using 10x less than Chrome"
https://www.reddit.com/r/macapps/comments/12n7162/part_3_fin...
9 years ago, I myself also shipped apps that were rendering the GUI exclusively on CPU because it's just so much easier to get things to look 100% identical everywhere. But nowadays, those apps are either pixelated or feel sluggish even on modern Macs because Retina displays have easily 4x-ed the number of pixels that need to be drawn. But single-threaded FLOPS has not 4x-ed since then.
What alternative do you propose? What other library is cross-platform, has a nice API, performant, supports text well enough, and can do both CPU and GPU rendering?
It would be easy to add 20% of time and budget to a project and just let your developers work on bugfixes and improvements. Maybe even let your dev team interview a customer or two to truly understand what matters to them. But that's considered too expensive. (even though some SaaS have 90%+ profit margins)
As long as your tool demo works slickly on the highest performance Macbooks used by the execs you're trying to sell to, performance isn't a factor.
For mobile or web it would not be my first choice. And desktop apps may not sound as sexy. But there is definitely a category of applications that works best as a desktop app and shouldn't be replaced by the web.
How so?
> For teams skilled in C# and XAML, Avalonia is likely the better fit.
Support for F# is not great, the last time I looked.