These are chat archives for AvaloniaUI/Avalonia

8th
Dec 2017
danwalmsley
@danwalmsley
Dec 08 2017 10:40
@grokys iv noticed something odd with treeview
its been there a while
basically If I style treeview items to change foreground when selected
like maybe white text against blue background
the foreground text for the child items is also getting applied
code...
Steven Kirk
@grokys
Dec 08 2017 10:41
oh strange
danwalmsley
@danwalmsley
Dec 08 2017 10:41
il post a screen shot
too
Steven Kirk
@grokys
Dec 08 2017 10:41
do you have the repro for AvaloniaUI/Avalonia#1284 btw?
danwalmsley
@danwalmsley
Dec 08 2017 10:42
I'm literally working on one right now
Steven Kirk
@grokys
Dec 08 2017 10:42
oh cool, thanks
danwalmsley
@danwalmsley
Dec 08 2017 10:42
I have a repro commit for Avalon stuiod
but trying to make a minimal one in control catalog
il get the repro done then come back about the tree view
Steven Kirk
@grokys
Dec 08 2017 10:43
that would be great, repros in control catalog are always better because avalonstudio is kinda big!
Igor Gritsenko
@Igor_Gritsenko_twitter
Dec 08 2017 13:25
can't install Avalonia nuget package to net core 2.0 project. under Visual studio for Macos :-(
Nikita Tsukanov
@kekekeks
Dec 08 2017 13:34
Use nigtly builds
Igor Gritsenko
@Igor_Gritsenko_twitter
Dec 08 2017 13:40
image.png
i'll try)
soon
Hate those macos constant updates, general unstabiltiy and poor design... windows is another matter
Igor Gritsenko
@Igor_Gritsenko_twitter
Dec 08 2017 13:49
you mean this one?
image.png
Igor Gritsenko
@Igor_Gritsenko_twitter
Dec 08 2017 13:59
thank you!
Igor Gritsenko
@Igor_Gritsenko_twitter
Dec 08 2017 14:31
it's working!
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:00
Heap fragmentation
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:01
Marshal.AllocHGlobal produces heap fragmentation?
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:02
It uses heap internally
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:02
ok.
i'm in the process of fixing up my imageing stuff. it crashes on the mmap call now.
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:02
And I don't think that there is a point of using heap for bitmaps
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:02
agree with you there
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:02
They are almost guaranteed to occupy multiple memory pages
Another reason for using mmap is that allocated pages will be excluded from "heap size" in memory profiler
That would be confusing and we are tracking them elsewhere anyway
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:06
just asing. so, functionally, for testing, i could disable mmap usage and things should work just the same?
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:07
yes
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:07
great
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:07
You can safely replace it with AllocHGlobal
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:07
my avalonia app works fine on my yocto-based linux image, as long as i start it manually
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:26
any obvious reasons why on start up mmap is not allowed?
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:27
no idea
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:27
ok
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:27
probably some file systems aren't mounted yet or something
Are you running with GTK or /dev/fb0?
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:31
gtk and x (matchbox) but with fb backend
running manual from xterm works fine
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:34
You are probably trying to start it way too early
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:35
from session file for matchbox
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:36
try to spawn a background script with while true; do ./yourapp; sleep 1; done;
and see if that works
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:37
doesn't that keep starting my app?
ie, starve the system very quickly?
Nikita Tsukanov
@kekekeks
Dec 08 2017 15:41
it waits for the app to close
and starts it again
Matthijs ter Woord
@mterwoord
Dec 08 2017 15:41
ah, right. stupid. thanks!
will try that in a bit.
Matthijs ter Woord
@mterwoord
Dec 08 2017 16:00
build is running now. got a CI set up, which on check-in builds the yocto image and pushes it to my test device (using mender.io) :)
takes about 10-12 minutes
Matthijs ter Woord
@mterwoord
Dec 08 2017 16:44
hmm, doesn't work. keeps giving that error..
Nikita Tsukanov
@kekekeks
Dec 08 2017 16:50
Is it crashing with exception or segfaulting inside mmap?
Matthijs ter Woord
@mterwoord
Dec 08 2017 16:50
exception
Unable to allocate memory: 22
Nikita Tsukanov
@kekekeks
Dec 08 2017 16:51
EINVAL
Nikita Tsukanov
@kekekeks
Dec 08 2017 16:51
that's weird
Matthijs ter Woord
@mterwoord
Dec 08 2017 16:54
this is with version 0.5.2-build4248-alpha from the daily builds..
would mean the size would be invalid?
Nikita Tsukanov
@kekekeks
Dec 08 2017 17:02
It might be
try running with strace
Matthijs ter Woord
@mterwoord
Dec 08 2017 17:03
just strace <my-exe> ?
Nikita Tsukanov
@kekekeks
Dec 08 2017 17:29
strace -e trace=memory dotnet exec YourApp.dll
Matthijs ter Woord
@mterwoord
Dec 08 2017 17:48
what to look for now?
Nikita Tsukanov
@kekekeks
Dec 08 2017 17:51
It should log all mmap calls
Find the one that failed
Matthijs ter Woord
@mterwoord
Dec 08 2017 17:51
i have a 900kbyte file now..
Steven Kirk
@grokys
Dec 08 2017 17:52
@jkoritzinsky having difficulty understanding https://github.com/AvaloniaUI/Avalonia/pull/856#issuecomment-350322845
why wouldn't having a single instance keyed with (object, property) work?
Nikita Tsukanov
@kekekeks
Dec 08 2017 17:53
@mterwoord It will be among the last ones
Nikita Tsukanov
@kekekeks
Dec 08 2017 17:56
look for lines with EINVAL
mmap2(NULL, 0, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 EINVAL (Invalid argument)
This one looks suspisious
Are you trying to allocate zero size bitmap or something?
Matthijs ter Woord
@mterwoord
Dec 08 2017 17:59
doing nothing related to manual bitmap fooling..
let me simplify my application..
Nikita Tsukanov
@kekekeks
Dec 08 2017 18:02
check the stack trace then
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:04
@grokys First we'd have to use Tuple<AvaloniaObject, AvaloniaProperty> to allow us to use ConditionalWeakTable, which I'm not the biggest fan of. Additionally, if we just have that tuple instance for a specific call to SetAndRaise, then we might get a bad perf degredation on any property set that needs to use the machinery. If a property is bound in such a way that #855 would happen and the DeferredSetter machinery was needed, we would be re-creating the SettingStatus and Queue objects every time the property is set, which is not very efficient. If we cache the Tuple<AvaloniaObject, AvaloniaProperty> object, then we have a memory leak. If we use Tuple<WeakReference<AvaloniaObject>,AvaloniaProperty> the keys would not compare equal. So, we'd have to create a custom class that would correctly compare equality for a WeakReference<AvaloniaObject> for our use case. At this point, are we even saving any memory usage? And if so, is it worth the extra complexity?
If we consolidate the static instance in PriorityValue into the per-AvaloniaObject instance, we can switch back to a plain Dictionary instead of a ConditionalWeakTable, which will likely improve perf (both in time and memory) since ConditionalWeakTable isn't exactly super light weight.
Steven Kirk
@grokys
Dec 08 2017 18:08
ok i think i understand
i think the main thing you don't like is:
we would be re-creating the SettingStatus and Queue objects every time the property is set
thing, is these things are really short lived, right? and there will usually only ever be 1 or 2 of them in existence at the same time i think
or am i wrong there? @jkoritzinsky
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:11
Yeah they would be pretty short lived. But each call to SetValue would very likely have to recreate them. And if a property would need to use the Queue, recreating that on every SetValue call would add a lot of GC pressure.
Being short-lived and commonly recreated would cause more Gen0 collections, which would push more objects into Gen 1.
Steven Kirk
@grokys
Dec 08 2017 18:14
i've not throught about this long and hard, but: my intuition here would be to just maintain a global List<Entry>where Entry is a struct Entry { object, property, priority, value }
if you've only got a few entries, searching/adding/removing from a list is faster than a dictionary
this way, each object doesn't need its own collection
and it will not cause allocations
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:17
Maybe... I'd have to think a lot more about it.
Steven Kirk
@grokys
Dec 08 2017 18:18
as you've guessed, I really don't like adding fields to AvaloniaObject... our memory usage is already way higher than it should be
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:18
Wait I think I remembered the problem here
What type is the object member?
Steven Kirk
@grokys
Dec 08 2017 18:19
AvaloniaObject
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:19
How would users of that get the correct type in their callback.
If you're tracking the object in the collection, then you'd have to make sure to call the setter callback on that object.
And it really sucks to have the user have to manually cast the object back.
Nikita Tsukanov
@kekekeks
Dec 08 2017 18:20

our memory usage is already way higher than it should be

Most of it doesn't come from the managed heap though

For control catalog managed heap is ~30MB
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:20
Since they can't rely on this being the object they're running the setter callback on anymore
Nikita Tsukanov
@kekekeks
Dec 08 2017 18:20
while total consumed memory is 150MB
I have no idea why that happens
Steven Kirk
@grokys
Dec 08 2017 18:20
@kekekeks yeah, non managed is more of a problem i agree, but 30MB for a test app is too big IMO
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:21
What's the memory usage of the equivalent test app in WPF?
Steven Kirk
@grokys
Dec 08 2017 18:21
@jkoritzinsky well i did say i've not thought about it long and hard ;)
not sure tbh what WPF's equivalent memory usage is, it's lower than ours i seem to remember however
core2d is a good way to test this
Nikita Tsukanov
@kekekeks
Dec 08 2017 18:22
@jkoritzinsky I think I have an old 32-bit build of our control catalog that consumes 35MB on windows
For WPF it would be somewhat like ~15MB, I think
Steven Kirk
@grokys
Dec 08 2017 18:23
btw AvaloniaUI/Avalonia#1309 reduces our memory consumption quite a bit
Matthijs ter Woord
@mterwoord
Dec 08 2017 18:25
now i have a really simple test application that triggers the issue (application only includes the default themes/styles and window show 1 <Border>)
will dig more tomorrow..
could it be the problem that i'm running in RGB565 mode instead of ARGB8888 ?
Steven Kirk
@grokys
Dec 08 2017 18:26
@jkoritzinsky what if object in my idea was an interface with some sort of a Callback(property, priority, value) method?
Jeremy Koritzinsky
@jkoritzinsky
Dec 08 2017 18:29
I feel like we still have the problem where we'd have to cast to the control type. And also think about how to interface with the current SetAndRaise signature on master. I can't think of a way that would work correctly with your implementation.
And I feel that back-compat with at least something as core to the library as that is important.
Steven Kirk
@grokys
Dec 08 2017 18:31
hmm ok, i probably haven't got a feel for the difficulties involved
might be worth me taking some time to hack on it
Steven Kirk
@grokys
Dec 08 2017 18:37
not sure i'll have time to do that for a while though, so we should go with your solution for now
at least we're not stack overflowing