Hi all,
when I launch my macOS app from Xcode 16 on ARM64, appKit logs me this error on the debug console:
It's not legal to call -layoutSubtreeIfNeeded on a view which is already being laid out. If you are implementing the view's -layout method, you can call -[super layout] instead. Break on _NSDetectedLayoutRecursion(void) to debug. This will be logged only once. This may break in the future.
_NSDetectedLayoutRecursion doesn't help a lot, giving me these assembly codes from a call to a subclassed window method that looks like this:
-(void) setFrame:(NSRect)frameRect display:(BOOL)flag {
if (!_frameLocked) [super setFrame:frameRect display:flag];
}
I have no direct call to -layoutSubtreeIfNeeded from a
-layout implementation in my codes. I have a few calls to this method from update methods, however even if I comment all of them, the error is still logged...
Finally, apart from that log, I cannot observe any layout error when running the program. So I wonder if this error can be safely ignored?
Thanks!
I don’t have any good input on the original issue that kicked off this thread, but I wanted to address this:
if someone knows a good solution to disable all system logs while keeping my own
Xcode 15 introduced a new Console area with excellent integration with the system log. For example, consider this program:
import Foundation
import Network
import os.log
let log = Logger(subsystem: "", category: "")
func main() {
let c = NWConnection(host: "example.com", port: 80, using: .tls)
c.stateUpdateHandler = { newState in
log.log("did change state, state: \( "\(newState)" )")
}
c.start(queue: .main)
log.log("will enter main loop")
dispatchMain()
}
main()
IMPORTANT This is not meant to work. It tries to connect to the HTTP port using TLS, which won’t end well. The goal is to generate a bunch of log entries from Network framework, which it absolutely does (-:
When I run this (Xcode 26.4 on macOS 26.3.1) I see this:
will enter main loop
did change state, state: preparing
quic_protector_key_update unsupported TLS ciphersuite: 0
… lots of stuff …
nw_endpoint_flow_failed_with_error [C1.1.1 mask.icloud.com:443 cancelled intermediate-flow ((null))] already failing, returning
did change state, state: waiting(-9836: bad protocol version)
It’s hard to distinguish my log entries from all the stuff generated by Network framework. To focus on just my stuff, I pasted library:Test806471 into the filter box at the bottom of the Console area (where Test806471 is the name of my tool). After that I see just this:
will enter main loop
did change state, state: preparing
did change state, state: waiting(-9836: bad protocol version)
Nice!
For lots more hints and tips on how to use the system log effectively, see Your Friend the System Log.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"