This project is read-only.

XNA GameStateManagement Crash

Feb 1, 2012 at 6:50 AM

We are using the GameStateManagement example for different screens of our game. However sometimes, going between screens, the application crashes and gives errors like "System.ExecutionEngineException" or "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." 

we think it is some problem with markers or game or alvar tracker ... not being disposed properly. We tried disposing, unloading but no success. Has anyone used different screens in their game and came across with these random crashes?

Coordinator
Feb 1, 2012 at 6:30 PM

Did you set the multithread option for marker tracking (State.ThreadOption)? If so, disable it. We had experience with weird crashes from v4.0 as well for some other cases when we enable the multithread option for marker tracking. It may solve your problem as well.

Ohan

Feb 5, 2012 at 7:46 AM
Edited Feb 5, 2012 at 12:10 PM

thanks for that. ok this is promising. but still getting errors not the same places though.

i got one AccessViolationException at

 XNAModel xnaModel = State.Content.Load<XNAModel>(@"" + filePath);

----------------------

An unhandled exception of type 'System.StackOverflowException' occurred in Unknown Module.

no place where it happened.

---------------------

Specified framerate or/and resolution is/are not supported for HP Webcam Splitter. 

this one is really strange. in the first game, camera works fine. then i exit to main menu. and go to another screen that has another game. there it gives me this error. 

edit: I think i solved this problem by disposing the IVideoCapture captureDevice. hasn't happened since.

Feb 5, 2012 at 11:49 AM
Edited Feb 5, 2012 at 12:12 PM

ok so i figured out this.

i have 3 different goblin games basically in this menu system. if i go between these and dont show the markers to the camera, it never crashes. but if the camera sees a marker in one game, and if i exit to main menu and enter to another game, then the game crashes and gives this error. 

An unhandled exception of type 'System.ExecutionEngineException' occurred in GoblinXNA.dll

i think the other errors are somewhat related to this problem.

any thought on this?

Coordinator
Feb 6, 2012 at 9:58 PM

What do you mean by "3 different goblin games"? Do you mean you have 3 GoblinXNA.SceneGraph.Scene instances?

In that case, I've never tried running more than one Scene instance, so I do not know the outcome.

Ohan

Feb 6, 2012 at 11:50 PM

yes i have 3 different scenes in 3 three different source files. I go between them through the menu. Should I do perhaps, all of this in one scene? Define one scene in a super class and use that in these 3 different games?

Coordinator
Feb 10, 2012 at 11:29 PM

I just remembered that I have used 3 different Scene instances in 3 different XNA Game classes organized through WPF, and I never had any problems. However, that was in XNA 3.1 version using Arcane library to integrate XNA with WPF. There is no easy way to manage XNA 4.0 contents with the latest WPF, so I'm not sure what's the best solution is.

Ohan

Feb 11, 2012 at 12:23 AM

we are actually using XNA 3.1 as well.

and this example for different screens http://create.msdn.com/en-US/education/catalog/sample/game_state_management, 3.1 version.

we couldn't get it to work, and have been working on it over a month.

so decided to separate games, and get rid of the menu.

but if you have any other suggestions, i would like to hear. we still have the crashing version. if it simply changing couple of lines, where we messed up, that would be awesome.

the way we set it up right now is, each screen contains a Goblin scene. and every time you go into a screen you create a new Goblin scene.

the problem comes down to i think with AlvarMarkerTracker.cs. As I said before, if the camera doesnt see a marker, we can switch back and forth between screens with no crash. But after this switching back and forth is done like 3 or 4 times, and the camera sees a marker, the program crashes. I think the AlvarMarkerTracker is not freeing a source that it is using.  

Coordinator
Feb 13, 2012 at 9:18 PM

In that case, it's more of what's going on in the ALVARWrapper code in C++. There might be a memory leak that I'm not aware of, but if you find where it happens, I would appreciate it. Also, there is no plan for us to update 3.x versions since we moved most of our projects to 4.x version.

Ohan