Skip to content
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

Extremely High CPU Usage #36

Closed
VasilisPat opened this issue May 23, 2020 · 24 comments
Closed

Extremely High CPU Usage #36

VasilisPat opened this issue May 23, 2020 · 24 comments
Labels
bug Something isn't working

Comments

@VasilisPat
Copy link
Contributor

VasilisPat commented May 23, 2020

Describe the bug
High CPU usage and very low GPU usage during playback.

To Reproduce
In normal mode the CPU hits very high utilization and GPU usage is alomost 0%.
If I disable all video processing the CPU seems to lower a bit and GPU takes a little bit of workload ~15%. This was testes both in a laptop with intergrated and discrete graphics and in a desktop with discrete graphics. Both environements came up with the same result. Also when video processing is disabled, little horizontal blurred lines seem to appear in the video playback.

Expected behavior
Shouldn't the CPU have less of a workload than the GPU in this situation, or split the workload between them?

Aerial Version
Beta 0.5.3

Additional context
I have proposed an enhancement #34, don't know if this can be achieved but this could be a good idea.

@VasilisPat VasilisPat added the bug Something isn't working label May 23, 2020
@OrangeJedi
Copy link
Owner

Hmm. My system (Ryzen 7 3800X, GTX 1070) has about 10% CPU usage and 20% GPU usage when running Aerial on my dual monitor setup. (Both monitors are larger than 1080p). My best guess is that in both your desktop and laptop, Windows isn't choosing to run Aerial on your GPU. I would make sure you have the latest drivers installed and check Window's power and performance settings.

As for the lines appearing when you disable video processing, my best response is that "there is a reason we have video processing enabled by default." The lines are a known issue, but there isn't much we can do about it. When you disable video processing Aerial falls back to the default HTML video player. Video processing is simply redrawing the video onto an HTML5 canvas. This helps with resizing, transitions, coloring, and a few other things.

@VasilisPat
Copy link
Contributor Author

The lines are visible whether video processing is disable or not. Although I have noticed that if it's enabled, it tends to happen to a fraction of the videos. It's like splitting the screen horizontally to three panels and have different focus and blur to them, with the best resolution being the center.

So as a solution you propose checking which GPU is set by the system defaults to run the Electron process?

@OrangeJedi
Copy link
Owner

Hmm. You should send a screen shot, I would be interested to see how bad it is.

And yes, checking which GPU is running Aerial should help.

@VasilisPat
Copy link
Contributor Author

I tried IrfanView to try and capture the screen based on a timer(20 seconds after screensaver is set to start)but it returns a black screen.... Any tools that might have worked for you?

@OrangeJedi
Copy link
Owner

Try running Aerial from the command line like this: aerial.scr /s /nq. This will run Aerial in fullscreen with self quitting disabled. See here for the full list of arguments Aerial supports.

@VasilisPat
Copy link
Contributor Author

Can't seem to find the right video at the moment, I will send a screenshot whenever the lines reappear.
Also another thing I noticed, preview tends to require less cpu and gpu usage. Is this normal with windows?

@OrangeJedi
Copy link
Owner

Hmm. My fans do seem to be a bit louder when actually running the screensaver, as apposed to previewing it. I wonder if it has something to do with how windows actually runs the screensaver. I'll take a look into it.

@VasilisPat
Copy link
Contributor Author

I might have found the cause of the problem. I run one desktop and two laptop setups. The desktop has two monitors connected to its discrete GPU. The laptops have their onboard screen and a monitor through their hdmi output. I set them all to run aerial with the discrete gpu, except desktop which is default. What I have found from task manager, is that the laptops now use both integrated and discrete gpu when running aerial. So I disconnected the external monitors. The result is that the laptops where much quiter and only the discrete gpu had a load. I did a little resarch and saw a lot of people saying that the laptop's hdmi port can only run an external display through the integrated graphics only. Can't figure out why but this seems to fix the high cpu and gpu usage, so not a bug from aerial. As for the desktop, sometimes has a high load on both cpu and gpu sometimes not, so I have to investigate a litlle bit more for that.

@arsalan86
Copy link

I frequently encounter a similar issue, but I haven't been able to measure CPU usage.

The screensaver seems to start fine, but it grinds to stuttering halt in a matter of minutes, and my CPU and GPU fans both start screaming.

This is bizarre because I can play the videos (4K and 1080p) just fine in VLC without issue.

This issue occurs with either 4K or 1080p issues.

I'm logging cpu usage data, i'll share if i find anything useful

My setup:
i7-7700U (ultrabook cpu)
16gb ram
nvidia gtx 1050 graphics dock via thunderbolt
2x 4K displays, 1x WQHD ultrawide

@arsalan86
Copy link

There is definitely something funny going on - aerial.scr uses ~50% CPU when it's triggered by Windows' idle timer. If I run the screensaver by hitting the Preview button in Screen Saver Settings, it barely hits 2% CPU usage.

This is consistent and repeatable across system restarts.

I know it's not throttling or SpeedStep - those are disabled so I have constant CPU clock and power.

It hints at malware, but I run a pretty tight ship, and have a good antivirus and firewall. Strange

@OrangeJedi
Copy link
Owner

I've notice that Aerial uses a lot more power when activated by the system than in preview mode or when I run it from the command line. I wonder if it is something with how Windows runs screensavers?

@arsalan86
Copy link

I just tested with cDima's Aerial. It is the same case with that: uses a lot more CPU when activated by the system, and runs like a breeze in preview mode.

From the surface of it, it doesn't look like there's been much change in the way Windows handles screensavers since win95. There's barely any technical/system level documentation to be found.

In the absence of empirical data, a question about arbitrary experience: does your screensaver appear to stutter while using unreasonable amounts of power?

@OrangeJedi
Copy link
Owner

When I was doing some testing whenever usage got close to 100% lots of stuttering happened. So yes. But on some computers where the usage wasn't close to 100% (smaller screen space, better GPU, etc.) it looked fine.

@arsalan86
Copy link

https://docs.microsoft.com/en-us/windows/win32/lwef/screen-saver-library

Have you seen this page? The only thing that I think might be the culprit is security context.

===

In other news: If I start screensaver from DisplayFusion's context menu, it runs fine. But having to manually start a screensaver each time defeats the purpose

@arsalan86
Copy link

Try running Aerial from the command line like this: aerial.scr /s /nq. This will run Aerial in fullscreen with self quitting disabled. See here for the full list of arguments Aerial supports.

@OrangeJedi that link is broken.

@arsalan86
Copy link

The dark chapter in my life that has been Windows System Programming.

I wrote a simple c# 'screensaver' that just counts out fibonacci and displays it on screen with a timer.
It performs far far better when previewed, and uses less CPU. When I say I wrote, I actually mean I made a few convenient changes to cDima's aerial. I am nowhere closer to figuring out what's wrong here, but one thing I know for certain:

This is not a bug with aerial, and should be closed.

On the other hand, I've been able to use Display Fusion to launch aerial.exe /s (renamed from the .scr) based on it's own idle timer. It works beautifully - It renders fast and uses ~3% CPU.

I did try Windows' own task scheduler, but it would not launch the screensaver with focus, and just figuring out the security context is a nightmare.

@VasilisPat
Copy link
Contributor Author

Surely it's not a bug concerning only aerial. But I don't think it should be closed. In fact your article about the screen saver library made me check through again all the parameters when running the screensaver. Running it through displayfusion dramatically reduced the cpu & gpu load. To tell you the truth, I think this issue should remain open just until the cause of the problem is found, not necessarily the solution. Reading through some electron based documentation it might have to deal with signing the app with a certificate, but I will take a deeper look through it.

@arsalan86
Copy link

I think this issue should remain open just until the cause of the problem is found, not necessarily the solution.

If you put it that way, it makes good sense. The major reason I switched over from cDima's aerial to this one is the performance issue.

I do like getting to the bottom of things. One thing to investigate:

While I'm consistently recording high CPU usage for aerial.scr when windows activates it, I don't know what the CPU is doing in all those extra cycles that are being attributed to the screensaver. I keep referring back to the context: maybe kernel or other system worker threads get activated along with a screensaver, in that shared context (indexing, for example). Why this would indicate high CPU usage for aerial boggles me. I know that the CPU does not go into a low power (C2/3/etc) state, nor is it due to throttling or a change in the clock speed - I've controlled for that.

It might just be malware - a screensaver seems like a good place to hide something like a cryptominer.

@OrangeJedi
Copy link
Owner

I agree that we should leave this open, at least until we can pin down the cause of the problem. It does seem to be a problem with Windows itself rather that Aerial, the fact the when ran from the commandline there is no issue shows that. I would like to fix the issue as it would seem that Aerial is stuttering on lots of computers, but I have no idea how feasible it is.
If we could find where the extra CPU cycles are going than that would be a huge help, it also might be possible to find a way to circumvent the issue somehow.

As for @arsalan86's question about the link, the link was broken because we were moving around some documentation. The same place can be found here

@VasilisPat
Copy link
Contributor Author

An initial search I did came back with 2 possible scenarios:

@VasilisPat
Copy link
Contributor Author

Quick Update

  • Created an exception for all the folders of Aerial to exclude any possibillity of false alarm malware.
  • Checked for scheduled tasks while system is idling

Any of that action seemed to give any hint about the problem. During testing I noticed somthing though. I let the screensaver automatically start for a number of times, in which some of them I heard the fan spinning loud but in other I didn't. This might give a clue that it might be some task running every now and then.
In the other hand, when I connect an external display via HDMI the fans spin at all times the screensaver is on. This only applies to my laptop, the desktop seemed to behave normal in any monitor setup.

@OrangeJedi
Copy link
Owner

I took some inspiration from @christian-korneck's workaround in #52 and wrote this page detailing how to set up Aerial to run in Window's Task Scheduler instead of the normal screen saver app. It seems to work pretty well and doesn't have the frame rate issues that it did before.

@MadNBG
Copy link

MadNBG commented Nov 21, 2020

I am using an Office-PC with internal GPU (Intel HD4600 -Uuuh!).
With 0.5.4 there are no micro-stutterings nor my fan blows up.
I guess, the CPU load is much better.
I now use this awsome screensaver, no problems for me anymore.

@OrangeJedi
Copy link
Owner

The day has finally come where this issue can be closed in peace 🤞
The issue with super high power usage and lagging frames only seemed to occur when Windows ran Aerial as a screensaver. With v1.0.0 Aerial is now a self-supporting app and no longer uses the Windows screensaver framework. Any problems from before should be gone now.

If by chance issues related to this come up for versions past v1.0.0, open a new issue as the cause will hopefully be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants