Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (12 posts)

[4.0] Windows game sometimes crashes in the framework on exit

Last post 3/10/2011 12:23 AM by Wixin. 11 replies.
  • 9/6/2010 1:17 AM

    [4.0] Windows game sometimes crashes in the framework on exit

    My Windows game sometimes crashes with the following exception while exiting:

    System.AccessViolationException was unhandled
      Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      Source=Microsoft.Xna.Framework
      StackTrace:
           at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.IsEventRegistered(EventType type)
           at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.UnregisterEvent(EventType type)
           at Microsoft.Xna.Framework.Audio.KernelMicrophone.ShutdownCaptureEngine()
           at Microsoft.Xna.Framework.Audio.MicrophoneUnsafeNativeMethods.ShutdownCaptureEngine()
           at Microsoft.Xna.Framework.Audio.AudioRendererShutdownHandler.AppExitingEventHandler(Object sender, EventArgs args)
      InnerException:


    It doesn't happen at any other time, just while exiting.  I thought maybe it was happening if a sound effect was playing during the exit (e.g. my "menu click" sound when tapping Exit), but it also happens when no sound is playing.  Also, it only happens when running in Windows, not the phone emulator.

    Any thoughts as to what might be the cause?
  • 9/6/2010 1:24 AM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    I created a Windows copy of the SoundAndMusicSampleGame sample and see the same behavior.
  • 11/16/2010 7:51 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    I'm getting the same thing.  Any ideas?
  • 11/16/2010 7:55 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    Hmm... this appears to have fixed it for me.  Maybe it does have something to do with playing a sound while selecting the Exit Game link.

            void exitMenuEntry_Selected(object sender, EventArgs e)
            {
                System.Threading.Thread.Sleep(1000);
                ScreenManager.Game.Exit();
            }
  • 11/17/2010 3:22 AM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    Sounds like a garbage collector issue to me, but maybe not. Is there some sort of manager/sounds you can try destroying before exit?
  • 11/18/2010 12:27 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    LattaSoft:

    Sounds like a garbage collector issue to me, but maybe not. Is there some sort of manager/sounds you can try destroying before exit?



    I've tried quite a few things, up to and including disposing everything related to sound, and still haven't found a solution.

  • 11/23/2010 7:56 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    I've go the same problem. I've stopped and disposed of all Sounds and SoundInstances, and I've added a system sleep call for 5000ms.
    I continue to get the following error:

    System.AccessViolationException was unhandled
      Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      Source=Microsoft.Xna.Framework
      StackTrace:
           at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.IsEventRegistered(EventType type)
           at Microsoft.Xna.Framework.Audio.AudioCallbackDispatcher.UnregisterEvent(EventType type)
           at Microsoft.Xna.Framework.Audio.KernelMicrophone.ShutdownCaptureEngine()
           at Microsoft.Xna.Framework.Audio.MicrophoneUnsafeNativeMethods.ShutdownCaptureEngine()
           at Microsoft.Xna.Framework.Audio.AudioRendererShutdownHandler.AppExitingEventHandler(Object sender, EventArgs args)
      InnerException: 

    The references to audio leads me to believe that this is a sound issue but I have no idea how to begin to debug this.

    Help?

    Thanks,

    A
  • 11/23/2010 8:13 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    I used to get a similar problem related to the GC; it ends up that I was Unloading one of my content managers before it's parent class was fully initialized. Basically, it occurred during tests in which I would exit my game in my menu system, before loading any maps. I fixed it by ensuring that my Unload would only unload the map's content manager if it had already been fully initialized.
  • 11/23/2010 8:43 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    Daniel Hoctor:
    I used to get a similar problem related to the GC; it ends up that I was Unloading one of my content managers before it's parent class was fully initialized. Basically, it occurred during tests in which I would exit my game in my menu system, before loading any maps. I fixed it by ensuring that my Unload would only unload the map's content manager if it had already been fully initialized.

    Thanks for the idea, unfortunately this has not worked. I've now disposed of everything I can on game exit but after everything is initialized and I still get the above error. Oh well.

    There's an editor that needs to get done so I'll come back to this later. Hopefully this won't be an issue on the Xbox ...

    Thank you

    A

  • 11/23/2010 9:08 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    Thanks for reporting this. I'll open a bug on our end to investigate.
  • 11/26/2010 7:43 PM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    Something else to try...

    In my game, I removed the GamerServicesComponent from my Windows build (that is, I wrapped it in an "#if XBOX" directive).  This appears to have cleared up the issue for me.

    Hope that helps.
  • 3/10/2011 12:23 AM In reply to

    Re: [4.0] Windows game sometimes crashes in the framework on exit

    Adam Spragg Games:
    Something else to try...

    In my game, I removed the GamerServicesComponent from my Windows build (that is, I wrapped it in an "#if XBOX" directive).  This appears to have cleared up the issue for me.

    Hope that helps.
    Could you be a little more specific on how exactly you did this? I'm getting this same bug, having disposed of everything and slept for several seconds. It's so strange that there's no help anywhere for a problem as glaring as this.
Page 1 of 1 (12 posts) Previous Discussion Next Discussion