These are chat archives for AvaloniaUI/Avalonia

29th
Oct 2017
danwalmsley
@danwalmsley
Oct 29 2017 12:18
@grokys @kekekeks say I streamed jpg data over tcpip in quick succession, each jpg is a frame of video, would it be efficient to have an image element and update the image source every received frame? Or is there a better way?
Nikita Tsukanov
@kekekeks
Oct 29 2017 12:31
use MP4
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 13:36
What is required to have a working custom Icloseable?
Nikita Tsukanov
@kekekeks
Oct 29 2017 13:39
I think I had one based on cancellation token
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 13:44
Any chance you can find it?
danwalmsley
@danwalmsley
Oct 29 2017 14:06
@kekekeks yeah I would, but the camera which is source is a sony camera and its live preview just spits out jpg images continually, so I would like to avoid encoding, was just really wondering if continually xhanging image source is inefficient?
Nikita Tsukanov
@kekekeks
Oct 29 2017 14:30
Use WritableBitmap
And some native decoder
to avoid unnecessary memory traffic
You'll get tons of stale bitmaps in memory otherwise
danwalmsley
@danwalmsley
Oct 29 2017 14:31
Ok cheers
Big Jake
@jakesays
Oct 29 2017 16:05
hey how's the skia stuff coming along?
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:06
mostly harmless working
Big Jake
@jakesays
Oct 29 2017 16:06
lol cool
i need a new ui on my raspi. gonna give win iot a try. apparently someone has a working spi driver for it. if it doesnt work then i'll try avalon on linux
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:09
a working spi driver for it
working
I had awful experience with SPI-connected screens
Big Jake
@jakesays
Oct 29 2017 16:18
@kekekeks using which driver?
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:22
I've ended up with my own driver
But it was only working with ~5 FPS
Big Jake
@jakesays
Oct 29 2017 16:23
ah
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:23
I could get it to send 30 frames per second
But then there would be some sync issues
And display starts to treat command as data and vice versa
Big Jake
@jakesays
Oct 29 2017 16:24
which display were you using?
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:24
So I had to run reset sequence now and then
Don't quite remember
It's better to get a board with some kind of proper display connector
Another issue is SPI throughput
You can't send more than 1MB per second or something like that
Or 2MB, don't quite remember
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 16:33
Any chance you could find your custom ICloseable implementation? @kekekeks ?
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:33
you can use Dispatcher.UIThread.RunLoop, I think
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 16:34
Dispatcher.UIThread.MainLoop(source.Token);?
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:34
+
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 16:34
I'm calling application.run which does that
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:37
well, your problem is elsewhere then
Big Jake
@jakesays
Oct 29 2017 16:41
@kekekeks spi is capable of something like 40mb/s
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:48
Hm
That was the limit of my particular board then
Or that particular screen, don't quite remember
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 16:49
If the ui thread is blocked then it shouldn't be responding right?
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:52
I guess so
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 16:52
So that's not it
As it's responding just fine
Just nothing being rendered
Nikita Tsukanov
@kekekeks
Oct 29 2017 16:53
Check if Dispatcher.UIThread.Invoke(()=>{ Console.WriteLine("123");}, DispatcherPriority.Background) works
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 17:06
That works
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 17:29
Any chance you could make a very basic custom icloseable implementation?
Nikita Tsukanov
@kekekeks
Oct 29 2017 17:35
I don't think that your issue is caused by IClosable
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 18:09
I've got no clue how to debug it though
Nikita Tsukanov
@kekekeks
Oct 29 2017 18:19
A minimal repro would be nice
ControlCatalog works for you, right?
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 18:29
Yeah
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 18:40
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:10
Well, ya know, if you are trying to display on-screen notifications at the corner of the screen
It won't work with wayland
I'll take a look at your repository tomorrow and check what's causing the black screen
Jurjen Biewenga
@JurjenBiewenga
Oct 29 2017 19:18
That's fine
danwalmsley
@danwalmsley
Oct 29 2017 19:33
@kekekeks
if I have an IBitmap, how can I get access to the raw pixel data?
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:34
You can not
Request that feature or something
Our bitmaps are also not disposable
danwalmsley
@danwalmsley
Oct 29 2017 19:36
I hacked around it
 var rawFrameData = new MemoryStream();

                    _lastFrame.Save(rawFrameData);
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:36
Ouch
danwalmsley
@danwalmsley
Oct 29 2017 19:36
just to get it working
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:36
it's not "raw"
It's encoded one
danwalmsley
@danwalmsley
Oct 29 2017 19:36
hmmm basically I have jpg data
I want to encode it to pixels like a buffer
and transfer those to writable bitmap
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:36
I think it would be better to use SkiaSharp directly
danwalmsley
@danwalmsley
Oct 29 2017 19:37
I was also looking at this
wonder if it could be useful here
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:37
The thing is that you already are using Skia
So there is no point of bringing yet another library
danwalmsley
@danwalmsley
Oct 29 2017 19:39
true
going to try skia
thanks
Jeremy Koritzinsky
@jkoritzinsky
Oct 29 2017 19:40
@danwalmsley I have an MJPEG parser in AvaloniaAV. I'll pull up a link
danwalmsley
@danwalmsley
Oct 29 2017 19:40
@jkoritzinsky awesome could be just what I need
@kekekeks
var skimage = SkiaSharp.SKImage.FromEncodedData(SkiaSharp.SKData.CreateCopy(e.FrameData));
The Playback/Frame stuff is really just wrappers for AvaloniaAV but the code itself works.
The main issue is this is horrible with memory perf. Lots of GC/memory pressure since we can't reuse bitmaps or dispose them
danwalmsley
@danwalmsley
Oct 29 2017 19:43
ah that's the issue I'm coming across
basically I can play the video
but as you say memory usage is horrible
so I was going to just keep updating a writable bitmap
and telling it to re-render
but I have no way of getting the raw pixels
@kekekeks if we made bitmaps disposable would this solve my problem?
I could just create a bitmap from jpg data, like the code @jkoritzinsky posted
and then quickly dispose of it when no longer needed
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:57

The main issue is this is horrible with memory perf. Lots of GC/memory pressure since we can't reuse bitmaps or dispose them

WritableBitmap is reusable

Jeremy Koritzinsky
@jkoritzinsky
Oct 29 2017 19:57
But WritableBitmap works at the raw pixel level, not the encoded image level
That's the problem Dan and I have
We can't reuse bitmap instances that are encoded as JPEG, etc.
Nikita Tsukanov
@kekekeks
Oct 29 2017 19:59
I think we can do nothing about that other than allow to dispose them
Since dimensions aren't exactly known at the point when we are decoding the data
Jeremy Koritzinsky
@jkoritzinsky
Oct 29 2017 20:00
Sounds good to me