问题
My app starts and the window shows (all controls are physically there) in an inactive-like state (controls grayed out and inactive to keys/mouse). It takes three to five seconds for the window to become active? Same pattern occurs when I switch back to this app from another.
EDIT
I have added logging in various Window, Delegate & Controller methods to determine where precisely the slowdown is occurring and all of these run before the slowdown:
1. 2015-02-08 15:22:16.032 Grid[40199:5354843] ScrollGridViewContainer.awakeFromNib start
2. 2015-02-08 15:22:17.244 Grid[40199:5354843] ScrollGridViewContainer.awakeFromNib end
3. 2015-02-08 15:22:17.247 Grid[40199:5354843] contentViewController.viewDidLoad started
4. 2015-02-08 15:22:17.247 Grid[40199:5354843] contentViewController.viewDidLoad ended
5. 2015-02-08 15:22:17.262 Grid[40199:5354843] WindowController.windowDidLoad start
6. 2015-02-08 15:22:17.263 Grid[40199:5354843] WindowController.windowDidLoad end
7. 2015-02-08 15:22:17.303 Grid[40199:5354843] Window.makeKeyAndOrderFront start
8. 2015-02-08 15:22:17.316 Grid[40199:5354843] windowDidUpdate
9. 2015-02-08 15:22:17.975 Grid[40199:5354843] Window.makeFirstResponder start
10. 2015-02-08 15:22:17.975 Grid[40199:5354843] GridCell: 1, 1 .becomeFirstResponder
11. 2015-02-08 15:22:17.975 Grid[40199:5354843] self.nextResponder
12. 2015-02-08 15:22:17.976 Grid[40199:5354843] firstResponder is: 1, 1
13. 2015-02-08 15:22:17.976 Grid[40199:5354843] Window.makeFirstResponder end
14. 2015-02-08 15:22:20.692 Grid[40199:5354843] Window.makeKeyAndOrderFront end
15. 2015-02-08 15:22:20.742 Grid[40199:5354843] windowDidUpdate
16. 2015-02-08 15:22:20.772 Grid[40199:5354843] applicationDidFinishLaunching
17. 2015-02-08 15:22:20.773 Grid[40199:5354843] windowDidUpdate
18. 2015-02-08 15:22:21.216 Grid[40199:5354843] windowDidBecomeMain
19. 2015-02-08 15:22:21.238 Grid[40199:5354843] windowDidBecomeKey
20. 2015-02-08 15:22:21.322 Grid[40199:5354843] windowDidUpdate
21. 2015-02-08 15:22:25.117 Grid[40199:5354843] windowDidUpdate
On log item 14 it shows the window in an inactive state. (This is as it is exiting the Window.makeKeyAndOrderFront method after calling super)
It is only at log item 21 above that the window of my app actually became active (I moved the mouse over the window at that point to trigger a "windowDidUpdate").
My next problem to solve will be what is happening between 13 and 14 but was just trying to figure out one thing at a time...unless they're related.
UPDATE
[RE Comment by Ken Thomases below on what the console log says is happening between 13 and 14]
2015/02/08 5:30:40,963 PM WindowServer[114]: disable_update_timeout: UI updates were forcibly disabled by application "Grid" for over 1.00 seconds. Server has re-enabled them.
2015/02/08 5:30:43,568 PM WindowServer[114]: common_reenable_update: UI updates were finally reenabled by application "Grid" after 3.61 seconds (server forcibly re-enabled them after 1.00 seconds)
The occurrence of the above is linked to the size of the grid of NSTextField objects I am trying to display. Below a certain grid size it doesn't occur.
来源:https://stackoverflow.com/questions/28392153/why-is-my-cocoa-nswindow-taking-such-a-long-time-to-become-active