| Ticket UUID: | 8cb99d1d665e0cd33802cb8a9fa284d0b2537857 | |||
| Title: | macOS: suppress NSCGS and makeKeyWindow warnings on toplevel map/unmap | |||
| Type: | Patch | Version: | trunk | |
| Submitter: | nab | Created on: | 2026-03-22 15:32:07 | |
| Subsystem: | (unused) | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Open | Last Modified: | 2026-03-27 07:39:15 | |
| Resolution: | None | Closed By: | nobody | |
| Closed on: | ||||
| Description: |
Hi Marc, attached a little patch (AI made) about annoying warnings on macOS... would you mind review it. Fix macOS warnings when mapping/unmapping toplevel windows On macOS, several NSWindow operations triggered warnings from the CoreGraphics Server and the window manager: - "[Window] Warning: -[NSWindow makeKeyWindow] called on <TKWindow> which returned NO from -[NSWindow canBecomeKeyWindow]" - "[NSCGS] Warning: Invalid attempt to open a new transaction during CA commit" Root causes and fixes: 1. XMapWindow: activateIgnoringOtherApps: was called for all windows including help/tooltip windows that cannot become key. macOS then attempted makeKeyWindow on them, triggering the warning. Fix: only activate the application for key-capable windows. 2. XUnmapWindow / TkWmDeadWindow: implicit CoreAnimation animations on orderOut/close opened new CGS transactions that conflicted with an in-progress CA commit. Fix: temporarily disable animations (NSWindowAnimationBehaviorNone) around orderOut, and permanently for windows being destroyed. 3. XUnmapWindow / TkMacOSXAssignNewKeyWindow: makeKeyAndOrderFront: on the next key window was unnecessary since orderedWindows already yields windows in front-to-back order. Replaced with makeKeyWindow to avoid redundant ordering and associated CGS transactions. 4. WmDeiconifyCmd / TkpWmSetState: orderFront: on non-key-capable windows was replaced with orderFrontRegardless, which explicitly does not attempt to change the key window. best regards, Nicolas | |||
| User Comments: |
nab added on 2026-03-27 07:39:15:
Hi Marc, same reulsts with latest trunk : 2026-03-27 08:38:05.573591+0100 DLight[53971:839610] [Window] Warning: -[NSWindow makeKeyWindow] called on <TKWindow: 0x61600028b980> windowNumber=2577 which returned NO from -[NSWindow canBecomeKeyWindow]. 2026-03-27 08:38:07.110496+0100 DLight[53971:839610] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-27 08:38:07.110627+0100 DLight[53971:839610] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-27 08:38:07.110660+0100 DLight[53971:839610] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-27 08:38:07.110756+0100 DLight[53971:839610] [NSCGS] Entangling fence requested after pre-commit 2026-03-27 08:38:07.111367+0100 DLight[53971:839610] [API] cannot add handler to 2 from 2 - dropping 2026-03-27 08:38:07.111430+0100 DLight[53971:839610] [NSCGS] Warning: Invalid attempt to open a new transaction during CA commit. This is likely to break AppKit transactional behavior. Break on NSCGSTransactionCreatedDuringCommitError to debug. ++ marc_culler (claiming to be Marc Culler) added on 2026-03-26 16:05:23: Annoying log messages in the terminal are de rigeur with Apple. Most macOS releases add a new one. Sometimes they go away on the next release. When code is run from the Terminal, Apple uses stderr as the log file, instead of the usual system log, and their logs can be quite verbose. The simplest way to avoid being annoyed is: % export TK_NO_STDERR=1 However, I have not seen the particular messages that you show here. Also, the latest commit to main changed [TKWindow canBecomeKeyWindow]. So it would be good to check if that changes anything. I do think we should avoid calling makeKeyWindow on a window which we know cannot become a key window, not just to avoid the warnings but because it is bad practice. I don't know what "entangle context after pre-commit" means. Maybe a simple tooltip example would produce these messages? nab added on 2026-03-26 14:37:51: Hi Marc, thank you to take care about this. I use the patch on my system (macOS 26 ARM) since 4 days and nothing wrong happened. I was fed up about message in the Terminal while working on my app. They was like that : 2026-03-22 14:53:55.008041+0100 DLight[32431:1003275] [Window] Warning: -[NSWindow makeKeyWindow] called on <TKWindow: 0x61600009a580> windowNumber=2f1f which returned NO from -[NSWindow canBecomeKeyWindow]. 2026-03-22 14:53:56.858096+0100 DLight[32431:1003275] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-22 14:53:56.858181+0100 DLight[32431:1003275] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-22 14:53:56.858200+0100 DLight[32431:1003275] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-22 14:53:56.858249+0100 DLight[32431:1003275] [NSCGS] Entangling fence requested after pre-commit 2026-03-22 14:53:56.858539+0100 DLight[32431:1003275] [API] cannot add handler to 2 from 2 - dropping 2026-03-22 14:53:56.858566+0100 DLight[32431:1003275] [NSCGS] Warning: Invalid attempt to open a new transaction during CA commit. This is likely to break AppKit transactional behavior. Break on NSCGSTransactionCreatedDuringCommitError to debug. 2026-03-22 14:53:56.951137+0100 DLight[32431:1003275] [Window] Warning: -[NSWindow makeKeyWindow] called on <TKWindow: 0x61600025a780> windowNumber=2f20 which returned NO from -[NSWindow canBecomeKeyWindow]. 2026-03-22 14:53:58.789114+0100 DLight[32431:1003275] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-22 14:53:58.789202+0100 DLight[32431:1003275] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-22 14:53:58.789225+0100 DLight[32431:1003275] [NSCGS] Ignoring request to entangle context after pre-commit 2026-03-22 14:53:58.789284+0100 DLight[32431:1003275] [NSCGS] Entangling fence requested after pre-commit 2026-03-22 14:53:58.789625+0100 DLight[32431:1003275] [API] cannot add handler to 2 from 2 - dropping 2026-03-22 14:53:58.789659+0100 DLight[32431:1003275] [NSCGS] Warning: Invalid attempt to open a new transaction during CA commit. This is likely to break AppKit transactional behavior. Break on NSCGSTransactionCreatedDuringCommitError to debug. each time I put the mouse over a widget that had a toolTip registered (I'm using code from Alex : https://github.com/aplsimple/baltip) now with the patch, Terminal is clean and in release mode everything works as expected. I've also checked on macOS 12 (Intel) in release mode and it's all good. we had a discussion about that in September 2025. best regards, nicolas marc_culler (claiming to be Marc Culler) added on 2026-03-26 13:37:53: Nicolas, can you provide some details about these messages - your system configuration and a way to generate them? marc_culler (claiming to be Marc Culler) added on 2026-03-26 13:27:33: Hi Nicolas, Are you sure that will not cause a new Wish window to get mapped behind windows belonging to a different app? Much of the code being changed is there to make sure that doesn't happen. | |||
Attachments:
- fix-tooltip-warnings.patch [download] added by nab on 2026-03-22 15:32:36. [details]
