IMac going in and out of sleep every few seconds

imacsleep-wake

If I put my iMac (2011, i7) to sleep, it'll wake up after 5 seconds, then go back to sleep after a few seconds, and repeat constantly. The only way to stop it is to restart. This seems to be happening every two weeks or so.

One key thing is the screen remains blank when going in and out of sleep.

I've quit every application, disabled bluetooth completely, removed all USB devices, reset the PRAM and SMC, turned network wake off, and disabled the inferred sensor, but nothing seems to help.

Here's the kernel.log, where I put it to sleep, it woke, it slept again, then I woke it up by pressing the keyboard (I've split the parts up):

Oct 15 21:00:04 Ashleys-iMac kernel[0]: 196433.337281: performCountryCodeOperation: Disconnecting from AP 
Oct 15 21:00:04 Ashleys-iMac kernel[0]: 196433.337284: setDISASSOC from disconnectVap
Oct 15 21:00:04 Ashleys-iMac kernel[0]: AirPort: Link Down on en1. Reason 8 (Disassociated because station leaving).
Oct 15 21:00:04 Ashleys-iMac kernel[0]: 196433.359794: setDISASSOCIATE ****STA SYNC DISASSOC SUCCESS  
Oct 15 21:00:04 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateWillChangeTo: flags=4 stateNumber=2
Oct 15 21:00:04 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:303   powerStateWillChangeTo: found flag=kIOPMSleepCapability (4)
Oct 15 21:00:04 Ashleys-iMac kernel[0]: 196434.146140: setDISASSOC from disconnectVap
Oct 15 21:00:05 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateDidChangeTo: flags=4 stateNumber=2
Oct 15 21:00:05 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:303   powerStateDidChangeTo: found flag=kIOPMSleepCapability (4)
Oct 15 21:00:05 Ashleys-iMac kernel[0]: 
Oct 15 21:00:06 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0x00000000
Oct 15 21:00:06 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0xe00002ed


Oct 15 21:00:10 Ashleys-iMac kernel[0]: Wake reason: EHC1
Oct 15 21:00:10 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateWillChangeTo: flags=82 stateNumber=3
Oct 15 21:00:10 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:299   powerStateWillChangeTo: found flag=kIOPMPowerOn (2)
Oct 15 21:00:10 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:304   powerStateWillChangeTo: found flag=kIOPMRestartCapability (80)
Oct 15 21:00:10 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateDidChangeTo: flags=82 stateNumber=3
Oct 15 21:00:10 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:299   powerStateDidChangeTo: found flag=kIOPMPowerOn (2)
Oct 15 21:00:10 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:304   powerStateDidChangeTo: found flag=kIOPMRestartCapability (80)
Oct 15 21:00:10 Ashleys-iMac kernel[0]: Previous Sleep Cause: 5
Oct 15 21:00:10 Ashleys-iMac kernel[0]: The USB device HubDevice (Port 1 of Hub at 0xfd000000) may have caused a wake by issuing a remote wakeup (2)
Oct 15 21:00:10 Ashleys-iMac kernel[0]: EIR is supported.
Oct 15 21:00:10 Ashleys-iMac kernel[0]: SSP is supported.
Oct 15 21:00:10 Ashleys-iMac kernel[0]: en1: BSSID changed to c8:cd:72:b0:d9:81
Oct 15 21:00:10 Ashleys-iMac kernel[0]: AirPort: Link Up on en1
Oct 15 21:00:10 Ashleys-iMac kernel[0]: en1: BSSID changed to c8:cd:72:b0:d9:81
Oct 15 21:00:10 Ashleys-iMac kernel[0]: AirPort: RSN handshake complete on en1
Oct 15 21:00:11 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0x00000000
Oct 15 21:00:11 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0xe00002ed
Oct 15 21:00:11 Ashleys-iMac kernel[0]: [SendHCIRequestFormatted] ### ERROR: [0x0804] (Exit Sniff Mode) -- Send request failed (err = 0x000C (kBluetoothHCIErrorCommandDisallowed))
Oct 15 21:00:11 Ashleys-iMac kernel[0]: ### ERROR: Exit sniff failed (probably already unsniffed) (err=c)
Oct 15 21:00:16 Ashleys-iMac kernel[0]: Graphics suppressed 6163 ms
Oct 15 21:00:21 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateWillChangeTo: flags=4 stateNumber=2
Oct 15 21:00:21 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:303   powerStateWillChangeTo: found flag=kIOPMSleepCapability (4)
Oct 15 21:00:21 Ashleys-iMac kernel[0]: en1: BSSID changed to c8:cd:72:b0:d9:81
Oct 15 21:00:21 Ashleys-iMac kernel[0]: 196447.997183: setDISASSOC from disconnectVap
Oct 15 21:00:21 Ashleys-iMac kernel[0]: AirPort: Link Down on en1. Reason 8 (Disassociated because station leaving).
Oct 15 21:00:21 Ashleys-iMac kernel[0]: 196448.020319: setDISASSOCIATE ****STA SYNC DISASSOC SUCCESS  
Oct 15 21:00:22 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateDidChangeTo: flags=4 stateNumber=2
Oct 15 21:00:22 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:303   powerStateDidChangeTo: found flag=kIOPMSleepCapability (4)
Oct 15 21:00:22 Ashleys-iMac kernel[0]: 
Oct 15 21:00:22 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0x00000000
Oct 15 21:00:22 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0xe00002ed


Oct 15 21:00:27 Ashleys-iMac kernel[0]: Wake reason: EHC1
Oct 15 21:00:27 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateWillChangeTo: flags=82 stateNumber=3
Oct 15 21:00:27 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:299   powerStateWillChangeTo: found flag=kIOPMPowerOn (2)
Oct 15 21:00:27 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:304   powerStateWillChangeTo: found flag=kIOPMRestartCapability (80)
Oct 15 21:00:27 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateDidChangeTo: flags=82 stateNumber=3
Oct 15 21:00:27 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:299   powerStateDidChangeTo: found flag=kIOPMPowerOn (2)
Oct 15 21:00:27 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:304   powerStateDidChangeTo: found flag=kIOPMRestartCapability (80)
Oct 15 21:00:27 Ashleys-iMac kernel[0]: Previous Sleep Cause: 5
Oct 15 21:00:27 Ashleys-iMac kernel[0]: The USB device HubDevice (Port 1 of Hub at 0xfd000000) may have caused a wake by issuing a remote wakeup (2)
Oct 15 21:00:27 Ashleys-iMac kernel[0]: EIR is supported.
Oct 15 21:00:27 Ashleys-iMac kernel[0]: SSP is supported.
Oct 15 21:00:27 Ashleys-iMac kernel[0]: en1: BSSID changed to c8:cd:72:b0:d9:81
Oct 15 21:00:27 Ashleys-iMac kernel[0]: AirPort: Link Up on en1
Oct 15 21:00:27 Ashleys-iMac kernel[0]: en1: BSSID changed to c8:cd:72:b0:d9:81
Oct 15 21:00:27 Ashleys-iMac kernel[0]: AirPort: RSN handshake complete on en1
Oct 15 21:00:28 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0x00000000
Oct 15 21:00:28 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0xe00002ed
Oct 15 21:00:29 Ashleys-iMac kernel[0]: [SendHCIRequestFormatted] ### ERROR: [0x0804] (Exit Sniff Mode) -- Send request failed (err = 0x000C (kBluetoothHCIErrorCommandDisallowed))
Oct 15 21:00:29 Ashleys-iMac kernel[0]: ### ERROR: Exit sniff failed (probably already unsniffed) (err=c)
Oct 15 21:00:33 Ashleys-iMac kernel[0]: Graphics suppressed 6108 ms
Oct 15 21:00:39 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateWillChangeTo: flags=4 stateNumber=2
Oct 15 21:00:39 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:303   powerStateWillChangeTo: found flag=kIOPMSleepCapability (4)
Oct 15 21:00:39 Ashleys-iMac kernel[0]: en1: BSSID changed to c8:cd:72:b0:d9:81
Oct 15 21:00:39 Ashleys-iMac kernel[0]: 196461.449910: setDISASSOC from disconnectVap
Oct 15 21:00:39 Ashleys-iMac kernel[0]: AirPort: Link Down on en1. Reason 8 (Disassociated because station leaving).
Oct 15 21:00:39 Ashleys-iMac kernel[0]: 196461.474157: setDISASSOCIATE ****STA SYNC DISASSOC SUCCESS  
Oct 15 21:00:39 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateDidChangeTo: flags=4 stateNumber=2
Oct 15 21:00:39 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:303   powerStateDidChangeTo: found flag=kIOPMSleepCapability (4)
Oct 15 21:00:39 Ashleys-iMac kernel[0]: 
Oct 15 21:00:39 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0x00000000
Oct 15 21:00:40 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0xe00002ed


Oct 15 21:00:44 Ashleys-iMac kernel[0]: Wake reason: EHC2 EHC1
Oct 15 21:00:44 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateWillChangeTo: flags=82 stateNumber=3
Oct 15 21:00:44 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:299   powerStateWillChangeTo: found flag=kIOPMPowerOn (2)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:304   powerStateWillChangeTo: found flag=kIOPMRestartCapability (80)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:298   powerStateDidChangeTo: flags=82 stateNumber=3
Oct 15 21:00:44 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:299   powerStateDidChangeTo: found flag=kIOPMPowerOn (2)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: /drv/ MacModule.cpp:304   powerStateDidChangeTo: found flag=kIOPMRestartCapability (80)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: Previous Sleep Cause: 5
Oct 15 21:00:44 Ashleys-iMac kernel[0]: The USB device HubDevice (Port 1 of Hub at 0xfd000000) may have caused a wake by issuing a remote wakeup (2)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: The USB device HubDevice (Port 1 of Hub at 0xfa000000) may have caused a wake by issuing a remote wakeup (2)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: en1: 802.11d country code set to 'GB '.
Oct 15 21:00:44 Ashleys-iMac kernel[0]: en1: Supported channels 1 2 3 4 5 6 7 8 9 10 11 12 13 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140
Oct 15 21:00:44 Ashleys-iMac kernel[0]: The USB device BRCM2046 Hub (Port 1 of Hub at 0xfa100000) may have caused a wake by issuing a remote wakeup (3)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: The USB device Bluetooth USB Host Controller (Port 1 of Hub at 0xfa110000) may have caused a wake by issuing a remote wakeup (3)
Oct 15 21:00:44 Ashleys-iMac kernel[0]: EIR is supported.
Oct 15 21:00:44 Ashleys-iMac kernel[0]: SSP is supported.
Oct 15 21:00:44 Ashleys-iMac kernel[0]: 196463.844818: performCountryCodeOperation: Disconnecting from AP 
Oct 15 21:00:44 Ashleys-iMac kernel[0]: 196463.849588: setDISASSOC from disconnectVap
Oct 15 21:00:44 Ashleys-iMac kernel[0]: HID tickle 320 ms
Oct 15 21:00:45 Ashleys-iMac kernel[0]: Sound assertion "0 == fAudioEngineArray" failed in AppleHDADriver at line 3045 goto Exit
Oct 15 21:00:45 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0x00000000
Oct 15 21:00:45 Ashleys-iMac kernel[0]: IOThunderboltSwitch::i2cWriteDWord - status = 0xe00002ed

I've compared the processes from a fresh restart and when the issue is occurring. Here's what I'm left with:

/Applications/iPhoto.app/Contents/Library/LoginItems/PhotoStreamAgent.app/Contents/MacOS/PhotoStreamAgent

/System/Library/PrivateFrameworks/Heimdal.framework/Helpers/kdc

/System/Library/CoreServices/backupd

/System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker -s mdworker -c MDSImporterWorker -m com.apple.mdworker.pool.1

Does anyone know what the cause could be? Could it be a hardware fault?

Thanks!

Best Answer

Judging from your log, something on the USB bus is triggering the wake-up (and a similar issue I have found pointed to a defective Apple USB keyboard). As you have removed all hardware devices, my prime path of investigation would be drivers for any 3rd party USB devices (modem? scanner? graphics tablet?) and software that aims to extend the behavior of external devices (like BetterTouchTool, MagicPrefs, misc. and sundry).