Weird crashes using LoadingScreen.Load() in my Windows 8 game using Monogame

Hi everyone!

I have my game up and running on Windows 8 using Monogame 3.0, but I realized that my game crashes during the transitioning of screens. I am using the original XNA GameStateManagementSample with the screenManager, GameScreen, and LoadingScreen Classes.

I thought perhaps the ExitScreen() method was causing the problem, but now I think the problem may be with the LoadingScreen class, because when I use ScreenManager.AddScreen, it doesn’t crash. Has anyone else encountered such problems porting their games to Windows 8 using Monogame?

Also, sometimes I get a loud, weird, distorted sound when a new screen transitions on. I load and unload content with each new gameScreen. I have had no issues using my GameStateManagment classes on Windows phone or Windows desktop apps.

Thanks in advance!

Our UI system used in ARMED! on Windows 8 was based on the GameStateManagementSample as well. When we encountered problems like this it was because of some code that we modified or added.

You need to run your game in the debugger and look at the line of code where it crashes. That will tell you exactly what the problem is.

I assume you are playing a sound on the transition? You should identify what sound effect is causing this, so we can discuss it specifically.

Hi Tom!

Thanks for all you hard work on MonoGame and your quickreply to my issue!

Well, let me see…I’m using Visual Studio 2013 Pro, and it gives me a warning in a message box saying 'a debugger is attached, but not configured to debug this unhandled exception. its an unhandled Win32 exception in the exe., and it’s unable to attach to the unhandled exception. That’s why I can’t really trace it. Funny thing is, sometimes it will muscle it’s way through and load the next screen. Plus, the first screen that I ran into the problem with, I stopped using the ExitScreen() method because I saw that the Load method exited all existing screens, so I figured that was the issue, because that first problem screen doesn’t crash anymore!? I thought the issue was fixed, but I ran into the problem again on some other new screens that I added!

As far as the distorted sounds…yes, I am trying to play a sound effect during the LoadContent() method. Does that cause the distorted sound in MonoGame?

Oh yeah, have you used the original XNA particle sample in MonoGame? I had to strip it out because of some weird Vector2 and BlendState issues, and no definition for X in the ParticleSettings errors.

Thanks,
Tyrone

You can trace it… just go to the Debug->Exceptions menu and from there you can force it to stop on all exceptions.

Even just a callstack is useful to see what is triggering it.

MonoGame has no flaw that we know of that causes distorted sounds.

I would start by checking your sound effect. Does it still happen if you replace that sound with another sound?

You’ll have to be more specific than that to get help.

Hi Tom!

Okay, my bad, there is a list of things that went wrong. For starters, it say WinRt information: The operation attempted to access data outside the valid range. It goes on to list that it was trying to find or open SharpDX.Xinput.DLL, SharpDX.XAudio2.DLL, SharpDX.MediaFoundation.DLL…but it could not. Also, there were a few 'Failed to load symbols.

The weird sounds when a new screen transitions on still occurs even when I don’t load or use any sounds. The only thing that is going on, is the mediaPlayer is still playing the original game music during transitions.

As far as the issue with the original XNA Particle Sample not working for me, there were reference issues with the ParticleSettings.dll…

Error 2 Cannot implicitly convert type ‘Microsoft.Xna.Framework.Graphics.Blend’ to ‘Microsoft.Xna.Framework.Graphics.Blend [c:\Program Files (x86)\MonoGame\v3.0\Assemblies\Windows8\MonoGame.Framework.dll]’ C:\Users\Mr.DCE_President\documents\visual studio 2013\Projects\SinisterPop\SinisterPop\Utilities\ParticleSystem.cs 134 36 SinisterPop

Error 6 The type ‘Microsoft.Xna.Framework.Vector2’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553’. C:\Users\Mr.DCE_President\documents\visual studio 2013\Projects\SinisterPop\SinisterPop\Utilities\ParticleSystem.cs 250 21 SinisterPop

just to list a few…but basically, I just wanted to know if anyone has tried to use the particle sample from xna, and if they too, ran into any issues. The only thing I can think of, was that on Windows phone I had to reference ParticleSettings.dll in both projects(Game project and Content Projects). To get that working, I even tried to do the empty monogame content project so I could reference the dll the same way as my original windows phone project, but the same errors occurred. I scrapped that approach in favor of just adding the xnb files. I could revisit that approach now, because I realize many issues came from not having the Content folder and paths correct. Anyway, getting a little too long-winded here, so thanks, and I hope any of this makes sense to you!

UPDATE!

The problem is my content is not unloading, causing a memory crash. Amazing that this issue was brought up a year ago on GitHub (Content does not unload #848) and closed, but I’m still having the same issue on Windows 8. I think they proposed a fix for Android, but was there ever a fix for Windows 8?

There was a fix for this merged…

https://github.com/mono/MonoGame/pull/849

You need to figure out what reference is keeping the content from unloading. You need to run a memory profiler over your game and see what is not released.

Thanks Tom!

I was just guessing, but you’re absolutely right. I tried ANTS Memory Profiler, but it said that Window Store apps can’t be profiled! I have yet to find a good one currently. My debugging skills outside of my own code is lacking right now, but I’m crossing things off and will hopefully figure this issue out soon!

I forgot about how when I started out with XNA that it took some time to get my development environment stable.

Thinking back to your initial suggestion about something changing in the GameStateManagent classes, I did strip out the serialization methods from the ScreenManager class, because at the time I didn’t feel like making the switch from isolatedStorage to Windows.Storage, but I never used those methods on Windows 7/Phone anyway. Plus, nothing is calling for serialization for that to be the issue.

anyways,
Thanks!