Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

MonoGameGLException when closing game through Game.Exit(). #92

Closed
xanather opened this issue Jun 7, 2013 · 12 comments
Closed

MonoGameGLException when closing game through Game.Exit(). #92

xanather opened this issue Jun 7, 2013 · 12 comments

Comments

@xanather
Copy link

xanather commented Jun 7, 2013

All I am doing is the usual loading of textures through ContentManager, no Texture2D.FromFile etc.

Microsoft.Xna.Framework.Graphics.MonoGameGLException was unhandled
HResult=-2146233088
Message=GL.GetError() returned InvalidOperation
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Graphics.GraphicsExtensions.CheckGLError() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Graphics\GraphicsExtensions.cs:line 725
at Microsoft.Xna.Framework.Graphics.Texture.b__6() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Graphics\Texture.cs:line 183
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.AddDisposeAction(Action disposeAction) in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Graphics\GraphicsDevice.cs:line 1372
at Microsoft.Xna.Framework.Graphics.Texture.Dispose(Boolean disposing) in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Graphics\Texture.cs:line 180
at Microsoft.Xna.Framework.Graphics.GraphicsResource.Dispose() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Graphics\GraphicsResource.cs:line 125
at Microsoft.Xna.Framework.Content.ContentManager.Unload() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Content\ContentManager.cs:line 645
at Microsoft.Xna.Framework.Content.ContentManager.Dispose(Boolean disposing) in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Content\ContentManager.cs:line 183
at Microsoft.Xna.Framework.Content.ContentManager.Dispose() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Content\ContentManager.cs:line 169
at Microsoft.Xna.Framework.Game.Dispose(Boolean disposing) in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 210
at Microsoft.Xna.Framework.Game.Dispose() in c:\Users\Xanather\Documents\Programming\Libs\MonoGame\MonoGame.Framework\Game.cs:line 190
at hidden.Program.Main() in c:\Users\Xanather\Documents\Programming\Main\hidden\hidden\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

@flibitijibibo
Copy link
Owner

Wait, Game.Exit() or Game.Dispose()? That's what I see in the trace...

Either way, can you add a Console.WriteLine here for me?

https://github.com/flibitijibibo/MonoGame/blob/monogame-sdl2/MonoGame.Framework/SDL2/SDL2_GameWindow.cs#L391

I'm pretty sure some GL stuff is being called after the GL context has been removed.

Does this work on XNA4? Or the old WindowsGL project?

@xanather
Copy link
Author

xanather commented Jun 7, 2013

Yep, I am receiving a WriteLine (Edit: I am also using Game.Exit() ).

@flibitijibibo
Copy link
Owner

Right, will try to push the SDL2 Window/GLContext back a bit. One moment!

@xanather
Copy link
Author

xanather commented Jun 7, 2013

End users probably didn't report a problem because they didn't notice one. The program still closes (without a dialog box) and eventually stops execution.

@flibitijibibo
Copy link
Owner

Well, the current system actually works fine on the 7 or so titles I have running on it, so odds are your title's explicitly making a call that it's not happy with.

Also, seems I may not be able to push it back far enough to affect anything. Just at first glance, though.

@xanather
Copy link
Author

xanather commented Jun 7, 2013

Discovery actually, when referencing Release versions of (SDL) MonoGame.Framework.dll no exception is thrown, while debug throws.

@flibitijibibo
Copy link
Owner

Hm, not sure. Not to mention, this seems to be a generic MonoGameGLException. I'm disposing the window as late as I can (the only later time I could possibly do it is on SDL2_GamePlatform.Dispose(), which isn't guaranteed to work), so I'm wondering if there's some general GL silliness that needs to be addressed.

@flibitijibibo
Copy link
Owner

Actually, found a way to resolve this, nevermind~

Committing once I confirm this with all my games, may take a sec.

@xanather
Copy link
Author

xanather commented Jun 7, 2013

Ok, so I traced it all the way through. The exception is not actually thrown on Game.Exit(), I followed it all the way out to the initial creation of the game and then .net tried to clean it up.

@flibitijibibo
Copy link
Owner

e6f9ddf

As long as you explicitly call Game.Dispose() (or use using (Game...)) MG-SDL2 should work with UnloadContent.

@xanather
Copy link
Author

xanather commented Jun 7, 2013

And.... it works now, amazing 💃 , other than TextInput I'm now ready to develop with MonoGameSDL, thanks for all the help 👍 flibitijibibo!

@flibitijibibo
Copy link
Owner

No problem! You've found some pretty shockingly bad flaws in MG-SDL2, glad we could help each other out. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants