These are chat archives for AvaloniaUI/Avalonia

28th
May 2016
Jeremy Koritzinsky
@jkoritzinsky
May 28 2016 02:36
So opacity masks... I've got an implementation for Direct2D. My method for Cairo doesn't want to work and I have no idea for Skia.
Steven Kirk
@grokys
May 28 2016 12:19
thanks @danwalmsley - merged!
looks like when my popup is removed from its logical tree all the references are kept in _nameScope, which are holding my controls from being GCed
in the namescope of the popup?
if they're in there then they should also in the popup, so if you keep a reference to the popup you keep a reference to them too
danwalmsley
@danwalmsley
May 28 2016 12:52
@grokys I'm setting popup = null when my behaviour (containing popup) is detached from logical tree
I think it maybe the ContentControl mem-leak since everything inside the popup is inside a contentcontrol
got to popout now, but perhaps later I can commit a repro and demonstrate what is happening, probably an expert pair of eyes will spot what the problem is easier than me
Steven Kirk
@grokys
May 28 2016 13:08
ok, so if there's no reference to popup then when its collected the stuff in its namescope will be collected too. or am i missing somethinmg?
danwalmsley
@danwalmsley
May 28 2016 13:23
it should... but its not...
basically I have a behavior in view
Darnell Williams
@Seeker1437
May 28 2016 13:24
@grokys normally be he's saying that's not happening
danwalmsley
@danwalmsley
May 28 2016 13:24
the behaviour implements a custom tooltip
if the popup never opens everything is GCed correctly
it the popup was opened 1ce or more
it never can be GCed
Darnell Williams
@Seeker1437
May 28 2016 13:25
I'm looking at the source, @danwalmsley do you give anything to the Popup?
danwalmsley
@danwalmsley
May 28 2016 13:25
so just opening popup, causes it to take a reference to something, which in turn holds onto my controls, but my understanding of avalonia is limited, but according to dotmemory the key retention path points to _namescope
Darnell Williams
@Seeker1437
May 28 2016 13:26
Maybe the Popup is holding a reference and not the other way around? (Circular)
danwalmsley
@danwalmsley
May 28 2016 13:26
@Seeker1437 if you have 5 mins i can quickly demo on teamviewer
Darnell Williams
@Seeker1437
May 28 2016 13:27
Okay but it would have to be me seeing your screen, I'm on a classified desktop.
danwalmsley
@danwalmsley
May 28 2016 13:27
ok
Darnell Williams
@Seeker1437
May 28 2016 13:28
Pm?
danwalmsley
@danwalmsley
May 28 2016 13:28
616 696 602
has to be quick though
Steven Kirk
@grokys
May 28 2016 13:34
so it can't be the namescope inside the popup then - it must be something outside it
Adam Hill
@adamhill
May 28 2016 15:17
congrats on getting some miguel love :-)
Steven Kirk
@grokys
May 28 2016 15:27
miguel love?
ooh yeah just saw the tweet! cool!
danwalmsley
@danwalmsley
May 28 2016 15:32
Sweet
danwalmsley
@danwalmsley
May 28 2016 17:50
@grokys you about?
danwalmsley
@danwalmsley
May 28 2016 17:59
I'm trying to remember the syntax for binding in code....
popup = new Popup  // popup created when behvior created
            {
                PlacementMode = PlacementMode.Pointer,
                StaysOpen = false,
                [Popup.ChildProperty] = [PopupBehavior.ContentProperty]

                // popup contains contentcontrol...
            };
to bind popup.ChildProperty to PopupBehavior.ContentProperty?
danwalmsley
@danwalmsley
May 28 2016 18:15
answer
[!!Popup.ChildProperty] = this[!!ContentProperty]
danwalmsley
@danwalmsley
May 28 2016 18:44
so it can't be the namescope inside the popup then - it must be something outside it
This message was deleted
I'm not sure what dotmemory is showing exactly...
image.png
I has to be the content presenter bug surely
Steven Kirk
@grokys
May 28 2016 18:51
Ah yeah that looks promising
danwalmsley
@danwalmsley
May 28 2016 18:51
does it tell you anything?
I'm looking at ContentPresenter.cs
private void TemplatedParentChanged(AvaloniaPropertyChangedEventArgs e) 
         { 
             (e.NewValue as IContentPresenterHost)?.RegisterContentPresenter(this); 
         }
perhaps that should unregister before registering?
Steven Kirk
@grokys
May 28 2016 18:55
are templates getting applied to it multiple times?
danwalmsley
@danwalmsley
May 28 2016 18:55
I'll put a breakpoint on ApplyTemplate() ?
Steven Kirk
@grokys
May 28 2016 18:56
put a breakpoint on that line and see if it's getting called multiple times
danwalmsley
@danwalmsley
May 28 2016 18:56
ok
its called twice
yes
similarly popup Open calls itself (and so gets called twice, but lets not get distracted with that one just now)
Steven Kirk
@grokys
May 28 2016 18:59
yeah sounds like it probably should be unregistering the old one then? i'm not looking at the code but it might be that
can you repro it in a test now?
danwalmsley
@danwalmsley
May 28 2016 18:59
iv not been able to..
but I will see in my test how often that gets called
I think if its like the popup
bug
it Rasises PropertyChanged inside Open for IsOpen (the subscriber itself calls Open) so could be a similar bit of code) doing same mistake
Steven Kirk
@grokys
May 28 2016 19:02
ok well sounds like you're getting closer to a repro!
sorry i can't help much this weekend, got various things on
danwalmsley
@danwalmsley
May 28 2016 19:03
no problem, but you told me what to look for, so now if my test does same and can catch that
I can submit a failing test at least
Steven Kirk
@grokys
May 28 2016 19:07
Yep a failing test is 90℅ of solving the leak
danwalmsley
@danwalmsley
May 28 2016 19:07
it gets called the second time
Steven Kirk
@grokys
May 28 2016 19:07
Fixing it is usually easy once it's doing
danwalmsley
@danwalmsley
May 28 2016 19:07
when Popup.Open is called
popup root then triggers a measure
and layoutable MeasureCore then does applytemplate
danwalmsley
@danwalmsley
May 28 2016 19:21
ContentControlMixin.cs
Ln 63, seems to be not needed...
it applies the template
when its going to be applied in future?
safe to remove?
danwalmsley
@danwalmsley
May 28 2016 19:29
in my test how can I get a count of how many templates have been applied?
danwalmsley
@danwalmsley
May 28 2016 19:35
hmmm looks like there is a guard against it being called multiple times
public override sealed void ApplyTemplate()
        {
            if (!_createdChild && ((ILogical)this).IsAttachedToLogicalTree)
            {
                UpdateChild();
            }
everytime I resize window or something that triggers measure ApplyTemplate gets called but I don't think that my leak
Tests show apply templates being called twice too
Steven Kirk
@grokys
May 28 2016 22:49
ApplyTemplate is called on every measure, this is the same behavior as WPF
it's up to the control to no do anything if its template is already applied
Jeremy Koritzinsky
@jkoritzinsky
May 28 2016 22:51
@grokys There isn't currently a way to do opacity masks in Skia (The mask filters supplied don't support it and we can't create new ones via SkiaSharp). I'm planning on just throwing NotImplementedExceptions in the DrawingContext. Would you suggest I do something else?
Steven Kirk
@grokys
May 28 2016 22:52
yeah, that works for me for now
or just do nothing, maybe log something?
the skia backend has quite a bit still not implemented, like opacity
Jeremy Koritzinsky
@jkoritzinsky
May 28 2016 22:53
I'll make it a do-nothing with a comment.
Steven Kirk
@grokys
May 28 2016 22:53
sure
Jeremy Koritzinsky
@jkoritzinsky
May 28 2016 22:55
I'll also open an issue on the official skia repo.
danwalmsley
@danwalmsley
May 28 2016 23:36
well with miguels tweet, we might get some PRs through quicker now
Jeremy Koritzinsky
@jkoritzinsky
May 28 2016 23:39
This needs to be added to skia, as well as skia#