WPF apps raise timer resolution via timeBeginPeriod and never back down
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
Increasing the timer resolution leads to an increased rate of timer interrupts on the CPU, waking it up from sleep states more often. When WPF apps run in the background, regardless of UI state, this can dramatically increase the power consumption, ["which reduces the battery run time on mobile systems by as much as 25 percent"](https://docs.microsoft.com/en-us/previous-versions/windows/hardware/download/dn550976(v=vs.85)), according to Microsoft.
## Additional details / impact:
* https://social.msdn.microsoft.com/Forums/vstudio/en-US/d39edd26-5db3-4803-a536-6d39bb16c50c/on-app-launch-wpfgfxv0300dll-is-calling-timebeginperiod1
* https://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/
* https://github.com/File-New-Project/EarTrumpet/issues/189
## Steps to reproduce
1. File > New > Project a blank WPF app and execute
2. In elevated command prompt, execute `powercfg -energy duration 5`
3. Observe WPF app is listed in energy report warnings
## Related code:
https://github.com/dotnet/wpf/blob/c3b1ecefd9debf850b4757bb8d657b15af79469d/src/Microsoft.DotNet.Wpf/src/WpfGfx/core/uce/rendertargetmanager.cpp#L960-L970
Contributor guide
Assessment
This issue has not been assessed yet.