These are chat archives for AvaloniaUI/Avalonia

10th
Jun 2017
Matthijs ter Woord
@mterwoord
Jun 10 2017 08:22
for me on my desktop it boots in 3-5 seconds (same app)
must say that pc is a bitmore powerful.. (i7-7700k)
Matthijs ter Woord
@mterwoord
Jun 10 2017 08:30
If you guys are interested, I could put up binaries somewhree.
Nikita Tsukanov
@kekekeks
Jun 10 2017 08:49
I'm not sure that anyone here has the hardware to run it
I currently have NanoPi Neo air, but it doesn't have a proper screen
soerendd
@soerendd
Jun 10 2017 11:21
I have two rpi. One rpi 1 and one rpi3. The rpi 1 is running libreelec. But I could try it on the other which is running raspbian
danwalmsley
@danwalmsley
Jun 10 2017 11:22
@kekekeks what about normal list and use binary search for insert location? You could have extension method insertsorted?
Nikita Tsukanov
@kekekeks
Jun 10 2017 11:23
Insert is O(n)
Inserting n elements is O(n^2)
Too inefficient
soerendd
@soerendd
Jun 10 2017 11:46
Main problem when inserting in a list is that you have a copy op.
Sergey Khabibullin
@x2bool
Jun 10 2017 13:00
Hello. That's me again with noob questions :)
image.png
How do I prevent TextBox controls from expanding beyond their containers if text inside is too long? On the screenshot you can see the last two items are bigger than previous items, and then the scrollbar appears.
Steven Kirk
@grokys
Jun 10 2017 13:07
@x2bool i can't see your screenshot
Sergey Khabibullin
@x2bool
Jun 10 2017 13:07
image.png
And now?
Steven Kirk
@grokys
Jun 10 2017 13:08
i see it now, thanks
hmm that is strange
looks like it might be a problem with using StackPanel
i'm in the middle of something right now, i will take a look shortly
Sergey Khabibullin
@x2bool
Jun 10 2017 13:11
I don't use StackPanel.
<Grid ColumnDefinitions="2*,auto,3*">

    <ListBox
      Grid.Column="0"
      Items="{Binding Items}"
      SelectionMode="AlwaysSelected"
      BorderThickness="0">

      <ListBox.ItemTemplate>
        <DataTemplate>

          <Panel>
            <TextBox IsVisible="{Binding !IsButton}" Text="{Binding Key}" />
            <Button IsVisible="{Binding IsButton}">
              <TextBlock Text="{Binding I18N[Add]}" />
            </Button>
          </Panel>

        </DataTemplate>
      </ListBox.ItemTemplate>

    </ListBox>

    <GridSplitter Grid.Column="1" />

    <ListBox
      Grid.Column="2"
      Items="{Binding Items}"
      SelectionMode="AlwaysSelected"
      BorderThickness="0">

      <ListBox.ItemTemplate>
        <DataTemplate>

          <TextBox
            IsVisible="{Binding !IsButton}"
            Text="{Binding Value}" />

        </DataTemplate>
      </ListBox.ItemTemplate>

    </ListBox>

  </Grid>
Sure, I'll wait. Really appreciate your help guys!
Steven Kirk
@grokys
Jun 10 2017 13:18
yeah, sorry i meant that ListBox uses StackPanel as its default items panel
Steven Kirk
@grokys
Jun 10 2017 19:36
i swear that VS2017 spends more time frozen than working
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:44
@grokys please, use HashSet<IVisual> for keeping invalidation lists
And then convert said sets to Queue<IVisual> just before measure/layout pass
Changing lists is way too inefficient
Or use List<Queue<IVisual>>
Steven Kirk
@grokys
Jun 10 2017 21:48
i've been doing performance (memory and time) tests on various different collections
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:49
list of queues should be the most efficient one
At least in terms of performance
insert operation is O(1)
dequeue operation is O(1)
Steven Kirk
@grokys
Jun 10 2017 21:50
i tried using a hashset and then converting to a queue but it doesn't work, as a control that is invalidated in the middle of a measure must be added to the current measure pass in order
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:51
List<Queue<IVisual>> then
with hashset for tracking duplicates
Steven Kirk
@grokys
Jun 10 2017 21:51
the most efficient algorithm i've found is actually the one we're currently using on master
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:52
The only problem is that Queue<T> doesn't have Remove method, so it has to be implemented manually
Steven Kirk
@grokys
Jun 10 2017 21:52
second most efficient is the one currently on refactor/layout which uses a plain sorted list
that one is actually slightly better memory-wise than the current one on master, but a very tiny bit slower
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:53
That's on small widget hierarchies
Steven Kirk
@grokys
Jun 10 2017 21:54
the benchmark uses a hierarchy of around 1000 controls and invalidates half of them
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:54
insert/remove operations on the plain List<T> are fast when the count of elements is less than 200 or something
Steven Kirk
@grokys
Jun 10 2017 21:55
tbh i think we're best leaving the algorithm as it is
just fix it up to fix the edge cases
Nikita Tsukanov
@kekekeks
Jun 10 2017 21:56
Mkay, any idea why it doesn't work properly with LayoutManager-per-TopLevel model?
Steven Kirk
@grokys
Jun 10 2017 21:56
nope, i intend to try and work that out now
though if you want to have a go at trying different algorithms there's now a benchmark
and more unit tests
just to let you know my findings:
master: 5ms 156.25 Gen0 481.65kb total
DirtyVisuals: 5.1ms 195.31 Gen0 604kb total
DirtyVisuals with DistanceFromRoot stored in Visual: 4.78ms 195 Gen0 604kb total
Sorted list: 4.61ms 148 Gen0 463kb total
Johan Larsson
@JohanLarsson
Jun 10 2017 21:59
do you check in the results?
Johan Larsson
@JohanLarsson
Jun 10 2017 22:00
can't find them but good that you do
Steven Kirk
@grokys
Jun 10 2017 22:01
so actually, the sorted list is both faster and uses less memory than master, i thought that wasn't the case
though tbh the benchmarks can vary quite a bit beween runs
Nikita Tsukanov
@kekekeks
Jun 10 2017 22:03
BTW, we don't need duplicate checking
visuals won't add themselves twice
since they are checking for IsMeasureValid/IsArrangeValid
Steven Kirk
@grokys
Jun 10 2017 22:04
hmm, good point
Steven Kirk
@grokys
Jun 10 2017 22:37
removing the duplicate check doesn't have much affect at least on the benchmark i have. maybe a few fractions of a ms
Steven Kirk
@grokys
Jun 10 2017 23:23
ffs visual studio