HearthSim / Hearthstone-Deck-Tracker

A deck tracker and deck manager for Hearthstone on Windows
https://hsreplay.net/downloads/
4.7k stars 1.11k forks source link

HDT uses a lot of GPU when idle #4066

Closed riQQ closed 4 years ago

riQQ commented 4 years ago

Bug report

Also discussed on reddit: https://www.reddit.com/r/hearthstone/comments/ggnhxw/hearthstone_deck_tracker_uses_60_of_gpu_and_20_of/

Expected Behavior

HDT shouldn't use a lot of the GPU when idle

Actual Behavior

HDT uses a lot of GPU when idle. This occurs when Hearthstone is not running and with the Overlays disabled in the HDT options. After quitting HDT the gpu usage goes back to 0%.

Steps to reproduce behavior

Use HDT version 1.11.6 or higher (changed to .NET Framework 4.7.2 and higher version of MahApps.Metro). Further circumstances are yet unknown as it doesn't affect everyone.

Log/Screenshots

bug_idle_gpu_usage

joc256 commented 4 years ago

According to procmon it seems to be spinning trying to open various Hearthstone logfiles, not sure why that would show up as GPU usage tho?

image

riQQ commented 4 years ago

That's normal and doesn't cause GPU usage.

joc256 commented 4 years ago

Right I used the apitrace tool https://github.com/apitrace/apitrace to do a a trace of all GPU calls made by HDT:

C:\"Program Files (x86)"\apitrace-msvc\apitrace.exe trace --api d3d9 "C:\Users\me\Hearthstone-Deck-Tracker\Hearthstone Deck Tracker\bin\x86\Debug\Hearthstonedecktracker.exe"

That gave me a 160MB "Hearthstonedecktracker.trace" which I was able to load in the "qapitrace" gui from the same project. I'm no expert on either C# or D3d but the icons shown in the screenshot seem to match some of the icons in the HDT UI so does this mean the entire app ui is somehow being redrawn using Direct3D every frame? That would explain the GPU usage certainly...

image

joc256 commented 4 years ago

Window Detective http://windowdetective.sourceforge.net shows thousands of these "MilChannelNotify" messages being delivered to one of the HDT windows.

image

MilChannelNotify apparently is an internal WPF message used to tell its render thread to do some rendering. There aren't many Google hits but I found a few bugs that suggest it might be to do with animations still being run for hidden UI elements.

DayKev commented 4 years ago

Would listing .NET assembly/CLR versions installed be useful? I haven't been running into this bug from what I can tell (GPU usage seems appropriate, only rose ~4% after it started according to MSI Afterburner).

ghost commented 4 years ago

I have been running into this bug and GPU usage goes up to 41% for a few mins, same as mentioned in "actual behavior" this started to happen after bobs buddy feature

pendoza commented 4 years ago

I have the same problem. GPU is normal watching YT and having HS open. 2020-05-12 18_56_05-Window

Having HDT open with it but not on active window (so minimized) it doesn't produce anything special.

2020-05-12 19_05_43-2020_05_12_18_54_45_Window png - Paint

But if you want to use the program it shoots up to max. Even if you let it maximized but on background. So it seems to me that using the program lets it do all those things mentioned by others. 2020-05-12 19_08_17-Hearthstone

riQQ commented 4 years ago

Are the ones with problems using a monitor at 144 Hz (not only a monitor being 144 Hz capable but actually having the refresh rate setting in Windows set to 144 Hz)?

ghost commented 4 years ago

Yes using 144 Hz

pendoza commented 4 years ago

I have 2 monitors.

2020-05-12 23_21_42-Settings 2020-05-12 23_21_14-Settings

Otto42 commented 4 years ago

Can confirm, HDT just jumps the GPU usage up to 20% and the CPU usage up to 10% for no reason. This is without HS or anything else of note running, just the main window of HDT does it.

Minimizing the main HDT window drops all usage to zero again. It appears to be only the main window causing this.

The overlays during the game only seem to cause about half as much usage as the main window does, although it is constant while they're on screen.

asdman384 commented 4 years ago

confirm issue. HDT dramatically drains my GPU resource

azeier commented 4 years ago

Investigating this. Appears to be related to the deck picker component. Will update as I find out more.

azeier commented 4 years ago

I think I found & fixed the issue.

It appears to be a problem with MahApps' TextBoxHelper.IsWaitingForData, though I have no idea why that would be.

Here's a dev build. Can you guys try and see if you still have the same problems?

https://github.com/HearthSim/HDT-dev-builds/releases/download/v1.12.2.3976/HDT-Installer.exe (This build will overwrite the existing installation and automatically update to the next HDT release once available)

joc256 commented 4 years ago

That seems to have fixed the issue.

Before: before

After:

after

Thanks!

azeier commented 4 years ago

Fantastic. This will be fixed with v1.12.3, which should roll out shortly.