{"record":{"id":"0872702cda2ad04f","repo":"stride3d/stride","slug":"character","errorCode":null,"errorMessage":"character","messagePattern":"character","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Font/FontCacheManager.cs","lineNumber":67,"sourceCode":"        /// Remove all the currently cached characters from the cache.\n        /// </summary>\n        public void ClearCache()\n        {\n            foreach (var character in cachedCharacters)\n                character.IsBitmapUploaded = false;\n            cachedCharacters.Clear();\n\n            packer.Clear(cacheTextures[0].ViewWidth, cacheTextures[0].ViewHeight);\n        }\n        \n        /// <summary>\n        /// Upload a character's bitmap into the current cache.\n        /// </summary>\n        /// <param name=\"character\">The character specifications corresponding to the bitmap</param>\n        public void UploadCharacterBitmap(CommandList commandList, CharacterSpecification character)\n        {\n            if (character.Bitmap == null)\n                throw new ArgumentNullException(\"character\");\n\n            if (character.IsBitmapUploaded)\n                throw new InvalidOperationException($\"The character '{character.Character}' upload has been requested while its current glyph is valid.\");\n\n            var targetSize = new Int2(character.Bitmap.Width, character.Bitmap.Rows);\n            if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))\n            {\n                // not enough space to place the new character -> remove less used characters and try again\n                RemoveLessUsedCharacters();\n                if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))\n                {\n                    // memory is too fragmented in order to place the new character -> clear all the characters and restart.\n                    // TODO: This is invalid, we might delete character from current frame!\n                    ClearCache();\n                    if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))\n                        throw new InvalidOperationException(\"The rendered character is too big for the cache texture\");\n                }\n            }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Font/FontCacheManager.cs#L49-L85","documentation":"FontCacheManager.UploadCharacterBitmap uploads a glyph into the font atlas. The error text is 'character' (thrown as ArgumentNullException for the character argument): the API requires a CharacterSpecification with a rendered Bitmap; a null bitmap means there is nothing to upload, so it throws immediately.","triggerScenarios":"Calling UploadCharacterBitmap with a CharacterSpecification whose Bitmap property is null — e.g. the glyph was never rendered or character lookup failed earlier.","commonSituations":"Requesting a glyph for a character the font does not contain (missing glyph) and then pushing it to the cache; font failed to render the glyph (e.g. unsupported codepoint) upstream.","solutions":["Check character.Bitmap for null before calling UploadCharacterBitmap and skip/handle missing glyphs","Ensure the glyph was rendered successfully before queuing the upload","Verify the font actually contains the requested character before adding it to the cache queue"],"exampleFix":"// before\ncacheManager.UploadCharacterBitmap(commandList, character);\n// after\nif (character?.Bitmap != null)\n    cacheManager.UploadCharacterBitmap(commandList, character);","handlingStrategy":"validation","validationCode":"if (character == null) throw new ArgumentNullException(nameof(character));\nif (character.Bitmap == null) return false; // nothing rendered; skip upload","typeGuard":"bool CanUpload(CharacterSpecification c) => c?.Bitmap != null;","tryCatchPattern":"try { cache.UploadCharacterBitmap(commandList, character); }\ncatch (ArgumentNullException)\n{\n    log.Warning($\"Glyph for '{character?.Character}' not rendered; skipping upload.\");\n}","preventionTips":["Verify the glyph rendered successfully before queueing an upload","Check the font contains the requested character before caching it","Wrap upload calls with a null-bitmap guard"],"tags":["fonts","null-argument","atlas"],"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"}