These are chat archives for AvaloniaUI/Avalonia

14th
Jun 2016
Andrey Kunchev
@donandren
Jun 14 2016 07:33
@grokys @kekekeks I'll spend some more time on skia text rendering part, probably until the end of the week we'll have it in very good shape
Steven Kirk
@grokys
Jun 14 2016 08:16
that would be great
i think i've just about finished virtualization, but there's a big speed regression in Core2D that i need to fix
Paul Cunningham
@PumpkinPaul
Jun 14 2016 13:49

Hi Steven!
I had a (real) quick play with the framework and it's looking very nice. Great work so far :-)

Regarding incorporating Avalonia into Gearset (https://github.com/PumpkinPaul/Gearset), I think the biggest roadblock for me is the Inspector TreeView - here's the current XAML for it.
https://github.com/PumpkinPaul/Gearset/blob/master/Gearset/UserInterface/Wpf/InspectorWPF/Inspector.xaml

...and I think ListView or something that allows a grid / multi column lists

Regards,
Paul

Steven Kirk
@grokys
Jun 14 2016 15:20
hi paul! yes that is definitely something that's missing at the moment
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:20
hi people!! I'm happy to peek over this chat !
I'm currently working in OmniXAML, reworking the Object Assembler (that is a quite important phase in the parsing) and I'm thinking of baking the immutable type support from the very beginning
but this afternoon, while I was on the underground (or subway if you will) I thought about collections
for instance
<MyClass>
   <MyClass.Children>
         <Child />
         <Child />
         <Child />
   </MyClass.Children>
</MyClass>
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:26
A generic XAML parser would take the instance in MyClass.Children, that is supposed to implement the Add method and invoke it as it reads each child
I mean, a generic parser will not instantiate the collection, but use the existing collection to fill it with the children
this is cool as long as the parser doesn't have to instantiate the collection
and it doesn't require any kind of lookahead! that simplifies the parsing a lot
the underlying model is the one that instantiates the collection
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:31
if we want to support immutable collections, then this has to change: the parser should create the collection
and it has to asume that the ctor of the collection accepts an enumerable. This also requires a lookahead mechanism (the object isn't instantiated until the last item has been read)
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:54
I don't know what implications does this have, but maybe you can foresee something that could make it difficult to implement.
Steven Kirk
@grokys
Jun 14 2016 18:55
hi @SuperJMN welcome back!
i don't really know much about how you should be handling them, but i think Portable.Xaml supports immutable collections now
you may want to take a look there
also: SuperJMN/OmniXAML#82 !
this one looks like quite a big problem too SuperJMN/OmniXAML#109
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:57
hi Steven!! nice to see you again, too!
Steven Kirk
@grokys
Jun 14 2016 18:57
also SuperJMN/OmniXAML#110
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:58
I have to start breathing again!
Steven Kirk
@grokys
Jun 14 2016 18:58
(though only the 1st there has affected me)
yes, you need to breathe!
it's dangerous not to!
José Manuel Nieto
@SuperJMN
Jun 14 2016 18:59
immutables require a pretty important change
currently, there is a GetObject instruction
it means: get the current instance of the current member
to support immutable collections, GetObject should disappear
because every time we find a type that is a collection, we should create an instance, not getting an existing instance
I will try to work it out and see what happens
Steven Kirk
@grokys
Jun 14 2016 19:01
i think @cwensley said that immutable support in Portable.Xaml wasn't too difficult - you should definitely take a look at how it's done there
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:03
whoops, @cwensley! I hope you can talk with me about that. Maybe you can summarize what's does it do. Anyways, I'll take a look to the code
Curtis Wensley
@cwensley
Jun 14 2016 19:04
it uses a List<T> to populate, then when assigning it to the property it translates it to immutable
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:06
so you're looking ahead for items
and after EndObject, you're creating the instance. Aren't you?
Curtis Wensley
@cwensley
Jun 14 2016 19:07
I added a bit of new api to support this XamlTypeInvoker.ToMutable()/ToImmutable(), and XamlType.IsImmutable
During GetObject, it calls ToMutable() if the type is immutable
and stores that instance for mutation (adding items to the collection, dictionary, etc)
During EndObject, it calls ToImmutable(), again only if the type is immutable which translates it back to the correct type
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:09
OK, that sounds OK
but I think GetObject has almost no sense in a scenario in which the parser may instantiate collections
I mean, if the parser will instantiate collections, why would I want to tell it to use an existing instance?
at least in my implementation, I think I will make things simpler
Curtis Wensley
@cwensley
Jun 14 2016 19:13
since immutable collections are structs, Portable.Xaml will add to the existing collection instead of wiping it clean.
well them being structs doesn't really matter in that case though
Matthijs ter Woord
@mterwoord
Jun 14 2016 19:14
if they are structs you'll have to reassign them as structs are imutable
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:14
:) thanks for the info! I will try to put everything that I know together and see what happens
Curtis Wensley
@cwensley
Jun 14 2016 19:15
no prob (;
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:15
I'm gonna write some tests and cast something good enough prior to solving some bugs
I need some traction!
by the way, I hope to develop an Avalonia application soon!
in my company, we need an app that could run a GUI, based on .NET in a Mac
there's no better chance to burn the house!
and I want to burn it so badly
Steven Kirk
@grokys
Jun 14 2016 19:17
haha well as long as it's not something you're betting the company on, i say go ahead
but keep in mind we're still alpha!
which might cause problems for maintenence
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:18
for me, alpha is the tag that shouts "use my in production while it's hot or you're a goat"
Steven Kirk
@grokys
Jun 14 2016 19:19
um, can you use a different word there? that word is very offensive to americans
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:19
fixed!
Steven Kirk
@grokys
Jun 14 2016 19:19
thanks :)
Matthijs ter Woord
@mterwoord
Jun 14 2016 19:19
:)
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:20
sorry, I don't have a fine sense of "offensiveness"
Steven Kirk
@grokys
Jun 14 2016 19:20
yeah understood! :)
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:20
let's say that I'm a word machinegun
Steven Kirk
@grokys
Jun 14 2016 19:20
i am the same in italian! ;)
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:21
hahaa
I would like to release our new app to production as @grokys pushes commits
Steven Kirk
@grokys
Jun 14 2016 19:21
hahaha
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:22
new commit? OK, lemme deploy his bits to the production server
Matthijs ter Woord
@mterwoord
Jun 14 2016 19:22
poof doesn't work anymore
?
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:22
what? you don't know what's that Avalonia UI package? You ignorant piece of chicken!
Steven Kirk
@grokys
Jun 14 2016 19:22
tbh it's more the fact that our APIs change which would cause problems
when you come to update it 1 year from now, it will be difficult
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:23
OK, those API changes is what makes it challenging
Matthijs ter Woord
@mterwoord
Jun 14 2016 19:23
who's chicken?
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:23
hahaha, it's a figurative chicken
I will say that to whoever that dares to ask
Matthijs ter Woord
@mterwoord
Jun 14 2016 19:24
i know, but who is the ignorant piece of chicken? :)
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:24
:)
I don't know! probably, a colleague in my team
Matthijs ter Woord
@mterwoord
Jun 14 2016 19:24
ahh, now it starts to make sense. never mind :)
José Manuel Nieto
@SuperJMN
Jun 14 2016 19:25
"hey, I've seen that your app runs on Mac, are you using a the Xamarin thingy?"
"No, I'm using the Triforce"
"We also call it Avalon"
Steven Kirk
@grokys
Jun 14 2016 19:30
argh it's like the github slack in here ;) though less animated gifs
@wieslawsoltes are you around?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:47
@grokys Yes
Steven Kirk
@grokys
Jun 14 2016 19:50
welcome back to you too ;)
i've been trying out Core2D with the recent virtualization changes and I found that Core2D became very slow
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:51
how can I help ?
Steven Kirk
@grokys
Jun 14 2016 19:51
looking further into it it seems to be a problem with CachedContentPresenter
with the current Avalonia from nuget SetContent is only ever called with null
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:51
well CachedContentPresenter is a quick hack i've made
Steven Kirk
@grokys
Jun 14 2016 19:51
yeah - avalonia should now recycle data templates
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:52
its is virtualization branch only ?
Steven Kirk
@grokys
Jun 14 2016 19:52
yes
but anyway, can you confirm that SetContent is never called?
bceause i've fixed some problems in the virtualization branch and now it's getting called
a lot
which slows things down a lot ;)
if i comment out the line which calls SetContent everything still seems to work and it's back to it's normal speed
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:53
will do quick check
Steven Kirk
@grokys
Jun 14 2016 19:54
can you confirm that SetContent is never called
actually i mean "is never called with anything but null"
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:54
just checking
can not confirm
it is getting called with actual value
Steven Kirk
@grokys
Jun 14 2016 19:55
hmm
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:56
you can reproduce this by drawing shape and selecting it
Steven Kirk
@grokys
Jun 14 2016 19:57
ahhh i only did a "new project"
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:58
Bez tytułu.png
but I would gladly get rid of CachedContentPresenter and use ContentControl instead
Steven Kirk
@grokys
Jun 14 2016 19:59
ok, so if it's getting called with EditorView during "new project" is that wrong?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 19:59
no
I think this is issue with Avalonia
<presenters:CachedContentPresenter DataContext="{Binding Project.CurrentContainer.CurrentShape}"/>
Steven Kirk
@grokys
Jun 14 2016 20:01
ok, so the fact that it is getting called with EditorView during "new project" in the virtualization branch means i've fixed something rather than broken something?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:02
I think its same as before
Steven Kirk
@grokys
Jun 14 2016 20:02
so yours gets called with EditorView when doing "new project"?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:02
oh sorry its new
Steven Kirk
@grokys
Jun 14 2016 20:03
ah ok
should be be happening do you know?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:04
I think it should be null
{Binding Project.CurrentContainer.CurrentShape}
this is the binding I use
Steven Kirk
@grokys
Jun 14 2016 20:05
hmm ok - so it looks like there is a problem
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:05
I think it is probably some issue with bindings
Steven Kirk
@grokys
Jun 14 2016 20:06
yeah looks like it
the interesting thing is that if i remove this.GetObservable(DataContextProperty).Subscribe((value) => SetContent(value)); so it's just acting like a normal ContentControl everything seems to work...
i will keep looking
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:07
currently it look like if binding is not valid it inherits parents DataContext
SetContent value: Core2D.Shapes.XRectangle
SetContent value: Core2D.Editor.ProjectEditor
if I select shape I get XRectangle as I should
Project.CurrentContainer.CurrentShape == null than I get ProjectEditor
Steven Kirk
@grokys
Jun 14 2016 20:09
so if an EditorView appears in SetContent then something is wrong?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:09
definitly
Steven Kirk
@grokys
Jun 14 2016 20:09
ok
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:14
I just check WPF <ContentControl x:Name="content" DataContext="{Binding Project.CurrentContainer.CurrentShape}" Content="{Binding}"/> and when CurrentShape == null I just get null
not the ProjectEditor

in Avalonia <ContentControl Name="content" DataContext="{Binding Project.CurrentContainer.CurrentShape}" Content="{Binding}"/>

            var content = this.FindControl<ContentControl>("content");
            content.GetObservable(DataContextProperty).Subscribe((value) =>
            {
                System.Diagnostics.Debug.WriteLine($"DataContextProperty value {value}");
            });

I get:

DataContextProperty value Core2D.Shapes.XRectangle
DataContextProperty value Core2D.Editor.ProjectEditor
Steven Kirk
@grokys
Jun 14 2016 20:20
this is using the latest nuget?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:20
yes
0.2.0.1605-alpha
Steven Kirk
@grokys
Jun 14 2016 20:20
ok, so there was a problem even before the virtualization branch
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:20
yes
Steven Kirk
@grokys
Jun 14 2016 20:21
where are you doing var content = this.FindControl<ContentControl>("content");?
pushed debug code
Steven Kirk
@grokys
Jun 14 2016 20:25
on the virt branch i'm getting
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value Core2D.Editor.Views.EditorView
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value 
DataContextProperty value Core2D.Editor.ProjectEditor
that's definitely wrong, huh? ;)
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:26
yes
check the ShapesControl.xaml
maybe this is related <ListBox Name="shapes" Items="{Binding CurrentLayer.Shapes}" SelectedItem="{Binding CurrentShape, Mode=TwoWay}" Classes="default" Grid.Row="1">
not sure
Steven Kirk
@grokys
Jun 14 2016 20:33
ahhh... i think i might know what's happening
thanks - that's been really helpful!
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:33
no problem
Steven Kirk
@grokys
Jun 14 2016 20:40
yep, managed to repro in a unit test. well at least i think it's the same problem
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:41
great
@grokys If you want to test version without CachedContentPresenter you can use this branch https://github.com/Core2D/Core2D/tree/RemoveCachedContentPresenter
Steven Kirk
@grokys
Jun 14 2016 20:47
ah yeah - that will be useful, thanks!
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:50
@grokys How does data template recycling works ?
does that explain much?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:54
so it only recycles if previous object was of same type (used same data template)?
Steven Kirk
@grokys
Jun 14 2016 20:55
yeah
actually i need to put a check in to make sure it's the same type
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:56
so in my case it will almost never recycle
Steven Kirk
@grokys
Jun 14 2016 20:56
ah really? why is that?
oh i see why
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:58
the CurrentShape is like XRectangle, null, XRectangle, XEllipse etc
Steven Kirk
@grokys
Jun 14 2016 20:58
because when you're switching the data from e.g. X -> Y -> X you want it to use the same control for both X's?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:58
yes
this is what I do in my cached content presenter
Steven Kirk
@grokys
Jun 14 2016 20:58
does WPF do that?
it seems like it would leak memory
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 20:59
It does not
not sure how WPF does this
Steven Kirk
@grokys
Jun 14 2016 21:00
do you have a CachedContentPresenter in wpf too?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:00
no I use default ContentControl
just this <ContentControl x:Name="content" Content="{Binding Project.CurrentContainer.CurrentShape, FallbackValue={x:Null}}"/>
you can ignore FallbackValue
Steven Kirk
@grokys
Jun 14 2016 21:01
but in avalonia the performance of that is unacceptable?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:02
its much slower than WPF and memory usage is huge
with my CachedContentPresenter in Avalonia its very fast
it increases somewhat memory usage but its ok
Steven Kirk
@grokys
Jun 14 2016 21:03
ok
we just need to reduce memory usage then and you can remove it ;)
easy ;)
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:04
yeah
the load times are slow for xaml
Steven Kirk
@grokys
Jun 14 2016 21:04
yeah, i've seen
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:04
when control is cached load times are super fast
so even when you reduce memory I would leave caching on for quick load times
Steven Kirk
@grokys
Jun 14 2016 21:05
we need to speed up control creation time too!
i don't think it's xaml as such
it think it's just avalonia
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:08
do I have to set SupportsRecycling ?
for DataTemplate
Steven Kirk
@grokys
Jun 14 2016 21:08
do you define your own IDataTemplate class?
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:09
no just define them in xaml
Steven Kirk
@grokys
Jun 14 2016 21:09
no it's ok then - that property is set by the class that implements IDataTemplate
it's an implementation detail
Wiesław Šoltés
@wieslawsoltes
Jun 14 2016 21:11
by default ContentControl has enabled data template recycling ?
Steven Kirk
@grokys
Jun 14 2016 22:13
it's not the control that enables it - it's the class that implements IDataTemplate
and the XAML DataTemplate does
Steven Kirk
@grokys
Jun 14 2016 22:23
hmm, this goes right to the heart of our binding system
i think i might just revert the change that introduced the problem and merge virtualization to master
then fix the binding issues separately before adding the change back in...