src/macos/api-wrappers/PersistedWindowFrameSpecs.md
NSWindow.isValidPersistedFrame(_:) (defined in HelperExtensionsTestable.swift) decides whether a
window-frame string that AppKit persisted in UserDefaults (key "NSWindow Frame <name>") is safe to
restore. AppKit's setFrameAutosaveName / setFrameUsingName immediately apply that string, and an
out-of-range or non-finite frame makes the apply throw NSInternalInconsistencyException and abort the
app (crash f481d5b0, FeedbackWindow). setFrameAutosaveNameSafely calls this predicate and drops a
corrupt value before AppKit ever sees it.
The persisted string is space-separated numbers: the window frame x y w h, optionally followed by the
save-time screen frame x y w h (so 4 or 8 tokens), with a trailing space. AppKit's own validity rule is
CGRectContainsRect(CGRectMake(INT_MIN, INT_MIN, INT_MAX-INT_MIN, INT_MAX-INT_MIN), frame) — i.e. every
edge must stay within Int32 bounds and be finite. This predicate mirrors that rule exactly.
Double(Substring) (period decimal, never comma); "nan"/"inf" parse to
non-finite values and are rejected by the isFinite check.Int32 bounds (Int32.min ... Int32.max) — this is the
exact range AppKit's CGRectContainsRect enforces; values outside it are what abort the app.x + w / y + h must not overflow Int32.max (a frame
whose origin is in range but whose far edge isn't is still rejected).compactMap), so an all-garbage string yields zero
tokens → invalid.Mirrors PersistedWindowFrameTests.swift 1:1.
"834 503 380 450 0 0 2048 1121 ") is accepted, trailing space and all.x y w h (no screen tokens) is accepted.Int32.max is accepted.nan token is rejected.inf token is rejected.Int32.max is rejected.x + w past Int32.max is rejected.w/h is rejected.