{"record":{"id":"8945ea9e0b6c35e6","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-minsize-value","errorCode":null,"errorMessage":"Invalid minSize: {value}","messagePattern":"Invalid minSize: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/EditorWindow.cs","lineNumber":1162,"sourceCode":"\n        [VisibleToOtherModules(\"UnityEditor.UIBuilderModule\")]\n        internal void RepaintImmediately()\n        {\n            if (m_Parent && m_Parent.actualView == this)\n                m_Parent.RepaintImmediately();\n        }\n\n        // the minimum size of this window\n        public Vector2 minSize\n        {\n            get\n            {\n                return m_MinSize;\n            }\n            set\n            {\n                if (!View.IsValidViewSize(value))\n                    throw new ArgumentException($\"Invalid minSize: {value}\");\n\n                m_MinSize = value;\n                MakeParentsSettingsMatchMe();\n            }\n        }\n\n        // the maximum size of this window\n        public Vector2 maxSize\n        {\n            get\n            {\n                return m_MaxSize;\n            }\n            set\n            {\n                if (!View.IsValidViewSize(value))\n                    throw new ArgumentException($\"Invalid minSize: {value}\");\n","sourceCodeStart":1144,"sourceCodeEnd":1180,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/EditorWindow.cs#L1144-L1180","documentation":"The EditorWindow.minSize setter validates the supplied Vector2 through View.IsValidViewSize, which rejects any component that is NaN or Infinity. Normal finite values (including zero or negative) pass, so the throw is specifically about non-finite math, not about unrealistic window sizes.","triggerScenarios":"Assigning window.minSize from a computation that produced NaN (0/0) or Infinity (division by zero) — e.g. computing size from a float division without guarding the denominator, or deserialising corrupt layout data.","commonSituations":"Dynamically sizing a window based on screen DPI or content where a denominator can be zero. Layout deserialization after a layout-file corruption. Editor scripts that scale minSize by a factor sourced from an unset preferences value.","solutions":["Sanitise the Vector2 with float.IsFinite on both components before assigning.","Trace the upstream math producing the value and guard the division (check denominator != 0).","Reset the corrupted layout (delete Library/current.max-default layout) if the value comes from deserialisation."],"exampleFix":"// before\nwindow.minSize = new Vector2(width / dpi, height / dpi);\n// after\nVector2 SizeOr(float v, float f) => float.IsFinite(v) ? new Vector2(v, v) : new Vector2(f, f);\nwindow.minSize = float.IsFinite(dpi) ? new Vector2(width / dpi, height / dpi) : new Vector2(100, 100);","handlingStrategy":"validation","validationCode":"static Vector2 SafeMin(Vector2 v, Vector2 fallback) =>\n    float.IsFinite(v.x) && float.IsFinite(v.y) ? v : fallback;\nwindow.minSize = SafeMin(computed, new Vector2(100, 100));","typeGuard":"static bool IsValidViewSize(Vector2 v) => float.IsFinite(v.x) && float.IsFinite(v.y);","tryCatchPattern":null,"preventionTips":["Always sanitise DPI- or content-derived sizes with float.IsFinite.","Guard division denominators before computing sizes.","Discard corrupt layout files (Library/current.max-default) when sizes look like NaN."],"tags":["window-size","validation","nan","infinity","unity-editor"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}