AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 290 forks source link

Crashing when WindowMode is set to Fullscreen #723

Closed heraldofgargos closed 4 years ago

heraldofgargos commented 5 years ago

Summary

The application crashes when trying to run a game with the WindowMode property set to Fullscreen in DualityUserData.

How to reproduce

  1. Create a new Duality app
  2. Change the WindowMode property to Fullscreen in DualityUserData
  3. Run the app

Workaround

Changing from Fullscreen to FullWindow (borderless, I'd presume?) fixes it.

Attachments

Logfile

[Core] ERR:   GraphicsModeException: Device Primary: {X=0,Y=0,Width=1920,Height=1080} (122 modes available): Failed to change resolution to {X=0,Y=0,Width=1920,Height=1080}x32@25Hz.
              CallStack:
                 at OpenTK.DisplayDevice.ChangeResolution(DisplayResolution resolution) in D:\svn\Projects\AdamsLair.OpenTK\Source\OpenTK\DisplayDevice.cs:line 244
                 at OpenTK.NativeWindow..ctor(Int32 x, Int32 y, Int32 width, Int32 height, String title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device) in D:\svn\Projects\AdamsLair.OpenTK\Source\OpenTK\NativeWindow.cs:line 121
                 at OpenTK.NativeWindow..ctor(Int32 width, Int32 height, String title, GameWindowFlags options, GraphicsMode mode, DisplayDevice device) in D:\svn\Projects\AdamsLair.OpenTK\Source\OpenTK\NativeWindow.cs:line 83
                 at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title, GameWindowFlags options, DisplayDevice device, Int32 major, Int32 minor, GraphicsContextFlags flags, IGraphicsContext sharedContext) in D:\svn\Projects\AdamsLair.OpenTK\Source\OpenTK\GameWindow.cs:line 210
                 at Duality.Backend.DefaultOpenTK.NativeWindow.InternalWindow..ctor(NativeWindow parent, Int32 w, Int32 h, GraphicsMode mode, String title, GameWindowFlags flags) in C:\projects\duality\Source\Platform\DefaultOpenTK\Backend\Graphics\NativeWindow.cs:line 30
                 at Duality.Backend.DefaultOpenTK.NativeWindow..ctor(GraphicsMode mode, WindowOptions options) in C:\projects\duality\Source\Platform\DefaultOpenTK\Backend\Graphics\NativeWindow.cs:line 106
                 at Duality.Backend.DefaultOpenTK.GraphicsBackend.Duality.Backend.IGraphicsBackend.CreateWindow(WindowOptions options) in C:\projects\duality\Source\Platform\DefaultOpenTK\Backend\Graphics\GraphicsBackend.cs:line 317
                 at Duality.DualityApp.OpenWindow(WindowOptions options) in C:\projects\duality\Source\Core\Duality\DualityApp.cs:line 406
                 at Duality.Launcher.Program.Main(String[] args) in C:\projects\duality\Source\Launcher\Program.cs:line 61
ilexp commented 5 years ago

Thanks for reporting this issue. Looks like a bug to me, although potentially from the "not handling valid error cases" realm. I'm flagging this as a good match for new contributors, since this can probably be solved by a reasonable try-catch and fallback code at the right spot within the callstack:

  1. Catch exceptions thrown by an attempt to create a window and log them as an error.
  2. Attempt to recover by changing the window mode to something more compatible, then retry. My first guess for a fallback chain would be: Fullscreen --> FullWindow --> Window

@alexfonseka One thing that strikes me as quite odd is the graphics mode that was selected on your system: Failed to change resolution to {X=0,Y=0,Width=1920,Height=1080}x32@25Hz. Why would there be a 25Hz mode, and why would that be selected as the default graphics mode? Can you do a debug step through QueryGraphicsModes and post a list of the gathered / available modes?

heraldofgargos commented 5 years ago

Here's the list of available graphics mode.

◢ | AvailableGraphicsModes | Count = 6 | System.Collections.Generic.IEnumerable<OpenTK.Graphics.GraphicsMode> {System.Collections.Generic.HashSet<OpenTK.Graphics.GraphicsMode>}
  | ▶ [0] | {Index: , Color: 32 (8888), Depth: 24, Stencil: 0, Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False} | OpenTK.Graphics.GraphicsMode
  | ▶ [1] | {Index: , Color: 32 (8888), Depth: 24, Stencil: 0, Samples: 2, Accum: 0 (0000), Buffers: 2, Stereo: False} | OpenTK.Graphics.GraphicsMode
  | ▶ [2] | {Index: , Color: 32 (8888), Depth: 24, Stencil: 0, Samples: 4, Accum: 0 (0000), Buffers: 2, Stereo: False} | OpenTK.Graphics.GraphicsMode
  | ▶ [3] | {Index: , Color: 32 (8888), Depth: 24, Stencil: 0, Samples: 6, Accum: 0 (0000), Buffers: 2, Stereo: False} | OpenTK.Graphics.GraphicsMode
  | ▶ [4] | {Index: , Color: 32 (8888), Depth: 24, Stencil: 0, Samples: 8, Accum: 0 (0000), Buffers: 2, Stereo: False} | OpenTK.Graphics.GraphicsMode
  | ▶ [5] | {Index: , Color: 32 (8888), Depth: 24, Stencil: 0, Samples: 16, Accum: 0 (0000), Buffers: 2, Stereo: False} | OpenTK.Graphics.GraphicsMode

Not sure how to interpret most of these fields though.

ilexp commented 5 years ago

Hm, nothing out of the ordinary there. Can you upload and link a full Logfile.txt?

heraldofgargos commented 5 years ago

https://pastebin.com/Ancd3FmG

It seems the issue is local to my PC. It's not present on my laptop ¯_(ツ)_/¯

Barsonax commented 4 years ago

@alexfonseka so this bug only happened on your PC? Did you manage to figure out how to reproduce it on a different system?

heraldofgargos commented 4 years ago

Hey @Barsonax, I wasn't able to reproduce it again. I suspect it's probably a GPU driver related issue.

Closing, since it's not relevant to the project anymore...