These are chat archives for AvaloniaUI/Avalonia

31st
Oct 2017
Miguel de Icaza
@migueldeicaza
Oct 31 2017 01:22
Good day
Wow, the channel has gotten quite busy
I am still struggling with getting use to the UI
Nikita Tsukanov
@kekekeks
Oct 31 2017 01:31
Hello. If you want to know about the status of the project, we are planning to release our first beta in January.
Our last release on nuget is pretty outdated, lots have changed since then: separate thread rendering, native backend for OSX (thanks for amazing MonoMac bindings, BTW), new xaml parser
Steven Kirk
@grokys
Oct 31 2017 07:42
hey @migueldeicaza yeah, as @kekekeks says we need to do a new release... also we need some docs, what we've got is kinda embarrasing
Jason Craig
@jasonrichardcraig
Oct 31 2017 07:43
Has anyone here ran Avalonia in the browser using WebAssembly?
Steven Kirk
@grokys
Oct 31 2017 07:45
hi @jasonrichardcraig , we don't have a renderer or windowing system that will work in a browser at the moment
Matthijs ter Woord
@mterwoord
Oct 31 2017 07:46
@migueldeicaza "getting use to the ui" what ui? avalonia?
Jason Craig
@jasonrichardcraig
Oct 31 2017 07:47
@grokys Is it a technical limitation of the WebAssembly specification?
Steven Kirk
@grokys
Oct 31 2017 07:48
@jasonrichardcraig maybe i need to understand what you want to do. do you want to create HTML? draw to a Canvas? SVG?
Jason Craig
@jasonrichardcraig
Oct 31 2017 07:51
@grokys I am looking to create LOB apps much like Silverlight and run it in the browser using WebAssembly and get the benefit of near native execution and hardware accelerated Video/2D/3D.
Jason Craig
@jasonrichardcraig
Oct 31 2017 08:02
@grokys If Unity works, can't this?
Steven Kirk
@grokys
Oct 31 2017 08:52
i imagine unity works with webgl, right? so we'd need a renderer that renders to webgl first
that's probably do-able i imagine, maybe skia can render to webgl, not sure
@kekekeks is the person to speak to - i think he's looked into this
Nikita Tsukanov
@kekekeks
Oct 31 2017 10:24
@jasonrichardcraig I've tried to build mono-wasm and was unable to run the hello world example from there. So the current blocker is the lack of proper .NET runtime and tooling support for webassembly
Another problem is that we'll have to use HTML5 canvas for drawing, which is slow
It would be quite hard to build Skia for webassembly
tanaka_733
@tanaka-takayoshi
Oct 31 2017 14:01
Hi, I'm trying to build an app on Linux with the latest build https://ci.appveyor.com/project/AvaloniaUI/Avalonia/build/artifacts
When I execute ReactiveCommand, I got the Unhandled Exception: System.InvalidOperationException: Call from invalid thread message. Does anyone know anything?

It happens even the empty command.
xaml side:

<Button Command="{Binding Command}"/>

ViewModel class:

Command = ReactiveCommand.Create(() => { });
danwalmsley
@danwalmsley
Oct 31 2017 14:05
@tanaka-takayoshi install the Package Avalonia.ReactiveUI from the nightly feed
and then add
.UseReactiveUI()
to the app builder configuration
here is an example
also do you get the exception when you call create or when the command is actually executed?
tanaka_733
@tanaka-takayoshi
Oct 31 2017 14:08
@danwalmsley great Thanks! It works by adding UseReactiveUI()
I got the exception when the command was executed (clicked the button)
danwalmsley
@danwalmsley
Oct 31 2017 14:13
glad it works :)
danwalmsley
@danwalmsley
Oct 31 2017 15:35
avalonia-in-as.gif
AvalonStudio now builds, edits and debugs Avalonia! XAML previewer coming asap
Steven Kirk
@grokys
Oct 31 2017 15:49
wow! nice one!
danwalmsley
@danwalmsley
Oct 31 2017 16:04
still a bit rough
but hoping by xmas I can release and people will be able to try it out
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:26
@kekekeks How does Unity pull this off?
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:29
Unity have their own MSIL to WebAssembly compiler
I think it's called il2cpp or something like that
It is not open source, so we can use it, unfortunately
There are currently 3 ongoing efforts to get C# working with webassembly
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:30
@kekekeks How can I get involved?
Well, the most promising one is https://github.com/lrz/mono-wasm
The problem with that one
Is that build instructions are outdated
https://github.com/lrz/mono-wasm/issues/2#issuecomment-340195164 - this is the summary of build issues that I've encountered
And I wasn't able to produce a working binary at the end
Another problem is that it uses LLVM to generate WASM
Unfortunately, Mono's LLVM backend is currently unable to compile C#-methods that return value types
One of the most critical of such methods is Task::GetAwaiter
Which breaks async/await completely
What we could probably try to do
Is to target unity itself
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:35
@kekekeks Is it possible to leverage the Unity tooling to compile a .Net core app in Webassembly>
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:36
I haven't tried yet
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:37
@kekekeks Why did the .Net Core team stop working on it?
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:38
Ehm, stopped?
That PR to corert was merged a month ago
The main problem with running coreclr/mono runtime in WebAssembly
is GC support
WebAssembly doesn't currently allow to examine the stack
So it's not possible to check if there are GC roots on the stack
People are trying to use so-called "shadow stack" (the idea is to have a separate region of memory with GC-objects that should be currently referenced by the stack), so it's doable
But the only tooling that actually works these days is IL2CPP
Another major issue
Is that we need to either implement a whole new backend for drawing using HTML5 <canvas>
Or somehow build Skia for webassembly and make it working
Which, in turn, brings libfreetype, libfontconfing and another set of native libraries
That we need to build for webassembly
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:43
Another problem is that Skia's sw-rendering will be really slow due to the lack of optimized assembly-language code
that's used on real hardware
and won't be available on WASM
So we have to use webgl
Or fall back to HTML5 canvas which is also quite slow
So that whole "webassembly support" thingy is quite a major undertaking
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:45
@kekekeks Are you working with the browser standards organizations to get the specification enhanced?
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:45
Well, it's not our task, really. And everything is going to the right direction anyways
support for GCed languages in webassembly is a planned feature
The only thing that actually blocks us is runtime support
If I had a netstandard2.0-compliant runtime and bcl that could run my code in browser with a reasonable performance
I could probably implement a canvas-based rendering backend in a week
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:48
@kekekeks Do you expect a netstandard2.0-compliant runtime and bcl to be developed anytime soon?
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:50
Well, mono-wasm looks promising
And I've almost got it working on linux
So it would be possible to use it via docker image
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:51
@kekekeks That would be nice
Nikita Tsukanov
@kekekeks
Oct 31 2017 16:51
But I'd expect it to be "experimental" for a year
Since currently GC does not work at all
And it needs something to be done about vtype ret in call
Another major issue
is that hello world is 10MB
Which mostly consists of musl, mono runtime and mscorlib
And I suspect that most of that is mscorlib
Which in msil form is 1.5M
Avalonia heavily depends on System.Reactive
which is also 1.5MB
So I'm afraid that a hello world app with avalonia will consume 20MB+
And that's just download size
Jason Craig
@jasonrichardcraig
Oct 31 2017 16:59
@kekekeks Do the standards organizations plan on allowing for shared caching of the netstandard 2.0-compliant runtime and bcl?
Jeremy Koritzinsky
@jkoritzinsky
Oct 31 2017 16:59
@jasonrichardcraig the CoreRT Webassembly support is coming along, but it's not the main priority at the moment, as shown by all of the issues for it being marked as up-for-grabs. I've done some of the low hanging fruit for the opcodes
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:01
@jasonrichardcraig the problem about shared caching
Is that it would only work with JIT
because of how generics work for value types in C#
Basically, you can't just compile mscorlib to wasm and call it a day
Let's say, you want to use System.Collections.Generic.List<T>
It's required to emit a separate native code implementations for List<int>, List<double>, List<Point>, etc
Because int, double and Point have different sizes
so in case of ahead-of-time compilation
everyone essentially has to ship his own mscorlib with used generic type implementations
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:07
Runtime itself... It should be possible to make it shared
@jkoritzinsky what is the general status of corert right now?
Being able to ship the app as a native executable would be a nice selling point for Avalonia
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:09
@kekekeks Like .Net Native?
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:09
I think corert shares some code with .NET Native, but I'm not sure
And .NET Native is UWP-only anyways
I think the list of webassembly-related TODOs in corert can befound here: https://github.com/dotnet/corert/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20webassembly
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:15
@kekekeks Looks like they are going to support WebAssembly in the future.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:15
yep, that is one of the ongoing efforts
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:18
@kekekeks Thanks for showing me where things are at. Avalonia looks like the future of the web.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:20
More like a Silverlight reincarnation
It would be nice for complex apps
but not for actual web sites
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:22
@kekekeks I agree. So many developers are wasting their time with HTML & JavaScript (it's for DOCUMENTS).
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:23
They aren't actually wasting their time, web is the only platform that can ship your app to any device
The idea is to implement WPF-like xaml and controls on top of HTML
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:25
@kekekeks What I mean is when HTML / JS applications approach critical mass, the level of effort to maintain and develop a complex LOB app is quite high relative to what Avalonia offers.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:25
using C# to JS compiler
Yeah, JS devs are trying to overcome that by using immutability and react/redux-like techniques
But it's almost improssible to use MVVM approach with JS
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:26
But that code will never reach near native speed, correct?
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:27
You just can't build a proper data binding system without weak references
What exactly do you mean by "native" speed?
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:27
Interpreted script vs WebAssembly
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:28
Two major flaws of webapps right now is memory consumption and DOM being slow in general
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:28
@kekekeks Interpreted script vs WebAssembly
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:28

Interpreted script vs WebAssembly

That actually depends on what you are trying to do

Jason Craig
@jasonrichardcraig
Oct 31 2017 17:29
@kekekeks I agree, but my point is there is only so much the JavaScript engine can do to optimize the scripts.
@kekekeks And the browser should not limit what language, runtime or BCL's one can use.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:31
There are several limitations caused by JS language and JS runtime
That prevent it from being efficient
But if you are doing some computations you are likely to have ~30% speed of native C++
IMO the most major flaw of JS is it's memory model
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:33
@kekekeks No pointers and such?
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:33
Nope, that's not it
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:33
@kekekeks GC?
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:34
The problems are the value visibility rules and the lack of strong typing
JIT doesn't always know the actual type of the variable so it has to emit inefficient native code
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:35
@kekekeks Will Avalonia be supporting F#?
Jeremy Koritzinsky
@jkoritzinsky
Oct 31 2017 17:36
As far as I know CoreRT is still approaching an official preview soon-ish. I don't have any more inside info because most of the team was shifted to the UWP6.0 effort during my last few weeks of my internship
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:38
Mkay, let me rephrase the question. Is there something that would prevent running an avalonia-based app using corert?
@jasonrichardcraig It already does
There is one guy who've written an avalonia app in Pascal
Jeremy Koritzinsky
@jkoritzinsky
Oct 31 2017 17:39
Reflection support is a little funky, and we'd have to manually create an .rsp file for ILC to compile our code to native. Other than those two problems I think we could get something running on CoreRT without serious issues.

Reflection support is a little funk

From what I've seen, it erases tons of information

mikhail kilianovski
@mitutee
Oct 31 2017 17:40
I am not familiar with WPF and other desktop tools. Is there a way to share styling aka Bootstrap, like we do it in Web?
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:41
Yep, write your theme and compile it in a dll
That's how our default theme works
Jeremy Koritzinsky
@jkoritzinsky
Oct 31 2017 17:41
It erases a lot, but it keeps reflection info for anything that's public. And we can use their flavor of rd.xml to declare reflection roots if need be.
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:41
@kekekeks Nice. Do you know if there is a Tabular Data Stream Client (SQL Client) I could use with WebAssembly? (It supports HTTPS).
Jeremy Koritzinsky
@jkoritzinsky
Oct 31 2017 17:42
We'd have to use the RyuJIT backend only (at least for now). The CppCodeGen backend is missing too many features.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:42
@jasonrichardcraig running SQL queries from client machine in a public network is generally a bad idea
From security point of view

We'd have to use the RyuJIT backend only

If it can emit code for arm/amd64, I'm fine with that

mikhail kilianovski
@mitutee
Oct 31 2017 17:43
@kekekeks thats a pity, cause guys who make cool styles usually do CSS, and cant do such stuff as compile to .dll
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:44
@kekekeks I do not plan on querying tables with AD-HOC SQL (and so no access to the tables will be granted). I just want to execute scalar and table valued functions (possible stored procedures too).
Jeremy Koritzinsky
@jkoritzinsky
Oct 31 2017 17:45
The arm RyuJIT backend is still a little buggy. It's getting better over time though. The amd64 one is in really good condition though.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:45
@mitutee in .NET ecosystem dependencies are distributed via nuget, so one pretty much has to compile a library
or write some complex msbuild voodoo scripts
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:46
@kekekeks Also, no data will be stored on the web facing SQL Server, it will be using linked servers with an application layer gateway between the web facing SQL Server and the production server.
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:46
@jasonrichardcraig you'll be able to eval JS code from your WASM app
So it should be possible to use XMLHTTPRequest API
Which in turn should allow System.Net.HttpClient to work
You'll probably need to configure CORS on the server side
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:48
But that can be easily done by placing a reverse-proxy like nginx between your server and the internet
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:48
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:49
GNU LGPL
That's a big no-no for wasm
Since you ship your app as one wasm file
which is technically static linking
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:51
@kekekeks So, not a technical limitation just a licensing thing?
Nikita Tsukanov
@kekekeks
Oct 31 2017 17:51
If it doesn't use sockets of synchronious HTTP calls
it should be possible to compile the C library and P/Invoke it
Think of WASM like some weird hardware platform
Where you can trigger interrupts to call JS code
Jason Craig
@jasonrichardcraig
Oct 31 2017 17:53
@kekekeks I'd like to think of it as a Low Level Virtual Machine.
jp2masa
@jp2masa
Oct 31 2017 22:11
is it possible to handle a window close, and prevent it?
Nikita Tsukanov
@kekekeks
Oct 31 2017 22:12
Not implemented yet
jp2masa
@jp2masa
Oct 31 2017 22:12
ok, it would be important for unsaved changes dialog I think, is there any alternative?
Nikita Tsukanov
@kekekeks
Oct 31 2017 22:13
Create an issue, I'll implement that once I get some spare time
jp2masa
@jp2masa
Oct 31 2017 22:14
ok, thanks