{"record":{"id":"6b8d626bb2796358","repo":"stride3d/stride","slug":"levelcocvalues-and-leveldownscalefactors-must-be-arrays-of","errorCode":null,"errorMessage":"levelCoCValues and levelDownscaleFactors must be arrays of the same size!","messagePattern":"levelCoCValues and levelDownscaleFactors must be arrays of the same size!","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs","lineNumber":290,"sourceCode":"        }\n\n        /// <summary>\n        /// Caches the current configuration and re-generates the filter effect of each LOD level to avoid \n        /// generating garbage a each frame.\n        /// </summary>\n        public void SetupTechnique()\n        {\n            // Sanity checks\n            if (levelCoCValues == null && levelDownscaleFactors != null)\n            {\n                throw new ArgumentOutOfRangeException(\"You cannot provide downscale factors without CoC values first.\");\n            }\n\n            if (levelCoCValues != null && levelDownscaleFactors != null)\n            {\n                if (levelCoCValues.Length != levelDownscaleFactors.Length)\n                {\n                    throw new ArgumentOutOfRangeException(\"levelCoCValues and levelDownscaleFactors must be arrays of the same size!\");\n                }\n            }\n\n            if (levelCoCValues != null && levelCoCValues.Length == 0)\n            {\n                if (levelCoCValues.Length == 0)\n                {\n                    throw new ArgumentOutOfRangeException(\"DoF configuration needs at least one blur level!\");\n                }\n                if (levelCoCValues[levelCoCValues.Length - 1] != 1f)\n                {\n                    throw new ArgumentOutOfRangeException(\"Last blurriest level must have a CoC of 1.0!\");\n                }\n            }\n\n            // Default values: 1 original image and 1 blur level\n            int levelCount = 2;\n            if (levelCoCValues != null)","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/DepthOfField/DepthOfField.cs#L272-L308","documentation":"DepthOfField.SetupTechnique requires that levelCoCValues and levelDownscaleFactors have identical lengths, since each blur level pairs a CoC value with a downscale factor. Mismatched array sizes throw ArgumentOutOfRangeException.","triggerScenarios":"Setting levelCoCValues and levelDownscaleFactors to arrays of different lengths, then calling SetupTechnique or rendering (DrawCore).","commonSituations":"Adding a blur level to one array but not the other during tuning; loading mismatched arrays from config; off-by-one when building arrays programmatically.","solutions":["Make both arrays the same length with matching indices","Regenerate both arrays together from a single level definition","Clear one array if you only intend to customize the other (single-array mode is allowed)"],"exampleFix":"// before\ndof.LevelCoCValues = new[] { 0.5f, 0.75f, 1.0f };\ndof.LevelDownscaleFactors = new[] { 1, 2 };\n// after\ndof.LevelCoCValues = new[] { 0.5f, 0.75f, 1.0f };\ndof.LevelDownscaleFactors = new[] { 1, 2, 4 };","handlingStrategy":"validation","validationCode":"if (coc != null && dsf != null && coc.Length != dsf.Length) throw new ArgumentException(\"CoC and downscale arrays must match in length\");","typeGuard":"bool LevelsMatch(float[] coc, int[] dsf) => coc == null || dsf == null || coc.Length == dsf.Length;","tryCatchPattern":"try { dof.SetupTechnique(); } catch (ArgumentOutOfRangeException) { /* log array length mismatch and fall back to defaults */ dof.LevelCoCValues = null; dof.LevelDownscaleFactors = null; dof.SetupTechnique(); }","preventionTips":["Generate both arrays in one place so lengths can't diverge","Add a debug assertion comparing lengths after mutation","Validate arrays loaded from config before assignment"],"tags":["csharp","argumentoutofrange","depthoffield","rendering"],"backgroundTag":"schema-validation-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"}