{"record":{"id":"211a3740f5cb146c","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-minimum-size-min","errorCode":null,"errorMessage":"Invalid minimum size: {min}","messagePattern":"Invalid minimum size: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/ContainerWindow.cs","lineNumber":269,"sourceCode":"\n            if (rootView)\n            {\n                float scale = GetBackingScale();\n                rootView.position = new Rect(0, 0, GUIUtility.RoundToPixelGrid(m_PixelRect.width, scale), GUIUtility.RoundToPixelGrid(m_PixelRect.height, scale));\n            }\n        }\n\n        public void OnEnable()\n        {\n            if (m_RootView)\n                m_RootView.Initialize(this);\n            SetBackgroundColor(skinBackgroundColor);\n        }\n\n        public void SetMinMaxSizes(Vector2 min, Vector2 max)\n        {\n            if (!View.IsValidViewSize(min))\n                throw new ArgumentException($\"Invalid minimum size: {min}\");\n\n            if (!View.IsValidViewSize(max))\n                throw new ArgumentException($\"Invalid maximum size: {max}\");\n\n            m_MinSize = min;\n            m_MaxSize = max;\n            Rect r = position;\n            Rect r2 = r;\n            r2.width = Mathf.Clamp(r.width, min.x, max.x);\n            r2.height = Mathf.Clamp(r.height, min.y, max.y);\n            if (r2.width != r.width || r2.height != r.height)\n                position = r2;\n            Internal_SetMinMaxSizes(min, max);\n        }\n\n        static internal bool CanCloseAll(bool includeMainWindow)\n        {\n            using (var pooledObject = ListPool<EditorWindow>.Get(out List<EditorWindow> unsaved))","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/ContainerWindow.cs#L251-L287","documentation":"Thrown by ContainerWindow.SetMinMaxSizes when the 'min' Vector2 fails View.IsValidViewSize. IsValidViewSize rejects any component that is NaN or Infinity (positive or negative). It does NOT enforce positivity or ordering — a zero or negative-but-finite size passes. The check exists because the native windowing layer cannot clamp or apply a non-finite size, so passing garbage (e.g. an uninitialized Vector2 or a size derived from float.NaN math) would corrupt the window rect.","triggerScenarios":"Calling ContainerWindow.SetMinMaxSizes(min, max) (directly or via a HostView/EditorWindow minSize setter that flows through) where min.x or min.y is float.NaN or float.PositiveInfinity / float.NegativeInfinity. Commonly reached when min is computed from a division by zero, an unset serialized field, or a RectTransform whose layout has not resolved yet.","commonSituations":"EditorWindow with minSize computed from layout math that yields NaN (e.g. width / count where count == 0); deserialized window state from a corrupted layout file; custom docking/container code that reads position before the host view is initialized.","solutions":["Sanitize the size with a guard: if (!View.IsValidViewSize(min)) min = Vector2.one * 100; before calling SetMinMaxSizes.","Trace where the NaN/Infinity originates — search for division, Mathf.InverseLerp with equal args, or uninitialized serialized Vector2 fields in the window's data.","If the value comes from a layout pass, defer SetMinMaxSizes until GUILayout/layout has resolved (e.g. in a delayed EditorApplication.delayCall)."],"exampleFix":"// before\nwindow.SetMinMaxSizes(new Vector2(totalWidth / columnCount, 100), maxSize);\n// after\nfloat safeW = columnCount > 0 ? totalWidth / columnCount : 100f;\nvar min = new Vector2(float.IsNaN(safeW) ? 100f : safeW, 100f);\nwindow.SetMinMaxSizes(min, maxSize);","handlingStrategy":"validation","validationCode":"static bool IsValidSize(Vector2 s) =>\n    !float.IsNaN(s.x) && !float.IsNaN(s.y) && !float.IsInfinity(s.x) && !float.IsInfinity(s.y);\n// call before SetMinMaxSizes\nif (!IsValidSize(min)) min = Vector2.one * 100;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never derive a window size from division without a zero-guard.","Treat any Vector2 read from an unresolved layout as potentially NaN until layout completes.","Wrap SetMinMaxSizes in a helper that clamps NaN/Infinity to a sane default."],"tags":["editor","window","ui","validation","nan","size"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}