ppy/osu-framework

`GameHost.ChooseAndSetupRenderer()` silences exceptions from `CreateWindow()`

Susko3 opened this issue · 0 comments

Susko3 commented

Root cause of ppy/osu#24260 (very likely).

The most notable exception in CreateWindow() is SDL_Init failing. This can be forced with:

diff --git a/osu.Framework/Platform/SDL2Window.cs b/osu.Framework/Platform/SDL2Window.cs
index 8ae1d7215..3cfc63f69 100644
--- a/osu.Framework/Platform/SDL2Window.cs
+++ b/osu.Framework/Platform/SDL2Window.cs
@@ -186,7 +186,7 @@ protected SDL2Window(GraphicsSurfaceType surfaceType)
         {
             ObjectHandle = new ObjectHandle<SDL2Window>(this, GCHandleType.Normal);
 
-            if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_GAMECONTROLLER) < 0)
+            if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_GAMECONTROLLER) < int.MaxValue)
             {
                 throw new InvalidOperationException($"Failed to initialise SDL: {SDL.SDL_GetError()}");
             }
2023-09-26 09:05:44 [verbose]: 🖼️ Configuration renderer choice: Automatic
2023-09-26 09:05:44 [verbose]: 🖼️ Renderer fallback order: [ Direct3D 11, OpenGL (Legacy), OpenGL, Vulkan ]
2023-09-26 09:05:44 [verbose]: 🖼️ Initialising "Veldrid" renderer with "Direct3D11" surface
2023-09-26 09:05:44 [verbose]: 🖼️ Initialising "WindowsGL" renderer with "OpenGL" surface
2023-09-26 09:05:44 [verbose]: 🖼️ Initialising "Veldrid" renderer with "OpenGL" surface
2023-09-26 09:05:44 [verbose]: 🖼️ Initialising "Veldrid" renderer with "Vulkan" surface
2023-09-26 09:05:44 [error]: No usable renderer was found!
2023-09-26 09:05:44 [error]: An unhandled error has occurred.
2023-09-26 09:05:44 [error]: System.NullReferenceException: Object reference not set to an instance of an object.
2023-09-26 09:05:44 [error]: at osu.Framework.Input.Handlers.Tablet.OpenTabletDriverHandler.Initialize(GameHost host) in C:\...\osu-framework\osu.Framework\Input\Handlers\Tablet\OpenTabletDriverHandler.cs:line 53
2023-09-26 09:05:44 [error]: at osu.Framework.Platform.GameHost.initialiseInputHandlers() in C:\...\osu-framework\osu.Framework\Platform\GameHost.cs:line 1098
2023-09-26 09:05:44 [error]: at osu.Framework.Platform.GameHost.Run(Game game) in C:\...\osu-framework\osu.Framework\Platform\GameHost.cs:line 727
2023-09-26 09:05:44 [error]: at osu.Framework.Tests.Program.Main(String[] args) in C:\...\osu-framework\osu.Framework.Tests\Program.cs:line 23

This fails with the tabled driver trying to dereference host.Window. And the InvalidOperationException from SDL_Init failing is nowhere to be seen.