SDL 1.3 - App hangs after resize

We’ve just recently added code to our app to be able to change the window size (in windowed mode) during run time, using the SDL_SetWindowSize() function. This appears to work fine and our game loop continues until it gets to our event manager. Our event manager polls all events in can by calling SDL_PollEvent(&SDL_Event) in a while loop each frame. On the frame immediately after calling SDL_SetWindowSize() it hangs on the first event it polls, and has to be ended in task manager(I’m on windows, haven’t been able to test other platforms yet). CPU usage is at 99% when it hangs.

I have no idea where to go from here, any ideas? Thanks in advance.

Can you reproduce the problem in the SDL test programs?

Can you create a simple test case to show the problem?On Fri, Mar 11, 2011 at 11:19 AM, Mako_energy <mako_energy02 at yahoo.com>wrote:

We’ve just recently added code to our app to be able to change the window
size (in windowed mode) during run time, using the SDL_SetWindowSize()
function. This appears to work fine and our game loop continues until it
gets to our event manager. Our event manager polls all events in can by
calling SDL_PollEvent(&SDL_Event) in a while loop each frame. On the frame
immediately after calling SDL_SetWindowSize() it hangs on the first event it
polls, and has to be ended in task manager(I’m on windows, haven’t been able
to test other platforms yet). CPU usage is at 99% when it hangs.

I have no idea where to go from here, any ideas? Thanks in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and CEO, Galaxy Gameworks

Hanging with CPU at 99% actually makes debugging really easy. Reproduce the
problem, press Pause on the debugger while you’re hung, and examine the stack
trace. This should lead you right to the cause in short order.________________________________
From: mako_energy02@yahoo.com (Mako_energy)
To: sdl at lists.libsdl.org
Sent: Fri, March 11, 2011 11:19:15 AM
Subject: [SDL] SDL 1.3 - App hangs after resize

We’ve just recently added code to our app to be able to change the window size
(in windowed mode) during run time, using the SDL_SetWindowSize() function.
This appears to work fine and our game loop continues until it gets to our event
manager. Our event manager polls all events in can by calling
SDL_PollEvent(&SDL_Event) in a while loop each frame. On the frame immediately
after calling SDL_SetWindowSize() it hangs on the first event it polls, and has
to be ended in task manager(I’m on windows, haven’t been able to test other
platforms yet). CPU usage is at 99% when it hangs.

I have no idea where to go from here, any ideas? Thanks in advance.

Mason Wheeler wrote:

Hanging with CPU at 99% actually makes debugging really easy. Reproduce the problem, press Pause on the debugger while you’re hung, and examine the stack trace. This should lead you right to the cause in short order.

I haven’t yet tried to reproduce the issue in any of the test programs yet, but I did try this, and it seems to loop infinitely at lines 618-620 in SDL_windowsevents.c, in the while loop in WIN_PumpEvents().

I didn’t think it was relevant at the time, but now it does…Ogre also has a Message Pump function that I was calling and it hung there too, but I commented it out because I had only recently added it and was going to look at it later. But now it seems there is some common problem.

Are you doing processing with the size message in an event filter function?On Fri, Mar 11, 2011 at 12:48 PM, Mako_energy <mako_energy02 at yahoo.com>wrote:

Mason Wheeler wrote:

Hanging with CPU at 99% actually makes debugging really easy. Reproduce the
problem, press Pause on the debugger while you’re hung, and examine the
stack trace. This should lead you right to the cause in short order.

I haven’t yet tried to reproduce the issue in any of the test programs yet,
but I did try this, and it seems to loop infinitely at lines 618-620 in
SDL_windowsevents.c, in the while loop in WIN_PumpEvents().

I didn’t think it was relevant at the time, but now it does…Ogre also has
a Message Pump function that I was calling and it hung there too, but I
commented it out because I had only recently added it and was going to look
at it later. But now it seems there is some common problem.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and CEO, Galaxy Gameworks

Sam Lantinga wrote:

Are you doing processing with the size message in an event filter function?

No. We do have a filter function that looks for quit events, and filters them…but not for any other kind of event.

Some new info regarding this issue:
I still haven’t tried to reproduce this in one of the SDL tests, because it really seems to be something specific to my configuration, or something I am doing that I’m unaware of.

I have tried out a few different resolutions to change it to. My desktop resolution is 1024x768, I had it starting in an 800x600 window and trying to expand it to 1024x768 or 1280x1024. In both those cases it would hang. I have just recently tried smaller resolutions, starting at 640x480 and changing to 800x600(and vice versa) and it handles that just fine without any hiccups. Is there some limitation I am unaware of for having a window be the same size as the desktop resolution?

To answer my own question, it turns out there is a limitation in Windows that forbids a window being larger then the desktop display. When SDL was trying to force this it caused an error in the window message queue that kept PeekMessage() from being able to remove the message, thus causing an infinite loop.

My solution was a little bit hacky, but I simply added code that detected and prevented cases where the window would be larger then the desktop display. As a side note, window decorations must also be taken into account when making the window fit on the screen, which is why when I set the window to be 1024x768 while the desktop resolution was the same it didn’t work. Adding in the window decorations it would make the full area actually be 1032x798(+8x30), which was too large and caused the error.

Are you able to reproduce this with the test programs? I just created a
1900x1200 testsprite2 window and it worked fine.

Thanks!On Mon, Mar 14, 2011 at 10:54 AM, Mako_energy <mako_energy02 at yahoo.com>wrote:

To answer my own question, it turns out there is a limitation in Windows
that forbids a window being larger then the desktop display. When SDL was
trying to force this it caused an error in the window message queue that
kept PeekMessage() from being able to remove the message, thus causing an
infinite loop.

My solution was a little bit hacky, but I simply added code that detected
and prevented cases where the window would be larger then the desktop
display. As a side note, window decorations must also be taken into account
when making the window fit on the screen, which is why when I set the window
to be 1024x768 while the desktop resolution was the same it didn’t work.
Adding in the window decorations it would make the full area actually be
1032x798(+8x30), which was too large and caused the error.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and CEO, Galaxy Gameworks

Sam Lantinga wrote:

Are you able to reproduce this with the test programs?? I just created a 1900x1200 testsprite2 window and it worked fine.

I wasn’t able to compile all the tests, due to undefined reference errors, but I was able to build the “testbitmap” test, and I changed it’s resolution as defined on lines 104 and 105 to 1024x768. When I launched the test it crashed immediately. When I accounted for window decorations as stated above(the 8x30, thus making the resolution 1016x730), everything worked fine.

About the decorations being 8x30 – Windows uses AdjustWindowRect() to take
a desired window size and adjust it. That means creating an 800x600 window
on 800x600 actually can be 800x600 (borderless window) or 800x600 + MxN,
where MxN depend on the theme, version of windows, size of text in the
titlebar, etc.

Where exactly did the crash occur (file/line)?

Patrick Baggett wrote:

About the decorations being 8x30 – Windows uses AdjustWindowRect() to take a desired window size and adjust it. That means creating an 800x600 window on 800x600 actually can be 800x600 (borderless window) or 800x600 + MxN, where MxN depend on the theme, version of windows, size of text in the titlebar, etc.

Where exactly did the crash occur (file/line)?

I actually call the same function in my code to determine the size of the decorations. Kinda annoying that they just add them on, but still it was enough for me to do some basic math and determine the difference.

As for the crash, I have no idea…as I have no clue how to use gdb on the command line.

If you’ve got debugging symbols compiled in (-ggdb):

prompt> gdb

(gdb) r
… wait for crash …
(gdb) bt

is your executable file
prompt> your OS prompt
(gdb) is gdb’s prompt
r = run
bt = backtrace

This is usually enough for get me by. I haven’t delved into advanced GDB because
that’s all I’ve ever needed. HTH.________________________________
From: mako_energy02@yahoo.com (Mako_energy)
To: sdl at lists.libsdl.org
Sent: Thu, March 17, 2011 12:01:24 PM
Subject: Re: [SDL] [Solved]SDL 1.3 - App hangs after resize

Patrick Baggett wrote:

About the decorations being 8x30 – Windows uses AdjustWindowRect() to take a
desired window size and adjust it. That means creating an 800x600 window on
800x600 actually can be 800x600 (borderless window) or 800x600 + MxN, where MxN
depend on the theme, version of windows, size of text in the titlebar, etc.

Where exactly did the crash occur (file/line)?

I actually call the same function in my code to determine the size of the
decorations. Kinda annoying that they just add them on, but still it was enough
for me to do some basic math and determine the difference.

As for the crash, I have no idea…as I have no clue how to use gdb on the
command line.

goumba2k5-web wrote:

If you’ve got debugging symbols compiled in (-ggdb):

prompt> gdb

(gdb) r
… wait for crash …
(gdb) bt

is your executable file
prompt> your OS prompt
(gdb) is gdb’s prompt
r = run
bt = backtrace

This is usually enough for get me by. I haven’t delved into advanced GDB because that’s all I’ve ever needed. HTH.

Thanks, I managed to do this and get the backtrace. The crash seems to occur in a function named “BlitNtoN”, line 2098 of SDL_blit_N.c.

I would check what you’re trying to blit. The SDL function is likely crashing
because of bad data being passed to it.________________________________
From: mako_energy02@yahoo.com (Mako_energy)
To: sdl at lists.libsdl.org
Sent: Thu, March 17, 2011 1:48:42 PM
Subject: Re: [SDL] [Solved]SDL 1.3 - App hangs after resize

goumba2k5-web wrote:

If you’ve got debugging symbols compiled in (-ggdb):

prompt> gdb

(gdb) r
… wait for crash …
(gdb) bt

is your executable file
prompt> your OS prompt
(gdb) is gdb’s prompt
r = run
bt = backtrace

This is usually enough for get me by. I haven’t delved into advanced GDB because
that’s all I’ve ever needed. HTH.

Thanks, I managed to do this and get the backtrace. The crash seems to occur in
a function named “BlitNtoN”, line 2098 of SDL_blit_N.c.

goumba2k5-web wrote:

I would check what you’re trying to blit. The SDL function is likely crashing because of bad data being passed to it.

Thats the funny thing, the program I am getting the crash with is the TestBitMap test program. Only change I made was setting the resolution to 1024x768 instead of 640x480. Everything else is exactly the same, and setting it to any lower resolution makes it just work.

Ok, I noticed that Sam doesn’t have this issue. I don’t have an XP installation
to test on, but I have had no problems with windows being larger than desktop
resolution on any version I’ve used. It’s just useless as you can’t access those
portions.

Maybe this could be a video driver issue?

Maybe your driver somehow invalidates the data in the surface under the
conditions you describe. I don’t see any mention of you trying on other
hardware, but that might be worth a shot.________________________________
From: mako_energy02@yahoo.com (Mako_energy)
To: sdl at lists.libsdl.org
Sent: Thu, March 17, 2011 3:04:35 PM
Subject: Re: [SDL] [Solved]SDL 1.3 - App hangs after resize

goumba2k5-web wrote:

I would check what you’re trying to blit. The SDL function is likely crashing
because of bad data being passed to it.

Thats the funny thing, the program I am getting the crash with is the TestBitMap
test program. Only change I made was setting the resolution to 1024x768 instead
of 640x480. Everything else is exactly the same, and setting it to any lower
resolution makes it just work.

goumba2k5-web wrote:

Ok, I noticed that Sam doesn’t have this issue. I don’t have an XP installation to test on, but I have had no problems with windows being larger than desktop resolution on any version I’ve used. It’s just useless as you can’t access those portions.

Maybe this could be a video driver issue?

Maybe your driver somehow invalidates the data in the surface under the conditions you describe. I don’t see any mention of you trying on other hardware, but that might be worth a shot.

I do have a second machine I don’t develop on, but I got all my development stuff on it and tested. The second machine is Windows Vista SP1. Both machines have the latest nvidia drivers(a 6800 Ultra on the XP machine, and 9800GT on the Vista machine). Anyway, the results on the vista machine seem to be the same as yours and Sams. It worked fine at any resolution, but could only see a portion as expected at higher resolutions. I tested with my own app, not the test apps, doubt that matters in this case, but just in case.

Oh, I might have fixed this in the latest snapshot:
http://www.libsdl.org/tmp/SDL-1.3.zip

Cheers!On Thu, Mar 17, 2011 at 12:04 PM, Mako_energy <mako_energy02 at yahoo.com>wrote:

goumba2k5-web wrote:

I would check what you’re trying to blit. The SDL function is likely
crashing because of bad data being passed to it.

Thats the funny thing, the program I am getting the crash with is the
TestBitMap test program. Only change I made was setting the resolution to
1024x768 instead of 640x480. Everything else is exactly the same, and
setting it to any lower resolution makes it just work.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and CEO, Galaxy Gameworks