These are chat archives for AvaloniaUI/Avalonia

11th
May 2016
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 00:00
Ok. Looks like the RunWithMainWindow method constructs the MainWindow object on the main thread and then tries to apply the styles on the main thread instead of on your UI thread…
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 00:00
yes
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 00:00
I have an idea of how to fix it in core, but as I’ve mentioned before I don’t have time right now to do so.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 00:00
ic
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 00:02
What you could do is manually create the window in the correct synchronization context.
Darnell Williams
@Seeker1437
May 11 2016 00:03
WOW
really/
even more sense XD
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 00:04
Actually… This might just require core changes to support correctly. Any chance you can have the UI running on the main thread?
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 00:04
already tried
O I mean
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 00:04
You could put the STAThread attribute on the Main method to force the main thread to be STA.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 00:04
I got the current synccontext and Post() the initialization on it
already tried as well
:P
we are trying to instead of create a new Thread, use :
        private Thread _uiThread;

        public PIUIPlatformThreading()
        {
            _uiThread = Thread.CurrentThread;
        }
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 00:05
The reason that doesn’t work is because I think the new synchronization context hasn’t been installed yet. That’s why I’m suggesting running the UI thread on the Main thread instead of starting a seperate thread.
Let me know how that works.
I’ve got to run for a bit. I’ll be back in like 30-45 mins or something around there.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 00:06
thanks tty
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 01:16
no lucky
tried to simplify it
internal class PIUIPlatformThreading : IPlatformThreadingInterface
    {
        public bool CurrentThreadIsLoopThread => Thread.CurrentThread == _uiThread;

        private Queue<SendOrPostCallback> _queue = new Queue<SendOrPostCallback>();
        private static object SyncRoot = new object();
        public event Action Signaled;
        private Thread _uiThread;

        public PIUIPlatformThreading()
        {
            _uiThread = Thread.CurrentThread;
        }

        public void RunLoop(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                lock(SyncRoot) 
                {
                    Signaled?.Invoke();
                    if (_queue.Count == 0)
                        continue;

                    var workItem = _queue.Dequeue();
                    if (workItem != null)
                    {
                        workItem.Invoke(null);
                    }
                }
            }

            //_uiThread = new Thread(new ThreadStart(() =>
            //{

            //}));
            //_uiThread.Name = "UI Worker Thread";
            //_uiThread.SetApartmentState(ApartmentState.STA);
            //_uiThread.Start();
        }

        public void Signal()
        {
            EnsureInvokeOnMainThread(() => Signaled?.Invoke());
        }

        private void EnsureInvokeOnMainThread(Action action) => Post(new SendOrPostCallback(_ => action.Invoke()));

        private void Post(SendOrPostCallback callback)
        {
            // queue the item and don't wait for its execution. This is risky because
            // an unhandled exception will terminate the STA thread. Use with caution.

            lock (SyncRoot)
            {
                _queue.Enqueue(callback);
            }
        }

        public IDisposable StartTimer(TimeSpan interval, Action tick)
        {

            if (interval.TotalMilliseconds < 10)
                interval = TimeSpan.FromMilliseconds(10);
            object l = new object();
            var stopped = false;
            Timer timer = null;
            var scheduled = false;
            timer = new Timer(_ =>
            {
                lock (l)
                {
                    if (stopped)
                    {
                        timer.Dispose();
                        return;
                    }
                    if (scheduled)
                        return;
                    scheduled = true;
                    EnsureInvokeOnMainThread(()=>
                    {
                        tick();
                        lock (l)
                        {
                            scheduled = false;
                        }
                    });
                }
            }, null, TimeSpan.Zero, interval);

            return Disposable.Create(() =>
            {
                lock (l)
                {
                    stopped = true;
                    timer.Dispose();
                }
            });
        }
    }
the StartTime() is never called... the RunLoop() is being called but as the queue.Count is always 0, than there is nothing to invoke
which is probably OK to have the queue empty now cause we have nothing running on another thread
but nothing is being rendered... pretty weird
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 01:47
I think everything hooks into Signaled. StartTimer is for any DispatcherTimers.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 01:58
ok
well
if there is no problem in this class it probably means the problem is somewhere else :(
I got no rendering at all
no exceptions, but still no errors
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 02:50
You’re rendering to a device file right? You can try changing that render target to be a regular file and see if data is being written to it.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 02:54
by device file you mean the /dev/fb framebuffer
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 02:54
Yep
Darnell Williams
@Seeker1437
May 11 2016 05:50
@jkoritzinsky you around?
Darnell Williams
@Seeker1437
May 11 2016 12:56
@grokys hey we believe we have most everything working... however on our platform nothing is requesting a DrawingContext from our RenderTarget so after the window is available, we still get a black screen. I'm not sure what to do.
Steven Kirk
@grokys
May 11 2016 13:05
ok, rather than me explain it, run one of the sample apps and put a breakpoint here to see where it should be requested: https://github.com/Perspex/Perspex/blob/master/src/Windows/Perspex.Direct2D1/Media/DrawingContext.cs#L40
it's easier for you to see the call stack for yourself than for me to explain it
Darnell Williams
@Seeker1437
May 11 2016 13:35
Okay thanks will do!
Darnell Williams
@Seeker1437
May 11 2016 13:51
Okay. Everything is clear.
Steven Kirk
@grokys
May 11 2016 20:15
so i've written a script to do the rename, which i think works
question is when to do it
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 20:17
how about now? :D
Steven Kirk
@grokys
May 11 2016 20:22
would it cause problems for you guys to do it right now?
Darnell Williams
@Seeker1437
May 11 2016 20:22
Im all for it!
Steven Kirk
@grokys
May 11 2016 20:23
ok... lets go for it then
need to do a few final checks
Darnell Williams
@Seeker1437
May 11 2016 20:24
I am working on Calendar as soon as @galvesribeiro and I get Perspex working. We will get it working
Steven Kirk
@grokys
May 11 2016 20:24
:D
danwalmsley
@danwalmsley
May 11 2016 21:04
do it!
Steven Kirk
@grokys
May 11 2016 21:37
ok, testing on a branch - PLEASE NO-ONE COMMIT TO MASTER! :D
CI running, lets see what happens
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 21:50
lol
:)
suddenly, it exploded:)
Darnell Williams
@Seeker1437
May 11 2016 21:55
its passed!
Steven Kirk
@grokys
May 11 2016 22:01
still running as far as i can see
but looks promising!
success! wow
ok, will merge to master then
then we'll need to rename the repos and org
and that's when we find everything broke ;)
Steven Kirk
@grokys
May 11 2016 22:07
i'm hoping that the fact there's the rename script will make it easy to convert branches etc too
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 22:09
nice
Steven Kirk
@grokys
May 11 2016 22:09
actually, i meant to merge the property validation branch before i did the rename, doh
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:10
I'd suggest renaming the repos and the org as soon as possible since the link to Gitter is currently broken.
Steven Kirk
@grokys
May 11 2016 22:10
yeah, will do that now
better wait for CI to finish though
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:10
Yeah.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 22:10
Avalonia! :P
Steven Kirk
@grokys
May 11 2016 22:13
ok, publishing to myget is failing
as we'd need to either rename the org or create a new account
not a big problem for now
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:14
We can always make AppVeyor host our NuGet feed. It's built in for free accounts.
Steven Kirk
@grokys
May 11 2016 22:16
ok, org and repository renamed
i assume that @kekekeks set up a myget feed rather than using appveyor to host the packages for a reason?
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:18
Maybe he didn't see the feature. It's kind of hidden.
Steven Kirk
@grokys
May 11 2016 22:20
well nuget packages are uploaded to appveyor too
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:21
Maybe we just need to rename the feed. BTW the appveyor link is broken too.
The feed URL by default is a random hex string (possibly a guid, not quite sure).
You can find the place to change the setting in Settings > NuGet > Project feed URL.
Steven Kirk
@grokys
May 11 2016 22:30
renamed the appveyor project but the URL hasn't changed, hummm
seems you might need to ask them to manually change it
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:34
We could always just create a new AppVeyor project.
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 22:34
I prefer AppVeyor instead of MyGet...
their build system is WAY better than MyGet
Steven Kirk
@grokys
May 11 2016 22:34
i've renamed the org and the project but only the org has changed in the URL
we just used myget for hosting .nupkgs
Steven Kirk
@grokys
May 11 2016 22:40
ok, i just added a new myget feed
called it avalonia-ci because "nightly" was a misnomer ;)
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 22:41
@grokys where u do the CI?
Steven Kirk
@grokys
May 11 2016 22:41
appveyor
going to update the version numbering now too - will be 0.2.0.$version-alpha
Steven Kirk
@grokys
May 11 2016 22:47
hopefully that should allow smooth upgrades across feeds
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:50
I like that plan.
Btw I'm currently getting a dev environment set up on a spare computer now that exams are done. I'll be able to get stuff done "soon" (once I get VS set up the way I want)
Steven Kirk
@grokys
May 11 2016 22:56
cool!
annoyed that i forgot to merge the property validation branch before the rename!
hopefully won't be too much of a pain
Gutemberg Ribeiro
@galvesribeiro
May 11 2016 22:58
hehehehe
Jeremy Koritzinsky
@jkoritzinsky
May 11 2016 22:58
Should be fine. Just a rename here and there.
Darnell Williams
@Seeker1437
May 11 2016 23:04
Im excited
Onwait there is a new feed you said?
Steven Kirk
@grokys
May 11 2016 23:09
there will be... appveyor is going really slow though this evening