After a lot more experimentation, I've determined that it is nothing to do with something running after windowDidLoad. The problem occurs when I calculate the size of the window content. Here's a version of the code:
NSScrollView *scrollView = self.myScrollView;
MyContentView *myContentView = [scrollView documentView];
NSSize contentSize = [[self.window contentView] bounds].size;
NSSize viewSize = [scrollView contentSize];
CGFloat verticalPadding = contentSize.height - viewSize.height;
CGFloat horizontalPadding = contentSize.width - viewSize.width;
NSSize myContentSize = [myContentView bounds].size;
myContentSize = [NSScrollView frameSizeForContentSize:myContentSize
horizontalScrollerClass:[NSScroller class]
verticalScrollerClass:[NSScroller class]
borderType:NSLineBorder
controlSize:NSControlSizeRegular
scrollerStyle:NSScrollerStyleOverlay];
myContentSize.height += 1;
myContentSize.width += 1;
NSSize maximumSize = myContentSize;
maximumSize.height += verticalPadding;
maximumSize.width += horizontalPadding;
The problem is that viewSize, the size of the visible portion of the scroll view, can have one of two different values, which differ by 24. It seems to be arbitrary which of the two values is provided. Thus the maximum size, which is then set as the window content size with setContentSize, varies by 24, dependent on nothing that I can see.