Handmade Hero»Forums»Code
Livet Ersomen Strøm
163 posts
Window manager going down? timeBeginPeriod
Yesterday I made this little app that copies the bitmap form GetDC(0) (Desktop) in a gameloop, 30 times a second.

The application uses the Winmm.TimeBeginPeriod 1 call. And it sleeps at the end of every frame.

It consumes about 3-5-7% cpu depending on how much of the screen changes between frames, because I save those changes away to an open file.

(I was surprised at how well this worked. If you havent tried it, maybe you should, just to see how surprisingly easy it is to make a screen desktop recorder).

But what happens is: This makes the Window manager go down sometimes. And my question is if this maybe could be related to setting the timeBeginPeriod? Because that is a global setting. I doubt that the copy from the desktop would make the manager exit, although I wouldn't know.

I just found it worth mentioning. The timeBeginPeriod call is affecting systemtimers, and I am not sure it very safe to use it. As far as I know it was Google that used this technic and got to be publicly critisized for it, as it caused battery-life to diminish.
19 posts
Window manager going down? timeBeginPeriod
Going down? Are you using dwm or the classic compositor? Also, does it just crash or is it doing that "low performance detected switching to classic mode" which should not happen with Windows 8 and later and can be turned off in the previous versions if I remember right.
Livet Ersomen Strøm
163 posts
Window manager going down? timeBeginPeriod
Bigpet
Going down? Are you using dwm or the classic compositor?


dwm.exe

Bigpet

Also, does it just crash or is it doing that "low performance detected switching to classic mode" which should not happen with Windows 8 and later and can be turned off in the previous versions if I remember right.


It disappear quietly from the processlist. Yes, exactly the way it does when a program starts directdraw or something. (I dont) And it dont come back.
Mārtiņš Možeiko
2559 posts / 2 projects
Window manager going down? timeBeginPeriod
Are you calling GetDC(0) just once, or in a loop? It should be called once, obviously.
Can you show your code? I can not think of anything that could crash dwm.exe process.
Livet Ersomen Strøm
163 posts
Window manager going down? timeBeginPeriod
Edited by Livet Ersomen Strøm on
Yes it's called once and tested for. The program works and keeps running. But I think it went away. After I changed some code, that made it less greedy, so it now is able to double the amount of frames, it stopped taking down the dwm.

EDIT: I now think the problem is my graphiccard is failing. It seems the fan has been failing the last couple of days, and slowly causing problems.