These are chat archives for AvaloniaUI/Avalonia

7th
Jul 2016
Darnell Williams
@Seeker1437
Jul 07 2016 00:13
other projects tend to add a folder called licenses and put them there and they would also implant the full license at the top of the source file(s)'
might work :O the file would be named after whatever, so like in another project of mine I use the BouncyCastle's AESFastEngine, the full license is at the top, then in the licenses folder, there as a txt file with the license for that also
Darnell Williams
@Seeker1437
Jul 07 2016 13:42
@grokys if an external library needed to register a TypeConverter, how would I accomplish this?
Steven Kirk
@grokys
Jul 07 2016 13:48
hmm unfortunately that's not going to be easy right now...
the typeconverter stuff was a temporary hack :(
could you add an issue and i'll work on that asap
Darnell Williams
@Seeker1437
Jul 07 2016 13:55
Okay :O
Johan Larsson
@JohanLarsson
Jul 07 2016 13:58
@grokys did you look at the grid thing?
Steven Kirk
@grokys
Jul 07 2016 14:08
hi @JohanLarsson yeah i had a quick look
Darnell Williams
@Seeker1437
Jul 07 2016 14:09
I accidentally made the change on master.... I thought I was on a different branch!
(for me hehe)
Steven Kirk
@grokys
Jul 07 2016 14:10
@JohanLarsson something like that would definitely be better
well, be useful anyway
but i'm not sure where we're going with our Grid - it's painfully slow
regarding type converters, maybe .net platform standard support is now working?
if we could move to that we could just use the System.ComponentModel type converters
Johan Larsson
@JohanLarsson
Jul 07 2016 14:13
It was just a proof of concept but a bit interesting.
A fast grid is a must have unless there is something even better.
I use grid for 95% of all layout in WPF.
Steven Kirk
@grokys
Jul 07 2016 14:15
yeah...
though if the other layout panels were a bit better that probably wouldn't be so necessary
Johan Larsson
@JohanLarsson
Jul 07 2016 14:17
maybe
Darnell Williams
@Seeker1437
Jul 07 2016 14:18
Yeah, if we could use the System.ComponentModel.TypeConverter that would really rock
What kind of work needs to be done to make that work though?
Looks like travis froze ont he layout unittests :O
Steven Kirk
@grokys
Jul 07 2016 14:19
well there's the new .NET Platform Standard https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md which should give us access to that on all platforms
however last time i tried it, it didn't work
but... "If your library has any NuGet dependencies installed, you need to first follow the steps to switch packages.config to project.json."
i really don't want to do that because afaik that replaces .csproj
and project.json is going away to be replaced by... csproj
Darnell Williams
@Seeker1437
Jul 07 2016 14:21
I thought project.json was dropped anyways?
Steven Kirk
@grokys
Jul 07 2016 14:21
it is!
it's annoying
Darnell Williams
@Seeker1437
Jul 07 2016 14:25
Wow it really does still create project.json files....
I seriously wonder what porting would be like
What should I do to fix the failed build? I build on my side first but I didn't test on mono XD
Steven Kirk
@grokys
Jul 07 2016 15:00
i've restarted the build
Darnell Williams
@Seeker1437
Jul 07 2016 15:11
woot it passed
This just makes what I was doing a smoother experience once I'm ready to submit
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:04

i really don't want to do that because afaik that replaces .csproj

Some projects use them side-by-side

csproj for building, project.json for nuget
Dunno how that work
Darnell Williams
@Seeker1437
Jul 07 2016 16:18
DO we have support for "Suspended Handlers"?
Steven Kirk
@grokys
Jul 07 2016 16:19
i doubt it, as i don't know what they are
Darnell Williams
@Seeker1437
Jul 07 2016 16:30
I actually don't see the point in what I am reading right now.
I just want to know what this is doing xD
Steven Kirk
@grokys
Jul 07 2016 16:32
no idea either!
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:33
First step to make .Net Core port would be targeting Avalonia dependencies to .Net Standard. I had initial look on Skia .Net port for example, everything is easy until it comes to native libraries in this package.
Darnell Williams
@Seeker1437
Jul 07 2016 16:35
I was having an issue targeting .net core projects, they don't work properly if included in a solution file.
which make it not a great to deal with
The fun part is that you can still make your project target net framework too
so it can target .net framework and .net core :D
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:40
I think at this point thing worth to do is to iterate through all Avalonia dependencies, and for all of them create Issue on GitHub asking for .Net Core port. If that will be not ready in reasonable time (and probably it will not) then start creating pull requests ;)
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:41

First step to make .Net Core port would be targeting Avalonia dependencies to .Net Standard. I had initial look on Skia .Net port for example, everything is easy until it comes to native libraries in this package.

Skia should already work fine with .NET Core

Someone managed to make a linux build of native binaries, so it should just work
The real issue is the lack of working GTK bindings
Since GTK# needs to be compiled against actual GTK version
I'm considering to write some simplified bindings just for our needs
Since GTK is a plain C library
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:44
Yes the only difficulty is to create proper package with native libraries. Recently even Jon Skeet was asking on twitter how to do it in right way because of some difficulties (native libs in Nuget)
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:44
The issue with native libs
isn't with packaging
It's with library path resolution
When you have library name hardcoded in DllImport attribute
And have no means to alter lookup algorithm whatsoever
You are forced to ship only the specific library version
And that just don't work well even for windows
Where we have x86/x64
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:46
so you are telling me people are putting whole paths in DllImport ?
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:46
They are putting "mylib.dll"
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:47
And if all of them will land in one folder that will not work ?
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:47
And you have, say, x86 and x64 versions of mylib.dll for windows
libmylib.so for Ubuntu_x86, Ubuntu_x64, RedHat_x86, RedHat_x64, etc
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:47
Aa I see
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:48
In our skia-based renderer
I've used dlopen/dlsym/LoadLibrary/GetProcAddress
To dynamically load the library from proper location
Which can be only determined at runtime
For some reason neither .NET, Mono or .NET Core provide developer with means to do path resolution manually
Like with AppDomain.AssemblyResolve
That have always been frustrating me
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 16:50
sounds like good github project idea :)
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:51
Yeah, something that will look up for extern functions with DllImport attribute and replace them with LoadLibrary+GetProcAddress+Marshal.GetDelegateFromFunctionPointer
Could be a fody weaver or something like that
Darnell Williams
@Seeker1437
Jul 07 2016 16:52
Fody again x3
Actually, hey that's a very good idea
Dani Antonio Ona
@zxcdani
Jul 07 2016 16:53
Hi, can anyone assist me? Avalonia.Base throws an error on nameof
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:54
Update your VS
Dani Antonio Ona
@zxcdani
Jul 07 2016 16:54
I'm using Mono btw, sorry.
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:54
Update your Mono )
Dani Antonio Ona
@zxcdani
Jul 07 2016 16:54
MonoDevelop to be exact
Wait, i'll take a look at my mono version
It's 4.4.0.40
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:55
Hm
Weird
4.2.2 worked for me last time
Dani Antonio Ona
@zxcdani
Jul 07 2016 16:56
Yep, super. Maybe because of my distro? I'm using an Arch-based distro.
Nikita Tsukanov
@kekekeks
Jul 07 2016 16:56
Travis build uses 4.5.2
Dani Antonio Ona
@zxcdani
Jul 07 2016 16:57
Maybe there's a newer version on AUR. I'll check it
Nothing on AUR. I'm stuck. Haha
maybe he's using an alpha or beta build
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 17:01
mono nightly
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 17:02
@kekekeks can we summarize this problem. Don't know if I get it right. We have nuget pacage with few nativ libs libabc_x86 libabc_x64 etc .. Until first run of application we don't know on what architecture we are sitting on. So when application starts we need to determine platform and dynamically load appropriate libs right ?
Darnell Williams
@Seeker1437
Jul 07 2016 17:02
How does LibGit2Sharp do it?
Nikita Tsukanov
@kekekeks
Jul 07 2016 17:03
@arkadiuszwojcik yep
And people are trying to "solve" it by forcing you to choose the arch at the build time
For example Skia# doesn't work with AnyCPU executable projects
It forces you to choose either x86 or x64
Which is obviously a bad idea
Hm
Now I'm seriously considering to write that Fody weaver
It will save people from so many problems
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 17:06
What about a hacky way when you ran your app by sh/ps1 script that determine platform / copy all necessary libs to executable location and then start executable ?
Darnell Williams
@Seeker1437
Jul 07 2016 17:06
:) I was curious because LibGit2Sharp somehow is able to determine the platform and load the correct natives
I was thinking it might be a reference point
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 17:12
I'm taking a look into LibGit2Sharp now
Darnell Williams
@Seeker1437
Jul 07 2016 17:14
AH found something
Darnell Williams
@Seeker1437
Jul 07 2016 17:16
libgit2/libgit2sharp@0901a16
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 17:17
in static constructor they append path to system PATH with location of proper dll hehe
I would never thought about such solution :D
Darnell Williams
@Seeker1437
Jul 07 2016 17:19
Yeah I was thinking it seemed plausible
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 17:31
Another way would be to use Microsoft.CSharp package that will generate binding class implementation at runtime.
from some kind of template
only thing that will change in implementation class will be DllImport lib name
but that might be overhead
Steven Kirk
@grokys
Jul 07 2016 17:36
is there an issue on the coreclr repo for this? sounds like something that xamarin would need, and they're part of MS now, so it might happen...
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 17:42
I don't thinks such feature can be implemented. At very end .Net runtime (any runtime) have to call native system function LoadLibrary and at such level there is no way force own resolution policy.
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 18:03
Hmm but anyway I will create such issue in coreclr repo and see what they will say
Nikita Tsukanov
@kekekeks
Jul 07 2016 18:08

in static constructor they append path to system PATH with location of proper dll hehe

In Linux each thread has it's own copy on environment variables, I think

At very end .Net runtime (any runtime) have to call native system function LoadLibrary and at such level there is no way force own resolution policy.

Meh, one could allow a special ResolverType property for DllImportAttribute

Which will point to a specific class that should do the work for that specific DllImport
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 18:18
Yes, provided that DllImport deals with LateBinding on Runtime level. Probably yes because I can't imagine how static binding could work here (but there might be such)
Nikita Tsukanov
@kekekeks
Jul 07 2016 18:19
Obviously that can't work for static linking (iOS)
But in most cases runtime uses LoadLibrary/dlopen anyways
Nikita Tsukanov
@kekekeks
Jul 07 2016 18:24
My idea of library location basically is

For windows and OS X loader looks in {platform}/{arch} directory, e. g.:

@managed_image_directory/native/win32/x86
@managed_image_directory/native/win32/x64

@managed_image_directory/native/osx/i386
@managed_image_directory/native/osx/amd64

For Linux it's a bit tricky since there are so many distros, so loader checks for distro name using lsb_release and then probes directories in following order:

{distro}/{version}/{arch}
{distro}/generic/{arch}
generic/{arch}

For example, for Ubuntu 15.04 lsb_release -a prints the following values:

Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily

So the distro is Ubuntu and version is 15.04. Loader library lookup order for amd64 arch would be:

@managed_image_directory/native/linux/Ubuntu/15.04/amd64
@managed_image_directory/native/linux/Ubuntu/generic/amd64
@managed_image_directory/native/linux/generic/amd64

At least that makes sense to me
.NET and Mono completely ignore even the fact that people want to be able to run on different CPU archs
Well, in case of OSX x86 isn't really supported anymore, but still
If we'd have a fody weaver to modify skia# (and probably merge it in our rendering platform, since we'll need to repack it anyway)
There shouldn't be any issues with that
We also could have a weaver for automatically retargeting it to .NET Standard Platform (it has DllImportAttribute I believe)
Yeah, sounds like a plan
Steven Kirk
@grokys
Jul 07 2016 18:30
that would be amazing if you can do it - it's something that loads of people need i'm sure
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 18:34
hmm If you do something like that for pc it might be ok., but embedding all possible native dll's into smaller device packages will be to much. number of included files: number_of_OS_types * number_of_architectures pretty much
*too much
Darnell Williams
@Seeker1437
Jul 07 2016 18:35
universal stuff would really rock :(
windows universal, osx universal, linux/generic
Steven Kirk
@grokys
Jul 07 2016 18:37
@arkadiuszwojcik well you wouldn't have to bundle the dlls if you know what platform you're running on
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 18:40
If you know what platform you are running on before bundling you don't have to deal with this problem we are discussing right now.
you just bundle proper dll :)
Darnell Williams
@Seeker1437
Jul 07 2016 18:41
well even though though
instead of building by OS/Arch, you'd just build by platform

aka for mobile you could get away with shipping android/iOs compatibles stuff

For desktop the others

Steven Kirk
@grokys
Jul 07 2016 18:42
@arkadiuszwojcik yes but this gives you the choice
it's not one or the other
Darnell Williams
@Seeker1437
Jul 07 2016 18:45
did that just get released?
Steven Kirk
@grokys
Jul 07 2016 18:45
no, i think it's just a html feature
Darnell Williams
@Seeker1437
Jul 07 2016 18:45
I really like it :D
@grokys is it okay to add [skip-ci] t the commit, would that even work for a PR?
sense it's an easy change?
Steven Kirk
@grokys
Jul 07 2016 18:50
what''s [skip-ci]?
Darnell Williams
@Seeker1437
Jul 07 2016 18:51
fowhen you add a commit that you don't want CI to build you can append [skip-ci] or [ci-skip]
Steven Kirk
@grokys
Jul 07 2016 18:51
oh right, i didn't know that
Darnell Williams
@Seeker1437
Jul 07 2016 18:51
travis and appveyor listen for them both
Steven Kirk
@grokys
Jul 07 2016 18:51
they're both building it anyway
Darnell Williams
@Seeker1437
Jul 07 2016 18:51
however looks like it's ignored for PRs after all hehe
Nikita Tsukanov
@kekekeks
Jul 07 2016 19:01

If you do something like that for pc it might be ok., but embedding all possible native dll's into smaller device packages will be to much.

Noone forces you to actually ship everything

Dependencies are only embedded to nuget-packages
And copied to output directory
You can strip everything you don't need after that
And proper directory structure
Allows you to actually do that without much trouble with figuring out what you do need and what you don't
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 19:27
Nikita Tsukanov
@kekekeks
Jul 07 2016 19:29
So coreclr actually does have a method of native dll probing
interesting
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 19:31
It sounds like that from this post but my initial look into this code doesn't confirm that
later on in this thread they actually discussing how such feature might work and how many problems it implies
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 19:34
yes but that doesn't resolve bindings, you have to still do it manually right ?
Nikita Tsukanov
@kekekeks
Jul 07 2016 19:34
yep
But at least you can implement that logic
Arkadiusz Wójcik
@arkadiuszwojcik
Jul 07 2016 19:35
true
Steven Kirk
@grokys
Jul 07 2016 21:19
ok @wieslawsoltes that was a doozy to work out but i think i've just about worked out what's happening in #580
Created TabControl #56463873
Assigned TabControl #56463873 to Content for RectangleControl #33317444
Applied template for RectangleControl #33317444
With child ContentPresenter #41050596
With content TabControl #56463873
========
Created TabControl #56502960
Assigned TabControl #56502960 to Content for EllipseControl #34920014
Applied template for EllipseControl #34920014
With child ContentPresenter #38098266
With content TabControl #56502960
========
Applied template for RectangleControl #33317444
With child ContentPresenter #7170727
With content TabControl #56463873
i think it's caused by CachedContentPresenter
but i think there might be something wrong in avalonia too
i don't know if that log above makes sense to you?
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:01
@grokys not really
Steven Kirk
@grokys
Jul 07 2016 22:02
what i think is happening, is that RectangleControl.Content is getting set to a TabControl the first time the RectangleControl is created
so that TabControl will be a visual child of the RectangleControl's presenter
when RectangleControl is removed from the logical tree, its Template gets set to null, so its presenter is removed
however the TabControl is still a child of that presenter
when it gets re-added, it's presenter gets recreated
then the Content of the RectangleControl is assigned to it
however, it's still a child of the old presenter!
does that make sense at all?
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:05
yes
does this happen always ? because I did not get exception every time that content changed and cached version of control used
Steven Kirk
@grokys
Jul 07 2016 22:07
i can't quite work out why it only happens sometimes!
but technically speaking i think it's a problem with the cached content presenter
HOWEVER
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:07
how does the Carousel control work this when IsVirtualized="False"
Steven Kirk
@grokys
Jul 07 2016 22:08
it recreates the content each time
i.e. the TabControl gets recreated
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:09
but xaml is not loaded ?
Steven Kirk
@grokys
Jul 07 2016 22:09
no, just the template applied
the xaml has already been loaded into the template
but as i was saying: avalonia shouldn't reapply the template if it's the same template
that's a perf optimization really but it should fix this case
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:11
well when I use ContentControl instead of cached presenter the perf is very bad :(
Steven Kirk
@grokys
Jul 07 2016 22:11
yes i know
i think i need to make ContentPresenter.UpdateChild virtual so you can override it for CachedContentPresenter - that would be the correct way to do it
and improve perf obviously ;)
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:12
+1 for perf ;)
but would be nice to have cached version working for now
Steven Kirk
@grokys
Jul 07 2016 22:14
i'd like to work on perf but people keep asking for damned features ;)
Wiesław Šoltés
@wieslawsoltes
Jul 07 2016 22:15
well perf is feature too ;)
Steven Kirk
@grokys
Jul 07 2016 22:16
ok no more features or bug fixes until we're FAST!
Steven Kirk
@grokys
Jul 07 2016 22:21
tbh before we work on perf we need to get a benchmarking suite setup and a server to run it on and graph it
Johan Larsson
@JohanLarsson
Jul 07 2016 22:43
benchmarkdotnet is nice
we already use it ;)
but there aren't many tests
and we need to run the tests on each commit really to track our perf
Johan Larsson
@JohanLarsson
Jul 07 2016 23:09
yeah
maybe a unit test running the benchmark and checking the results?
use a baseline and compare the factor
tricky as it will be hw dependent
Steven Kirk
@grokys
Jul 07 2016 23:14
yeah