{"record":{"id":"3f29195486bc85d1","repo":"stride3d/stride","slug":"cannot-allocate-sdl-window","errorCode":null,"errorMessage":"Cannot allocate SDL Window: ","messagePattern":"Cannot allocate SDL Window: ","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"sources/engine/Stride.Graphics/SDL/Window.cs","lineNumber":102,"sourceCode":"#endif\n\n            // If there is a parent hwnd\n            if (parent != IntPtr.Zero)\n            {\n                void* parentPtr = parent.ToPointer();\n\n                sdlHandle = SDL.CreateWindowFrom(parentPtr);\n            }\n            else // no parent window\n            {\n                // Create the SDL window and then extract the native handle.\n                sdlHandle = SDL.CreateWindow(title, Sdl.WindowposUndefined, Sdl.WindowposUndefined, 640, 480, (uint)flags);\n            }\n            \n\n            if (sdlHandle == null)\n            {\n                throw new Exception(\"Cannot allocate SDL Window: \" + SDL.GetErrorS()); \n            }\n\n            SysWMInfo info = default;\n            SDL.GetVersion(&info.Version);\n            if (!SDL.GetWindowWMInfo(sdlHandle, &info))\n            {\n                throw new Exception(\"Cannot get Window information: \" + SDL.GetErrorS());\n            }\n\n            if (Core.Platform.Type == Core.PlatformType.Windows)\n            {\n                Handle = info.Info.Win.Hwnd;\n            }\n            else if (Core.Platform.Type == Core.PlatformType.Linux)\n            {\n                Handle = (IntPtr)info.Info.X11.Window;\n                Display = (IntPtr)info.Info.X11.Display;\n            }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/SDL/Window.cs#L84-L120","documentation":"In the SDL Window constructor, if SDL.CreateWindow returns a null handle, the window could not be allocated and the constructor throws a generic Exception including SDL.GetErrorS() which carries the underlying SDL error text (e.g. no video driver, display unavailable).","triggerScenarios":"Constructing a Stride.SDL Window when SDL_CreateWindow fails: missing display, no usable video driver (e.g. headless environment without dummy driver), or invalid window flags.","commonSituations":"Running on a headless CI server with no DISPLAY/WAYLAND_DISPLAY set, SDL video subsystem initialization failure, or missing graphics drivers in containers.","solutions":["Read the appended SDL.GetErrorS() text for the root cause","Ensure a display/video driver is available: set DISPLAY (X11), or SDL_VIDEODRIVER=dummy/offscreen for headless runs","Install/repair graphics drivers and SDL runtime dependencies","Verify SDL was initialized before window creation"],"exampleFix":"// before (CI without display)\ndotnet run --project Game\n// after\nSDL_VIDEODRIVER=dummy dotnet run --project Game","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(\"DISPLAY\")) && Environment.OSVersion.Platform != PlatformID.Win32NT) throw new InvalidOperationException(\"No display available for SDL window\");","typeGuard":null,"tryCatchPattern":"try { var win = new Window(...); } catch (Exception ex) when (ex.Message.StartsWith(\"Cannot allocate SDL Window\")) { log.Error(ex.Message); }","preventionTips":["Ensure SDL video driver availability before window creation","Set SDL_VIDEODRIVER=dummy for headless/CI environments","Install required native SDL dependencies"],"tags":["sdl","window","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}