-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI & graceful shutdown support #10844
Comments
IMO all the
IMO the fix should be done once the UI decoupling is done on this part, otherwise, it might cause conflicts. |
I agree that that would be much better fix though I wonder when that UI decoupling is supposed to be finished. What time frame are we talking about? |
PR that touches it just got merged. You can start to fix if you wish in this file: |
I think it makes most sense to start by fixing this, then moving on to app startup logic and so forth. I'll write a PR for it. |
@ichthus1604 What is the status of this? |
The second part of this issue is done. The remaining task is: @kiminuo Can you elaborate more on this? |
At the moment, we start initializing stuff in Global.cs and then we start an Avalonia application. Now I'm saying that right after the line https://github.com/zkSNACKs/WalletWasabi/blob/574080bd3b62855ef8d637c3be4e1071aea5491f/WalletWasabi.Fluent.Desktop/Program.cs#L206 all Avalonia UI stuff should be stopped. I'm talking mainly about that reactive stuff that reacts to, eg, synchronizer downloaded a new filter etc. If we reach that point we can safely dispose Maybe with the UI decoupling stuff you have some rules that makes sure that this (ie UI task accesses a service defined in Global that is being disposed) does not happen anymore but it was certainly the case in the past. It's worth noting that Avalonia 11 seems to have better support for an application lifetime (new API methods) than Avalonia 10. Another thing that's worth noting is that we use Avalonia package in a non-standard way (we initialize |
I think this is already happening like that.
So in So it shouldn't be a problem, right? |
I've taken a look at it and while what you say makes sense to me, I think we are not quite there yet because:
-> So I believe we are on the right track but the details feel weird to me and it feels it's overly complicated at the moment. |
I can repro. Actually a breakpoint before |
@kiminuo Using |
Did not check anything yet, but my guess would be there is no more UI dispatcher running jobs during that point of time. |
Yeah, I remember that I played with that a while back and However, I'm not persuaded it's actually the solution we are looking for as I would expect that if WW is terminated using "X" button we would not need any dispatcher in such case (why should we need it?). That makes me think that we should identify the proper place when to
Can we call these two commands simply after this line https://github.com/zkSNACKs/WalletWasabi/blob/e8d7bc0de5cce55f470f9df9fca997ae26592e8f/WalletWasabi.Fluent.Desktop/Program.cs#L206 ? Or does MainViewModel.Instance.ClearStacks();
MainViewModel.Instance.StatusIcon.Dispose(); require Avalonia to be actually running in some way? |
I think it is actually a leftover, because previously the termination methods weren't separated. And it threw an exception due to it was executed on non UI thread. Testing it now without the dispatcher, I don't see any exception. |
It was modified here https://github.com/zkSNACKs/WalletWasabi/pull/10529/files#r1173029462 and I added some explanation.
No. There is, for example, this line https://github.com/zkSNACKs/WalletWasabi/blob/f1b56713c893626a3f6102fcee8b35b4685318bb/WalletWasabi/Services/Terminate/TerminateService.cs#L49 and documentation clearly states:
And while it's true that some of my PRs regarding CTRL+C behavior has probably made that dispatch call ( So I think more correct approach is to move these two lines: MainViewModel.Instance.ClearStacks();
MainViewModel.Instance.StatusIcon.Dispose(); The question is where to. This seems to work #11511 but maybe Avalonia has some sort of callback which is more fitting. WDYT? |
I don't know about it, @wieslawsoltes? |
There were multiple PRs created to fix this "meta" issue and AFAIK it works OK as of now. I'm not aware of anything else that would need to be done for this issue to be closed. There are things that we can improve (nice to have) but it's not blocking right now. So I'm closing the issue now. |
I implemented a several PRs to handle CTRL+C gracefully. However, there are still issues, like #10814 and #10325.
So to move forward, I would like to discuss:
StopUiTasks()
here so that one knows that UI cannot touch services that are being disposed.Task.Delay
calls so that it accepts a cancellation token:UiContext
(with the meaning "application is stopping"). Not sure if there is a better way.I had a chat with @wieslawsoltes and he said that it is a good time to solve these issues because the UI decoupling PRs are being worked on (tracked under #10761).
This issue was filed for discussing purposes. Please share your honest opinion.
WDYT? @SuperJMN @ichthus1604 @soosr @wieslawsoltes (anyone else to ping?)
The text was updated successfully, but these errors were encountered: