These are chat archives for AvaloniaUI/Avalonia

31st
Aug 2018
Nikita Tsukanov
@kekekeks
Aug 31 2018 05:54

Guys, I've implemented a barebone version of MSIL-instumentation-based observable property tracking system that works like MobX from JS world. The idea is to track property get calls from some function and when any of used properties are changed, function will be called again. MobX uses that to properly update react components.

It might be useful for pure-function-from-the-app-state UI building approach.

Currently it doesn't support collection observation or computed (cached) properties, but I have a proof of concept working here: https://github.com/kekekeks/NObservable/blob/master/tests/ObservableTests/InstrumentationTests.cs#L8

My original idea was to use if for Blazor, but it might be usable for Avalonia

@grokys @jkoritzinsky @danwalmsley
bigworld12
@bigworld12
Aug 31 2018 05:59
@kekekeks i think having a strictly typed approach for tracking property getters/setters is better than IL manipulation
just my opinion tho
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 15:32
I have issue with my app, when I run with Direct2D back-end I get crush (Skia works fine), don't know how to debug this.
this is with Avalonia 0.6.2-build5977-beta
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 15:37
@kekekeks that looks really cool! That'd be a cool option to support in Avalonia!
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 15:41
the only error I get is The program '[12600] dotnet.exe' has exited with code -1073740791 (0xc0000409).
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 15:48
when I publish the app it sometimes run and sometimes just does not run (show window)
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 15:53
Exception thrown at 0x00007FFF6E03A9CE (ntdll.dll) in Core2D.UI.Avalonia.exe: 0xC0000005: Access violation reading location 0x00007DFD247CC200.
ntdll.dll!LdrpDispatchUserCallTarget()
WindowsCodecs.dll!CExternalStream::HrClose()
WindowsCodecs.dll!CExternalStream::~CExternalStream(void)
WindowsCodecs.dll!CExternalStream::`vector deleting destructor'(unsigned int)
WindowsCodecs.dll!CMILCOMBase::InternalRelease(void)
WindowsCodecs.dll!CCodecBase::~CCodecBase(void)
WindowsCodecs.dll!CGpPngDecoder::`vector deleting destructor'(unsigned int)
WindowsCodecs.dll!CMILCOMBase::InternalRelease(void)
[Managed to Native Transition]
SharpDX.dll!SharpDX.ComObject.SharpDX.IUnknown.Release()
SharpDX.dll!SharpDX.ComObject.Dispose(bool disposing)
SharpDX.dll!SharpDX.DisposeBase.CheckAndDispose(bool disposing = false)
SharpDX.dll!SharpDX.DisposeBase.~DisposeBase()
[Native to Managed Transition]
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
this is call stack
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 17:11
Weird... I'm not sure what's going on there.
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 17:29
seems like some resources are being disposed when they should not be and it happens only with Direct2D
CGpPngDecoder maybe some png is being disposed
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 17:44
@jkoritzinsky I can confirm, the issue is with png image being disposed
<Styles  xmlns:local="clr-namespace:Dock.Avalonia.Controls;assembly=Dock.Avalonia" xmlns="https://github.com/avaloniaui">
    <Style Selector="local|DockToolChrome">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Template">
            <ControlTemplate>
                <Grid RowDefinitions="25,*">
                    <Border BorderBrush="{DynamicResource ThemeBorderDarkBrush}" Name="PART_Border">
                        <Grid Name="PART_Grip">
                            <DockPanel LastChildFill="True" Margin="8 0">
                                <TextBlock DockPanel.Dock="Left" Text="{Binding CurrentView.Title}" HorizontalAlignment="Left" TextAlignment="Center" VerticalAlignment="Center" Height="25"  Margin="0 8 8 0" Background="{Binding #Part_Grip.Background}" />
                                <Button Classes="chromeButton" DockPanel.Dock="Right" Name="PART_CloseButton" Command="{Binding Parent.Factory.RemoveView}" CommandParameter="{Binding CurrentView}">
                                    <!--<Image Source="resm:Dock.Avalonia.Assets.PinClose_Dark.png?assembly=Dock.Avalonia" Height="13" Width="13" Stretch="None" />-->
                                </Button>
                                <Button Classes="chromeButton" DockPanel.Dock="Right" Command="{Binding Parent.Factory.PinView}" CommandParameter="{Binding CurrentView}">
                                    <!--<Image Source="resm:Dock.Avalonia.Assets.PinAutoHide_Dark.png?assembly=Dock.Avalonia" Height="13" Width="13" Stretch="None" />-->
                                </Button>
                                <Button Classes="chromeButton" DockPanel.Dock="Right">
                                    <!--<Image Source="resm:Dock.Avalonia.Assets.PinMenu_Dark.png?assembly=Dock.Avalonia" Height="13" Width="13" Stretch="None" />-->
                                </Button>
<!--<Image Source="resm:Dock.Avalonia.Assets.PinClose_Dark.png?assembly=Dock.Avalonia" Height="13" Width="13" Stretch="None" />-->
when I enable commented code It crushes
the interesting part is that it happens in Core2D and not in demo app for Dock where same xaml code is used
seems like more complex xaml hierarchy causes this
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 17:50
created issue AvaloniaUI/Avalonia#1843
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 17:56
Any chance you can try to trigger GC/the finalizer thread with the line commented out and see what happens?
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 18:08
calling GC.Collect(); is ok ?
I did that and nothing happens
did try that also with Skia and png images enabled, and also nothing happened
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 18:16
        <Setter Property="Template">
            <ControlTemplate>
                <Grid RowDefinitions="25,*">
                    <Grid.Resources>
                        <Image x:Key="closeImage" Source="resm:Dock.Avalonia.Assets.PinClose_Dark.png?assembly=Dock.Avalonia" Height="13" Width="13" Stretch="None" />
                    </Grid.Resources>
                    <Border BorderBrush="{DynamicResource ThemeBorderDarkBrush}" Name="PART_Border">
                        <Grid Name="PART_Grip">
                            <DockPanel LastChildFill="True" Margin="8 0">
                                <TextBlock DockPanel.Dock="Left" Text="{Binding CurrentView.Title}" HorizontalAlignment="Left" TextAlignment="Center" VerticalAlignment="Center" Height="25"  Margin="0 8 8 0" Background="{Binding #Part_Grip.Background}" />
                                <Button Content="{DynamicResource closeImage}" Classes="chromeButton" DockPanel.Dock="Right" Name="PART_CloseButton" Command="{Binding Parent.Factory.RemoveView}" CommandParameter="{Binding CurrentView}">
this also crushes when using SharpDX, Skia works fine
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 18:24
You need to call GC.WaitForPendingFinalizers
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 18:24
I did try this too
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 18:25
Call both (collect first) and let me know what happens
Did it trigger when you tried that?
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 18:25
no
this also causes crush
    <Application.Resources>

<Image x:Key="closeImage" Source="resm:Core2D.UI.Avalonia.Assets.PinClose_Dark.png?assembly=Core2D.UI.Avalonia" />
when I include the image resource in application
The program '[20600] dotnet.exe' has exited with code -1073740791 (0xc0000409).

I have tried again the

            GC.Collect();
            GC.WaitForPendingFinalizers();

and it does not triggers crush

Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 19:18
Yeah thats been there for a while hahaha. Since before I joined the project I think.
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 19:30

@jkoritzinsky This also cause crash:

<Window xmlns="https://github.com/avaloniaui">
    <Image Source="resm:Core2D.UI.Avalonia.Assets.PinClose_Dark.png?assembly=Core2D.UI.Avalonia"  Height="13" Width="13" Stretch="None" />
</Window>

when I resize window

Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 19:32
Does that repro work in a standalone (not part of Core2D) app?
Cause if so that would be a much easier repro to test with.
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 19:32
working on it
just run and resize window, it crushes but not evrytime
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 19:48
👍 I'll take a look when I get back home (after labor day)
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 19:48
ok
I can reproduce issue with minimal repro
I do dotnet cake build.cake -Target="Publish" and then attach debugger to published executable
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 20:48
@jkoritzinsky The issue is only reproducible under netcoreapp2.1
there is no crush when using net461 or netcoreapp2.0 target frameworks
Jeremy Koritzinsky
@jkoritzinsky
Aug 31 2018 20:49
Weird... Ill see what I can figure out.
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 20:57
actually under netcoreapp2.0 it sometimes crushes, sometimes not :worried:
and net461 works, could not trigger crush
and netcoreapp2.1 crushes always
Wiesław Šoltés
@wieslawsoltes
Aug 31 2018 21:02
under net47 it sometimes crushes, sometimes not