{"record":{"id":"8fbdcba690ec072f","repo":"stride3d/stride","slug":"graphicsdevice","errorCode":null,"errorMessage":"graphicsDevice","messagePattern":"graphicsDevice","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Font/FontSystem.cs","lineNumber":58,"sourceCode":"        /// </remarks>\n        public RuntimeFontProvider RuntimeFonts { get; private set; }\n\n        /// <summary>\n        /// Create a new instance of <see cref=\"FontSystem\" /> base on the provided <see cref=\"Stride.Graphics.GraphicsDevice\" />.\n        /// </summary>\n        public FontSystem()\n        {\n        }\n\n        /// <summary>\n        /// Load this system.\n        /// </summary>\n        /// <param name=\"graphicsDevice\">The graphics device.</param>\n        /// <exception cref=\"System.ArgumentNullException\">graphicsDevice</exception>\n        public void Load(GraphicsDevice graphicsDevice, IDatabaseFileProviderService fileProviderService)\n        {\n            // TODO possibly load cached character bitmaps from the disk\n            if (graphicsDevice == null) throw new ArgumentNullException(\"graphicsDevice\");\n            GraphicsDevice = graphicsDevice;\n            FontManager = new FontManager(fileProviderService);\n            FontCacheManager = new FontCacheManager(this);\n            RuntimeFonts = new RuntimeFontProvider(this);\n        }\n\n        /// <summary>\n        /// Loads a runtime-registered font by name.\n        /// This bypasses the content pipeline entirely.\n        /// </summary>\n        /// <param name=\"fontName\">The registered font name. If the font is not registered, the method returns <c>null</c>.</param>\n        /// <param name=\"defaultSize\">The default font size in pixels.</param>\n        /// <param name=\"style\">The font style.</param>\n        /// <returns>A <see cref=\"SpriteFont\"/> instance if the font is registered; otherwise, <c>null</c>.</returns>\n        public SpriteFont? LoadRuntimeFont(string fontName, float defaultSize = 16f, FontStyle style = FontStyle.Regular)\n        {\n            if (!RuntimeFonts.IsRegistered(fontName, style))\n                return null;","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Font/FontSystem.cs#L40-L76","documentation":"FontSystem.Load requires a GraphicsDevice to create GPU-backed font resources and throws ArgumentNullException when it is null. It also needs a file provider service to construct the FontManager, so a null device means the font system cannot be initialized at all.","triggerScenarios":"Calling fontSystem.Load(null, fileProviderService) before the game's GraphicsDevice is created, or in a headless/tooling context where no device exists.","commonSituations":"Initializing font services in a script constructor that runs before Game.GraphicsDevice is assigned; unit tests exercising font code without a device; ordering mistakes where fonts load before engine init.","solutions":["Create/initialize the GraphicsDevice before calling FontSystem.Load and pass the real instance","Defer font system initialization to a point after the game's device is ready (e.g. after SceneSystem setup)","In tests, mock or skip FontSystem.Load since fonts require a device"],"exampleFix":"// before\nfontSystem.Load(game.GraphicsDevice, services); // GraphicsDevice not yet created\n// after\nvar device = game.GraphicsDevice ?? throw new InvalidOperationException(\"Graphics not initialized yet\");\nfontSystem.Load(device, services);","handlingStrategy":"type-guard","validationCode":"if (graphicsDevice is null || graphicsDevice.IsDisposed)\n    throw new InvalidOperationException(\"Valid GraphicsDevice required before FontSystem.Load\");","typeGuard":"bool DeviceReady(GraphicsDevice d) => d is not null && !d.IsDisposed;","tryCatchPattern":"try { fontSystem.Load(device, fileProvider); }\ncatch (ArgumentNullException)\n{\n    log.Error(\"FontSystem.Load called before GraphicsDevice was created\");\n}","preventionTips":["Initialize font systems only after engine/graphics initialization completes","Enforce init ordering in a single bootstrap method","In tests, avoid FontSystem.Load or provide a mock device"],"tags":["null-argument","fonts","graphics"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}