These are chat archives for AvaloniaUI/Avalonia

24th
Feb 2018
Steven Kirk
@grokys
Feb 24 2018 00:46
@x2bool yes that is a bug! will investigate
Sergey Khabibullin
@x2bool
Feb 24 2018 06:14
thanks
Nikita Tsukanov
@kekekeks
Feb 24 2018 07:08
@grokys it might be worth to embed the control gallery video on the homepage
This one
Sergey Khabibullin
@x2bool
Feb 24 2018 12:09
Hi! It's me again with my chat app questions (c)
So I made a test view that loads 100 test messages from a ReactiveList into a ListBox.
image.png
And UI thread hangs for 3 secs which is not nice for just 100 messages.
Here is what I do when a chat is selected:
public async void ObserveRouterChat(Chat chat)
{
    Messages.Clear();

    var messages = await Task.Run(() =>
    {
        return Enumerable.Range(1, 100)
            .Select(id => new Message
            {
                Id = id,
                Text = TextGenerator.Generate()
            })
            .ToList();
    });

    // this causes UI thread hang
    using (Messages.SuppressChangeNotifications())
    {
        Messages.AddRange(messages);
    }
}

public ReactiveList<Message> Messages { get; } = new ReactiveList<Message>();
Nikita Tsukanov
@kekekeks
Feb 24 2018 12:15
Have you tried using a profiler?
Sergey Khabibullin
@x2bool
Feb 24 2018 12:16
No. What should I measure?
Nikita Tsukanov
@kekekeks
Feb 24 2018 12:17
Simple instrumentation should work
Matthijs ter Woord
@mterwoord
Feb 24 2018 12:18
during the 3 secs, is the cpu (single thread) at 100%?
Nikita Tsukanov
@kekekeks
Feb 24 2018 12:18
Have you checked our virtualization example?
Sergey Khabibullin
@x2bool
Feb 24 2018 12:19
@mterwoord yes
)
Matthijs ter Woord
@mterwoord
Feb 24 2018 12:19
then use a profiler to see what is taking so much time..
Nikita Tsukanov
@kekekeks
Feb 24 2018 12:19
Messages.AddRange is probably triggering change event for each message separately
That shouldn't cause 3 second hang though
Still worth a try to assign a new list to Messages property
Matthijs ter Woord
@mterwoord
Feb 24 2018 12:20
it even does that in the suppress.. scope?
Nikita Tsukanov
@kekekeks
Feb 24 2018 12:20
Wait, you are using suppresschangenotification
Yep
@grokys does virtualization need to be explicitly enabled?
Sergey Khabibullin
@x2bool
Feb 24 2018 12:22
Yeah. even with supression.
I cannot assign a new list. I am trying to emulate loading additional messages into the view. Okay I'll be back with profiling results.
Sergey Khabibullin
@x2bool
Feb 24 2018 12:46
image.png
TextBox causes this. When just ellipse stays in the view the list renders in an instant.
<UserControl
    xmlns="https://github.com/avaloniaui">

    <Grid
        ColumnDefinitions="auto,*"
        >

        <Ellipse
            Grid.Column="0"
            Width="32"
            Height="32"
            Fill="#00ff00"
            />

<!--        <TextBox-->
<!--            Grid.Column="1"-->
<!--            Text="{Binding Text}"-->
<!--            />-->

    </Grid>

</UserControl>
Sergey Khabibullin
@x2bool
Feb 24 2018 12:54
Whoa! I just realized I've been using TextBox instead of TextBlock. With TextBlock performance is good.
Which just leaves this question:
Is it okay that TextBox causes long UI thread hang?
Nikita Tsukanov
@kekekeks
Feb 24 2018 12:57
The problem is probably list virtualization not being enabled
It would be nice if you could provide a simple repro of bad performance
e. g. listbox filled with textboxes
Sergey Khabibullin
@x2bool
Feb 24 2018 12:59
I'll look at virtualization anyway. Thanks!
@kekekeks should I open an issue?
Nikita Tsukanov
@kekekeks
Feb 24 2018 13:00
3 seconds for 100 textboxes is too slow, so it's definitely a performance issue
Sergey Khabibullin
@x2bool
Feb 24 2018 13:01
Alright! I'll create an issue on Github with a simple repro.
Nikita Tsukanov
@kekekeks
Feb 24 2018 15:49
@grokys How do you feel about changing default window template?
I'm thinking about global menu support
And it seems that we need some kind of restricted menu items
Without their own templates
To be presented via our usual menus
The change of the template is also needed to hide our own implementation when running on OS X
Not sure if we actually need a separate MenuItem class, though, since NSMenuItem allows custom draw
The problem is that we somehow need to track custom templates for menu items
Steven Kirk
@grokys
Feb 24 2018 16:03

what i was thinking for global menus was something like:

  1. rename our current control MenuStrip
  2. add a new Menu control that detects when it's on a platform with global menus and uses MenuStrip if not

Menu wouldn't support templating obviously

Menu by default it would create its own MenuStrip items
but there should probably be a way to provide your own MenuStrip or customize the created one
is that vaguely along the lines you were thinking?
(i've not thought that much about this, so this is just initial ideas)
Nikita Tsukanov
@kekekeks
Feb 24 2018 16:21
The main problem I see here is custom menu item templates
It is possible to implement custom drawing logic for NSMenuItem
Steven Kirk
@grokys
Feb 24 2018 16:25
yeah, i don't think we should even try to support that, at least for a version 1
support the 90% case i say, which is menu text, shortcut keys, icons and checkboxes
we'd have to support data binding too though
Jeremy Koritzinsky
@jkoritzinsky
Feb 24 2018 16:48
Another thing to think about with global menus: WPF has an IsMainMenu property. I think we should add that if we don't have it and only that menu should be moved to the global menu when available.
Steven Kirk
@grokys
Feb 24 2018 16:49
@x2bool this should fix your DropDown problem: AvaloniaUI/Avalonia#1388
we should probably add a separate ContentTemplate that will be used to display the content in the main area. i've sometimes wanted to display that differently to the item in the list
Nikita Tsukanov
@kekekeks
Feb 24 2018 16:53

we'd have to support data binding too though

We could use regular MenuStrip/MenuItem classes

And use them as data source for the global menu bar
That's why I was thinking about changing the default template for the window
So we could have MainMenu property
Steven Kirk
@grokys
Feb 24 2018 16:54
only problem with that is MenuItem.Header is an object. what would you do if it's not a string? just call .ToString on it?
Matthijs ter Woord
@mterwoord
Feb 24 2018 16:56
custom draw?
Steven Kirk
@grokys
Feb 24 2018 16:58
i wouldn't be opposed to changing the window template but not really sure why it would be needed? if Menu is just a normal control that displays a MenuStrip on some platforms and nothing on other platforms
custom draw might be possible? not sure, i don't know enough about how global menus work
Nikita Tsukanov
@kekekeks
Feb 24 2018 17:02
Custom draw is possible, but it won't look native
because of fonts
Jeremy Koritzinsky
@jkoritzinsky
Feb 24 2018 17:21
For accessibility we need a way to get a textual representation of content anyway, so we should come up with something for menus that we can reuse for that.
Nikita Tsukanov
@kekekeks
Feb 24 2018 17:33
We could analyze the control tree and find text blocks
But that won't work for the global menu bar, since we'll need to track the entire subtree of visuals
Steven Kirk
@grokys
Feb 24 2018 17:37
for the moment i'd be fine with just calling .ToString on Header
Nikita Tsukanov
@kekekeks
Feb 24 2018 23:28
like in WPF
we won't be able to support checkboxes in global menu otherwise