开发者

XNA app not responding

I have a XNA 3.1 app on Windows 7 x64 with VS 2008. At ~7 seconds the window will go gray if the game does not have focus (sometimes!). The title adds Not Responding. If the game has focus, the window may slightly change position on the screen, and the application icon on my tray moves over as if it is opening a new program.

This only happens for a split second, and then the application icon moves back to its original position. It does this in both debug, and release mode. This is strange because the application is not stuck in any loop as far as I can tell. If I go into VS and pause the code while it is not responding it shows me the Instance.Run in the Program class like it should. I have tried pausing it at that exact moment;

The call stack looks like: [In a sleep, wait, or join]

External Code. ->

mscorlib.dll!System.Threading.Thread.Sleep(int millisecondsTimeout) + 0x5 bytes Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Tick() + 0x98 bytes

Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.HostIdle(object sender... Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.GameHost.OnIdle() + 0x3d bytes

... and so on.

If I hit run while paused, the program will work and unfreeze. The application will not unfreeze itself once it goes into this non-responsive mode. All sounds continue to work when it is not responding.

Additionally, I have a method that overrides the OnDeactivated() event and it gets called when the app loses responsiveness even though the application will HAVE focus. I have tried installing the latest drivers for my graphics card, but that failed to fix this problem. This issue also happens when running the executable without VS. Like I said, this issue happens ~ 75% of the time... otherwise it works fine.

I have found only one forum post regarding this issue: http://forums.开发者_StackOverflow中文版create.msdn.com/forums/p/56743/346180.aspx

It looks like it was never resolved.


Turns out I was checking Mediaplayer.State in an Update() method, and due to my profiler, I found the issue. MediaPlayer.State is an expensive enum to retrieve, and once I removed that block it no longer hangs.


this sounds like a fairly odd issue ... the only thing that jumps to mind is that maybe the app is not handling the loss of the device elegantly. I know that's rather vague, but perhaps it can be a hint. Check out all of the content loading routines (particularly if you're making any resources manually rather than through the content pipeline ... check out the DeviceLost event, etc.

some addition info: check out this blog post from the XNA team on how to properly handle resources and device lost/reset events: http://blogs.msdn.com/b/xna/archive/2006/09/18/761355.aspx

yet more info: the forum post where I got the link above has a nice quotable from Shawn Hargreaves which is why I think this might be related to what you're experiencing:

Device lost and device recreated are different things. Automatic pool resources will survive device lost, but need to be recreated any time the device is recreated.

Device lost happens in many places: when you change resolution, tab away from a fullscreen app, lock the terminal, etc.

Device recreated only happens in extreme circumstances, like dragging a window onto a different monitor (which as far as the driver is concerned might as well be a totally different graphics card so it has to start everything over from scratch).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜