"GL invalid operation" when app goes to backgroud second time

I have an exception:
(Monogame 3.2)

System.Diagnostics.Debugger.Mono_UnhandledException_internal () in 
System.Diagnostics.Debugger.Mono_UnhandledException (ex={Microsoft.Xna.Framework.Graphics.MonoGameGLException: GL.GetError() returned InvalidOperation
at Microsoft.Xna.Framework.Graphics.GraphicsExtensions.CheckGLError () [0x0000f] in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\GraphicsExtensions.cs:743
at Microsoft.Xna.Framework.Graphics.Shader.GraphicsDeviceResetting () [0x0002e] in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\Shader\Shader.cs:298
at Microsoft.Xna.Framework.Graphics.GraphicsResource.DoGraphicsDeviceResetting () [0x000d2] in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\GraphicsResource.cs:110
at Microsoft.Xna.Framework.Graphics.GraphicsDevice.OnDeviceResetting () [0x00020] in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\GraphicsDevice.cs:1550
at Microsoft.Xna.Framework.AndroidGameWindow.DestroyFrameBuffer () [0x00029] in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Android\AndroidGameWindow.cs:247
at OpenTK.Platform.Android.AndroidGameView.UnloadInternal (System.EventArgs) <IL 0x00009, 0x0008b>
at OpenTK.Platform.Android.AndroidGameView.SurfaceDestroyed (Android.Views.ISurfaceHolder) <IL 0x0000d, 0x0007b>
at Microsoft.Xna.Framework.AndroidGameWindow.Android.Views.ISurfaceHolderCallback.SurfaceDestroyed (Android.Views.ISurfaceHolder) [0x00001] in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Android\AndroidGameWindow.cs:541
at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceDestroyed_Landroid_view_SurfaceHolder_ (intptr,intptr,intptr) <IL 0x00013, 0x000f3>
at (wrapper dynamic-method) object.e2270088-b9e3-4cc5-ac3e-9c76b94dafa2 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
}) in 
object.e2270088-b9e3-4cc5-ac3e-9c76b94dafa2 (arg0=0xb336e0, arg1=0xffffffffeb400019, arg2=0xfffffffffb50001d) in 
Microsoft.Xna.Framework.Graphics.GraphicsExtensions.CheckGLError () in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\GraphicsExtensions.cs:743
Microsoft.Xna.Framework.Graphics.Shader.GraphicsDeviceResetting () in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\Shader\Shader.cs:298
Microsoft.Xna.Framework.Graphics.GraphicsResource.DoGraphicsDeviceResetting () in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\GraphicsResource.cs:110
Microsoft.Xna.Framework.Graphics.GraphicsDevice.OnDeviceResetting () in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Graphics\GraphicsDevice.cs:1550
Microsoft.Xna.Framework.AndroidGameWindow.DestroyFrameBuffer () in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Android\AndroidGameWindow.cs:247
OpenTK.Platform.Android.AndroidGameView.UnloadInternal (e={System.EventArgs}) in 
OpenTK.Platform.Android.AndroidGameView.SurfaceDestroyed (holder=) in 
Microsoft.Xna.Framework.AndroidGameWindow.Android.Views.ISurfaceHolderCallback.SurfaceDestroyed (Parameters=) in e:\Projects\Work\mobile-shell\thirdparty\MonoGame-3.2\MonoGame.Framework\Android\AndroidGameWindow.cs:541
Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceDestroyed_Landroid_view_SurfaceHolder_ (Parameters=) in 
object.e2270088-b9e3-4cc5-ac3e-9c76b94dafa2 (Parameters=) in 

It reproduces like this:

  1. open a game
  2. tap Home button at device
  3. return to the game
  4. tap Home button again
  5. there is an exception

Any ideas or hints how to fix this?

Thanks

Are you using the latest code from the develop branch? https://github.com/mono/MonoGame

I know they’ve been fixing a lot of stuff for Android regarding app resume.

No, I use stable version 3.2. With latest version I have the same exception and one more very similar