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

CPU spike on Windows with WM_EVENT and OpenGL #908

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

CPU spike on Windows with WM_EVENT and OpenGL #908

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.0
Reported for operating system, platform: Windows (All), All

Comments on the original bug report:

On 2013-06-07 01:41:43 +0000, wrote:

Created attachment 1179
Force ValidateRect to validate with OpenGL

On some Windows systems, when switching from fullscreen to windowed mode in my game, the CPU will spike and the application never shows the window again.

See the part of the e-mail thread here:

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2013-June/088626.html

I change the window by calling:

SDL_SetWindowFullscreen(gScreenInfo.sdlWindow, SDL_FALSE);
SDL_SetWindowSize(gScreenInfo.sdlWindow, sdlWindowWidth, sdlWindowHeight);

which you can see in our source:

https://code.google.com/p/bitfighter/source/browse/zap/VideoSystem.cpp# 377

Then all of a sudden the application gets stuck in WIN_PumpEvents() in SDL_windowsevents.c. I turned on WMMSG_DEBUG and found that there was an endless stream of WM_EVENT messages. I also found that where WM_PAINT is being handled in the callback WIN_WindowProc(), ValidateRect is somehow not clearing, or it is persisting, the WM_EVENT message like it's supposed to (according to the docs).

This may be a hardware issue. The issue has appeared on three different systems, one of them sporadically:

  • Windows XP SP3 running in VMware 9.0 (without VMWare 3D acceleration, but with the tools and drivers installed), Host: openSUSE 12.3 x86_64, NVidia NVS 3100M
  • Windows XP SP3 64bit running in VirtualBox, Host: Debian Wheezy (stable), Mobility Radeon HD 4100 (this was the sporadic one)
  • Windows 7 64 bit, Radeon 6770

After some tinkering, and noticing that SDL 1.2 has an exception for OpenGL in the WM_PAINT callback handler, I came up with the attached patch.

It works! But I still don't understand the actual cause.

On 2013-06-07 01:46:35 +0000, wrote:

I'm sorry that I've tried for several hours to get a consistent test-case, but I have been unable to do so. It could be that something in our code is exacerbating some obscure issue, but I cannot find anything.

On 2013-06-07 02:20:45 +0000, Sam Lantinga wrote:

Crazy, but it should be fixed now.
http://hg.libsdl.org/SDL/rev/737cc5bad795

Thanks!

On 2013-06-07 02:23:24 +0000, wrote:

Thank you!

I am curious, will this not affect other video systems other than OpenGL?

On 2013-06-07 03:08:10 +0000, Sam Lantinga wrote:

I don't think so, it should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant