Added some GPU info to the crash reports, all available debug console messages are included in the reports (not just the 15 latest ones), restart attempts caused by SharpDXExceptions are logged

This commit is contained in:
Joonas Rikkonen
2017-07-31 20:43:08 +03:00
parent d5e2b202d1
commit 1bc2523269
2 changed files with 40 additions and 10 deletions
@@ -142,11 +142,14 @@ namespace Barotrauma
GraphicsHeight = Config.GraphicsHeight; GraphicsHeight = Config.GraphicsHeight;
GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled; GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
//for whatever reason, window isn't centered automatically if (Config.WindowMode == WindowMode.Windowed)
//since MonoGame 3.6 (nuget package might be broken), so {
//let's do it manually //for whatever reason, window isn't centered automatically
Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - GraphicsWidth) / 2, //since MonoGame 3.6 (nuget package might be broken), so
(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - GraphicsHeight) / 2); //let's do it manually
Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - GraphicsWidth) / 2,
(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - GraphicsHeight) / 2);
}
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed; GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
+32 -5
View File
@@ -66,6 +66,8 @@ namespace Barotrauma
if (e is SharpDX.SharpDXException) if (e is SharpDX.SharpDXException)
{ {
DebugConsole.NewMessage("SharpDX exception caught. (" + e.Message + "). Attempting to fix...", Microsoft.Xna.Framework.Color.Red);
switch ((uint)((SharpDX.SharpDXException)e).ResultCode.Code) switch ((uint)((SharpDX.SharpDXException)e).ResultCode.Code)
{ {
case 0x887A0022: //DXGI_ERROR_NOT_CURRENTLY_AVAILABLE case 0x887A0022: //DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
@@ -73,10 +75,12 @@ namespace Barotrauma
{ {
case 0: case 0:
//just wait and try again //just wait and try again
DebugConsole.NewMessage("Retrying after 100 ms...", Microsoft.Xna.Framework.Color.Red);
System.Threading.Thread.Sleep(100); System.Threading.Thread.Sleep(100);
return true; return true;
case 1: case 1:
//force focus to this window //force focus to this window
DebugConsole.NewMessage("Forcing focus to the window and retrying...", Microsoft.Xna.Framework.Color.Red);
var myForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(game.Window.Handle); var myForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(game.Window.Handle);
myForm.Focus(); myForm.Focus();
return true; return true;
@@ -94,10 +98,13 @@ namespace Barotrauma
} }
case 0x80070057: //E_INVALIDARG/Invalid Arguments case 0x80070057: //E_INVALIDARG/Invalid Arguments
DebugConsole.NewMessage("Invalid graphics settings, attempting to fix", Microsoft.Xna.Framework.Color.Red); DebugConsole.NewMessage("Invalid graphics settings, attempting to fix...", Microsoft.Xna.Framework.Color.Red);
GameMain.Config.GraphicsWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; GameMain.Config.GraphicsWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
GameMain.Config.GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; GameMain.Config.GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
DebugConsole.NewMessage("Display size set to " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight, Microsoft.Xna.Framework.Color.Red);
game.ApplyGraphicsSettings(); game.ApplyGraphicsSettings();
return true; return true;
@@ -149,17 +156,37 @@ namespace Barotrauma
sb.AppendLine("\n"); sb.AppendLine("\n");
sb.AppendLine("System info:"); sb.AppendLine("System info:");
sb.AppendLine(" Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86")); sb.AppendLine(" Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));
if (game.GraphicsDevice == null)
{
sb.AppendLine(" Graphics device not set");
}
else
{
if (game.GraphicsDevice.Adapter == null)
{
sb.AppendLine(" Graphics adapter not set");
}
else
{
sb.AppendLine(" GPU name: " + game.GraphicsDevice.Adapter.Description);
sb.AppendLine(" Display mode: " + game.GraphicsDevice.Adapter.CurrentDisplayMode);
}
sb.AppendLine(" GPU status: " + game.GraphicsDevice.GraphicsDeviceStatus);
}
sb.AppendLine("\n"); sb.AppendLine("\n");
sb.AppendLine("Exception: "+exception.Message); sb.AppendLine("Exception: " + exception.Message);
sb.AppendLine("Target site: " +exception.TargetSite.ToString()); sb.AppendLine("Target site: " + exception.TargetSite.ToString());
sb.AppendLine("Stack trace: "); sb.AppendLine("Stack trace: ");
sb.AppendLine(exception.StackTrace); sb.AppendLine(exception.StackTrace);
sb.AppendLine("\n"); sb.AppendLine("\n");
sb.AppendLine("Last debug messages:"); sb.AppendLine("Last debug messages:");
for (int i = DebugConsole.Messages.Count - 1; i > 0 && i > DebugConsole.Messages.Count - 15; i-- ) for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
{ {
sb.AppendLine(" "+DebugConsole.Messages[i].Time+" - "+DebugConsole.Messages[i].Text); sb.AppendLine(" " + DebugConsole.Messages[i].Time + " - " + DebugConsole.Messages[i].Text);
} }