{"record":{"id":"1de17511c31d2817","repo":"AvaloniaUI/Avalonia","slug":"defaultflatness-must-be-greater-than-1-0e-10","errorCode":null,"errorMessage":"defaultFlatness must be greater than 1.0e-10","messagePattern":"defaultFlatness must be greater than 1\\.0e-10","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/PreciseEllipticArcHelper.cs","lineNumber":436,"sourceCode":"            public void SetMaxDegree(int maxDegree)\n            {\n                if (maxDegree < 1 || maxDegree > 3)\n                {\n                    throw new ArgumentException(@\"maxDegree must be between 1 and 3\", nameof(maxDegree));\n                }\n                _maxDegree = maxDegree;\n            }\n\n            /// <summary>\n            /// Sets the default flatness for Bezier curve approximation\n            /// </summary>\n            /// <param name=\"defaultFlatness\">default flatness (must be greater than 1e-10)</param>\n            /// <exception cref=\"ArgumentException\">Thrown if defaultFlatness is lower than 1e-10</exception>\n            public void SetDefaultFlatness(double defaultFlatness)\n            {\n                if (defaultFlatness < 1.0E-10)\n                {\n                    throw new ArgumentException(@\"defaultFlatness must be greater than 1.0e-10\", nameof(defaultFlatness));\n                }\n                _defaultFlatness = defaultFlatness;\n            }\n\n            /// <summary>\n            /// Computes the locations of the focii\n            /// </summary>\n            private void ComputeFocii()\n            {\n                double d = Math.Sqrt(A * A - B * B);\n                double dx = d * _cosTheta;\n                double dy = d * _sinTheta;\n                FirstFocusX = Cx - dx;\n                FirstFocusY = Cy - dy;\n                SecondFocusX = Cx + dx;\n                SecondFocusY = Cy + dy;\n            }\n","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/PreciseEllipticArcHelper.cs#L418-L454","documentation":"Thrown by SetDefaultFlatness when the requested flatness (the acceptable approximation error tolerance) is below 1.0e-10. The error-estimation math relies on flatness being a positive, non-degenerate magnitude; an extremely small value would demand unbounded subdivision and destabilize the rational-function error bounds.","triggerScenarios":"arc.SetDefaultFlatness(0) or arc.SetDefaultFlatness(1e-12) — any value strictly less than 1e-10, including zero and negatives.","commonSituations":"Exposing flatness as a user/config value without a floor; passing a 'max precision' sentinel of 0 expecting 'as precise as possible'; unit confusion (passing pixels-vs-device units).","solutions":["Use a flatness at or above 1e-10 (typical rendering values are ~0.25 to 1.0 in device units).","Floor the input: var f = Math.Max(userFlatness, 1e-10); arc.SetDefaultFlatness(f);","If 'maximum precision' is requested, pick a small-but-valid tolerance like 1e-9 rather than 0."],"exampleFix":"// before\narc.SetDefaultFlatness(0); // intended 'max precision'\n\n// after\narc.SetDefaultFlatness(1e-9); // small but valid tolerance","handlingStrategy":"validation","validationCode":"var f = Math.Max(defaultFlatness, 1e-10);\narc.SetDefaultFlatness(f);","typeGuard":"static bool IsValidFlatness(double f) => f >= 1.0e-10;","tryCatchPattern":null,"preventionTips":["Floor flatness at 1e-10; use realistic tolerances (~0.25-1.0 device units) for rendering.","Never pass 0 as a 'max precision' sentinel."],"tags":["avalonia","arc","bezier","argument","configuration","flatness"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}