-
Notifications
You must be signed in to change notification settings - Fork 743
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
perf(x11): use a Timer instead of a DispatcherTimer for render callbacks #19054
base: master
Are you sure you want to change the base?
Conversation
@HakanL With this PR, the Uno app shouldn't be scheduled by the OS at all if there's nothing to do and should not be spin-waiting at all. Let us know if this fixes the problem. |
// running XConfigureEvent and rendering callbacks on a timer is necessary to avoid freezing in certain situations | ||
// where we get spammed with these events. Most notably, when resizing a window by dragging an edge, we'll get spammed | ||
// with XConfigureEvents. | ||
_timer = new Timer(static obj => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we conditionally stop the timer if we know we do not have anything to draw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't directly pause the System.Threading.Timer
but I think there are ways to get around this, if we're careful enough. However, I don't think it matters. The Timer
actually sleeps (i.e. the equivalent of a Thread.Sleep) so waking up and immediately sleeping again 60 times a second should be more than fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is about CPU idle time, which may prevent CPU to go in low-power modes. It's generally best to avoid doing work we know nothing needs to be done.
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-19054/index.html |
@ramezgerges I'd be happy to test this on my RPi once you think it's ready to try. I haven't run my application with non-Nuget Uno (from source), do you have any docs on how to do that? I think last time I tried I wasn't able to successfully build it, but it was a while ago (may have been missing dependencies for Android, Mac, etc, since I'm only doing Win and Linux). |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-19054/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-19054/index.html |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-19054/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-19054/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-19054/index.html |
The CI for each PR generates nuget packages that can be used in a local feed. To test this PR, download the nuget packages from here, extract the zip, create a new entry in |
|
_renderTimer.Interval = TimeSpan.FromTicks(delta); | ||
_renderTimer.Start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we're setting up the interval to be the time since the last update? Aren't we trying to render immediately, or at least at the FPS interval?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're rendering immediately if the last frame was more than 1/60 secs ago. If the last frame is within the last 1/60 secs, we wait the remainder of this 1/60 secs "time slice" before rendering again, basically capping the frame rate at 60.
Is that the correct artifact URL? It only downloads two binlogs in the zip file. |
That worked better, thanks @ramezgerges ! I'll grab them and test locally. |
Alright, I was able to run with the updated Nuget packets. So far it's looking very promising, I used to be around 45-50% CPU time when idling (as viewed from |
@ramezgerges I'm getting this error while trying to build in
|
I was able to build now, after doing some rebuild all, etc. But not sure what caused the issue with the Toolkit, and not sure if it'll come back, but I'm good for now. |
Thanks for the update@HakanL. I wonder, do you any animated controls, like a progressring or progressbar in your app, even if it's not visible? |
I have a disabled ProgressBar on the splash screen, but I tried to remove it and it made no difference. |
GitHub Issue (If applicable): closes #19042
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Other information
Internal Issue (If applicable):