Switching graphics cards with the screen asleep makes WindowServer freeze

If the display on my 2012 Retina MacBook Pro is asleep when the computer switches from the discrete Nvidia graphics card to the integrated Intel one, WindowServer will freeze. I'm able to move the cursor and even control applications (for instance, unpause iTunes) by clicking blindly, but the image on screen won't update.

One surefire way to reproduce it is to connect to the computer through VNC causing the computer will switch to the discrete graphics. I then close the VNC client on my phone and use a hot corner to put the display to sleep. Whenever the VNC server realizes the client disconnected, it switches back to the integrated graphics, triggering the bug. This is not exclusive to VNC though, as I can trigger this bug with any application that uses discrete graphics.

Here's the relevant log:

4/2/14 13:18:53.902 screensharingd[274]: Authentication: SUCCEEDED :: User Name: user :: Viewer Address: 192.168.1.12 :: Type: DH
4/2/14 13:18:54.159 WindowServer[100]: Received display connect changed for display 0x4280382
4/2/14 13:18:54.182 WindowServer[100]: Found 62 modes for display 0x04280382 [36, 26]
4/2/14 13:18:54.206 WindowServer[100]: Received display connect changed for display 0x3f003f
4/2/14 13:18:54.206 WindowServer[100]: Found 1 modes for display 0x003f003f [1, 0]
4/2/14 13:18:54.206 WindowServer[100]: Received display connect changed for display 0x3f0040
4/2/14 13:18:54.207 WindowServer[100]: Found 1 modes for display 0x003f0040 [1, 0]
4/2/14 13:18:54.207 WindowServer[100]: Received display connect changed for display 0x3f0041
4/2/14 13:18:54.207 WindowServer[100]: Found 1 modes for display 0x003f0041 [1, 0]
4/2/14 13:18:54.218 WindowServer[100]: CGXMuxAcknowledge: Posting glitchless acknowledge
4/2/14 13:18:54.229 WindowServer[100]: MPAccessSurfaceForDisplayDevice: Set up page flip mode on display 0x04280382 device: 0x7fd5fd100be0  isBackBuffered: 1 numComp: 3 numDisp: 3
4/2/14 13:18:54.253 WindowServer[100]: Received display connect changed for display 0x4280382
4/2/14 13:18:54.254 WindowServer[100]: Found 1 modes for display 0x04280382 [1, 0]
4/2/14 13:18:58.000 kernel[0]: pci pause: SDXC
4/2/14 13:19:01.261 WindowServer[100]: _CGXSetWindowBackgroundBlurRadius: Invalid window 0xffffffff
4/2/14 13:19:01.282 loginwindow[68]: find_shared_window: WID -1
4/2/14 13:19:01.283 loginwindow[68]: CGSGetWindowTags: Invalid window 0xffffffff
4/2/14 13:19:01.283 loginwindow[68]: find_shared_window: WID -1
4/2/14 13:19:01.283 loginwindow[68]: CGSSetWindowTags: Invalid window 0xffffffff
4/2/14 13:19:01.372 WindowServer[100]: device_generate_desktop_screenshot: authw 0x7fd5fd04fdc0(2000), shield 0x7fd5fae43ba0(2001)
4/2/14 13:19:01.391 WindowServer[100]: device_generate_lock_screen_screenshot: authw 0x7fd5fd04fdc0(2000), shield 0x7fd5fae43ba0(2001)
4/2/14 13:19:01.534 com.apple.launchd.peruser.501[154]: (com.apple.SystemUIServer.agent[167]) The following job tried to hijack the service "com.apple.tsm.uiserver" from this job: 0x7fd1b3609f20.anonymous.loginwindow
4/2/14 13:19:14.139 loginwindow[68]: ERROR | -[LWBuiltInScreenLockAuthLion closeAuthAndReset:] | Attempted to remove an observer when not observing
4/2/14 13:19:14.174 WindowServer[100]: CGXDisplayDidWakeNotification [45457018136]: posting kCGSDisplayDidWake
4/2/14 13:19:14.175 WindowServer[100]: handle_will_sleep_auth_and_shield_windows: Deferring.
4/2/14 13:19:14.320 WindowServer[100]: Received display connect changed for display 0x4280382
4/2/14 13:19:14.341 WindowServer[100]: Found 29 modes for display 0x04280382 [18, 11]
4/2/14 13:19:14.371 WindowServer[100]: Received display connect changed for display 0x4280382
4/2/14 13:19:14.372 WindowServer[100]: Found 1 modes for display 0x04280382 [1, 0]
4/2/14 13:19:14.372 WindowServer[100]: current_mode_index: Failed to find current {ioModeID, ioModeDepth}
4/2/14 13:19:14.386 WindowServer[100]: Received display connect changed for display 0x3f003f
4/2/14 13:19:14.386 WindowServer[100]: Found 1 modes for display 0x003f003f [1, 0]
4/2/14 13:19:14.386 WindowServer[100]: Received display connect changed for display 0x3f0040
4/2/14 13:19:14.386 WindowServer[100]: Found 1 modes for display 0x003f0040 [1, 0]
4/2/14 13:19:14.386 WindowServer[100]: Received display connect changed for display 0x3f0041
4/2/14 13:19:14.387 WindowServer[100]: Found 1 modes for display 0x003f0041 [1, 0]
4/2/14 13:19:14.400 WindowServer[100]: CGXMuxAcknowledge: Posting glitchless acknowledge
4/2/14 13:19:14.401 WindowServer[100]: CGXMuxAcknowledge: Posting immediate acknowledge
4/2/14 13:19:14.487 WindowServer[100]: MPAccessSurfaceForDisplayDevice: Set up page flip mode on display 0x04280382 device: 0x7fd5fd100be0  isBackBuffered: 1 numComp: 3 numDisp: 3
4/2/14 13:19:14.490 WindowServer[100]: Received display connect changed for display 0x4280382
4/2/14 13:19:14.491 WindowServer[100]: Found 1 modes for display 0x04280382 [1, 0]
4/2/14 13:19:14.491 WindowServer[100]: Display 0x04280382 changed state to offline
4/2/14 13:19:14.525 WindowServer[100]: No display devices are on-line. Switching to virtual display mode
4/2/14 13:19:14.526 WindowServer[100]: Received display connect changed for display 0x3f003f
4/2/14 13:19:14.526 WindowServer[100]: Found 1 modes for display 0x003f003f [1, 0]
4/2/14 13:19:14.526 WindowServer[100]: Received display connect changed for display 0x3f0040
4/2/14 13:19:14.526 WindowServer[100]: Found 1 modes for display 0x003f0040 [1, 0]
4/2/14 13:19:14.526 WindowServer[100]: Received display connect changed for display 0x3f0041
4/2/14 13:19:14.526 WindowServer[100]: Found 1 modes for display 0x003f0041 [1, 0]
4/2/14 13:19:14.527 Finder[168]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.527 gfxCardStatus[218]: CGSCopyDisplayColorSpace: Invalid display 0x04280382sa
4/2/14 13:19:14.543 Kotoeri[235]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.543 Kotoeri[235]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.543 WindowServer[100]: Display 0x41dc9d01: GL mask 0x2; bounds (0, 0)[1280 x 1024], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 1, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.544 WindowServer[100]: Display 0x41dc9d05: GL mask 0x20; bounds (0, 0)[1280 x 1024], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 5, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.544 WindowServer[100]: Display 0x41dc9d04: GL mask 0x10; bounds (0, 0)[1280 x 1024], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 4, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.544 WindowServer[100]: Display 0x41dc9d03: GL mask 0x8; bounds (0, 0)[1280 x 1024], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 3, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.544 WindowServer[100]: Display 0x41dc9d02: GL mask 0x5; bounds (0, 0)[1440 x 900], 27 modes available
Main, Active, on-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 2, Rotation 0
UUID 0xf7e52f93b4ac312e87ed39669f5c08b8
4/2/14 13:19:14.545 Melo[238]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.545 Melo[238]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.563 NotificationCenter[189]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.563 NotificationCenter[189]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.563 NotificationCenter[189]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.563 NotificationCenter[189]: CGSCopyDisplayColorSpace: Invalid display 0x04280382
4/2/14 13:19:14.571 WindowServer[100]: Display added
4/2/14 13:19:14.571 WindowServer[100]: Display removed
4/2/14 13:19:14.573 WindowServer[100]: Display 0x41dc9d02: GL mask 0x5; bounds (0, 0)[1440 x 900], 27 modes available
Main, Active, on-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 2, Rotation 0
UUID 0xf7e52f93b4ac312e87ed39669f5c08b8
4/2/14 13:19:14.573 WindowServer[100]: Display 0x41dc9d01: GL mask 0x2; bounds (2464, 0)[1 x 1], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 1, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.573 WindowServer[100]: Display 0x41dc9d05: GL mask 0x20; bounds (2465, 0)[1 x 1], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 5, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.573 WindowServer[100]: Display 0x41dc9d04: GL mask 0x10; bounds (2466, 0)[1 x 1], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 4, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:14.573 WindowServer[100]: Display 0x41dc9d03: GL mask 0x8; bounds (2467, 0)[1 x 1], 2 modes available
off-line, enabled, built-in, Vendor 756e6b6e, Model 76697274, S/N 0, Unit 3, Rotation 0
UUID 0xffffffffffffffffffffffffffffffff
4/2/14 13:19:16.572 WindowServer[100]: **DMPROXY** (2) Found `/System/Library/CoreServices/DMProxy'.
4/2/14 13:19:16.609 WindowServer[100]: Display 0x41dc9d02: Unit 2; ColorProfile { 3, "Display"}
4/2/14 13:19:16.630 WindowServer[100]: Display 0x41dc9d02: Unit 2; ColorProfile { 3, "Display"}; TransferFormula (1.000000, 1.000000, 1.000000)
4/2/14 13:19:16.655 WindowServer[100]: Display 0x41dc9d02: Unit 2; ColorProfile { 3, "Display"}; TransferFormula (1.000000, 1.000000, 1.000000)
4/2/14 13:19:21.043 login[283]: USER_PROCESS: 283 ttys001
4/2/14 13:19:38.053 sudo[291]:     user : TTY=ttys000 ; PWD=/Users/user ; USER=root ; COMMAND=/usr/bin/killall loginwindow

Points of interest: 13:18:53, I connect via VNC. 13:19:14, the computer tries switching to Intel graphics and gets a lot of errors. 13:19:38, I kill loginscreen through SSH to get WindowServer to restart.

This is a clean 10.9.2 install done yesterday using the recovery partition. The day before I had a 10.9 install that I upgraded from 10.8 and 10.7 that didn't have this problem, so I don't think it's a hardware issue. I have no 3rd party kernel extensions installed.


Solution 1:

Have you tried turning off "Automatic Graphics Switching" in the Energy Saver preference pane?