Debug an issue with NSWindow becoming narrow

For months now we're trying to find an issue with one of our apps, were a window suddenly becomes narrow and can't be resized horizontally any more. It's a bug that only happens sporadically and we can't provide a "focused test project" to demonstrate the issue; thus we can't ask for code-level support at this moment.

To debug this issue, we've overwritten a private method on NSWindow that gets the constrained window min and max sizes (valuable hint of Kristin from the AppKit team in a WWDC 2025 one-on-one session where I was able to show it to her in my debugger). When the bug hits, the maxSize's width (usually 10000) becomes smaller than the minSize's width.

One way (but not the only one) to trigger this issue is to move the window from one display to another and back. Sometimes the bug triggers after a few back-and-forth movements, sometimes it takes minutes to trigger or I give up… but for other people the bug happens seemingly out of nowhere (of course there must be a trigger but we haven't noticed common patterns yet).

It looks like an AutoLayout issue since a suspicious thing happens when the bug triggers: calling constraintsAffectingLayoutForOrientation:NSLayoutConstraintOrientationHorizontal on the NSThemeFrame usually returns just two constraints. But when the bug triggers, it returns a whole bunch of constraints, related to all kind of views of our app. Asking the NSThemeFrame for its direct constraints still shows the same two constraints are present and active (NSWindow-current-width and NSWindow-x-anchor).

How to proceed in hunting down this issue when we're unable to produce a demo project? We can only reproduce the bug with our big product, and only sporadically: sometimes I can trigger it in a minute, sometimes it takes me 15 minutes or even more.

Issue happens on macOS 15 (currently running 15.5).

Debug an issue with NSWindow becoming narrow
 
 
Q