OSX 10.7 with external display causes CPU spike

Bug #804321 reported by Josh Kerr
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
InsomniaT
Fix Released
High
Archimedes Trajano

Bug Description

I'm not expecting Lion support at this point, but I wanted to notify you of this strange bug. The app runs fine in Lion except when you connect an external display. Then the CPU spikes to 125% with configd and powerd going nuts. The fix is to either unplug the power adapter or to start InomniaT. Both fix the issue.

Revision history for this message
Archimedes Trajano (trajano) wrote :

Thanks. Not sure how I can test this, I don't have Lion as of yet. Is this on more than one machine? They may have changed the IOKit.

Revision history for this message
Josh Kerr (joshkerr) wrote :

I've confirmed on multiple machines. Even after a fresh install, I see this behavior. Unplugging the power adapter surprisingly makes it work again. I can test a beta for you or provide extra data about the error if you want.

Revision history for this message
Napkula (napkula) wrote :

I am experiencing symptoms similar to this with 10.6.7! I filed a question about it -- any help would be very very appreciated.

Revision history for this message
Josh Kerr (joshkerr) wrote : Re: [Bug 804321] Re: OSX 10.7 with external display causes CPU spike

If you activate insomnia mode, it should work fine. If you disable it,
you'll get that CPU race condition.

On Wed, Jul 6, 2011 at 12:30 PM, Napkula <email address hidden> wrote:

> I am experiencing symptoms similar to this with 10.6.7! I filed a
> question about it -- any help would be very very appreciated.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/804321
>
> Title:
> OSX 10.7 with external display causes CPU spike
>
> Status in InsomniaT:
> New
>
> Bug description:
> I'm not expecting Lion support at this point, but I wanted to notify
> you of this strange bug. The app runs fine in Lion except when you
> connect an external display. Then the CPU spikes to 125% with configd
> and powerd going nuts. The fix is to either unplug the power adapter
> or to start InomniaT. Both fix the issue.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/insomniat/+bug/804321/+subscriptions
>

Revision history for this message
Napkula (napkula) wrote :

I noticed that during my troubleshooting -- it works for the CPU issue. At this point though I just want it uninstalled! The Uninstall option is missing from the preference pane, and running the uninstall script with sudo doesn't seem to completely remove InsomniaT -- just the kext.

Revision history for this message
Josh Kerr (joshkerr) wrote :

Right click on the icon in system preferences and choose "remove."
On Jul 6, 2011, at 1:16 PM, Napkula wrote:

> I noticed that during my troubleshooting -- it works for the CPU issue.
> At this point though I just want it uninstalled! The Uninstall option is
> missing from the preference pane, and running the uninstall script with
> sudo doesn't seem to completely remove InsomniaT -- just the kext.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/804321
>
> Title:
> OSX 10.7 with external display causes CPU spike
>
> Status in InsomniaT:
> New
>
> Bug description:
> I'm not expecting Lion support at this point, but I wanted to notify
> you of this strange bug. The app runs fine in Lion except when you
> connect an external display. Then the CPU spikes to 125% with configd
> and powerd going nuts. The fix is to either unplug the power adapter
> or to start InomniaT. Both fix the issue.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/insomniat/+bug/804321/+subscriptions

Revision history for this message
Napkula (napkula) wrote :

Fairly certain that only removes the PrefPane?

Sorry to muddy this bug thread up =(

Revision history for this message
Dustin Melancon (topside844) wrote :

Yes, definitely seems to deal with IOKit.

Here's the kernel.log entries during the race condition:

kernel[0]: /SourceCache/xnu/xnu-1699.22.73/iokit/Kernel/IOUserClient.cpp: mach_msg_send_from_kernel_proper {1000000d}

This message is repeated in an infinite loop until either InsomniaT is switched back to the 'On' setting, or you unplug from a power source.

Revision history for this message
Archimedes Trajano (trajano) wrote :

Hi Josh can I presume you are a registered Apple Developer as such you can get XCode and compile the code yourself? I am thinking because I had built this on 10.6 so long ago there may be some changes to the IOKit code that requires a recompile (which sounds flakey, but this is the only thing I can think of).

Revision history for this message
Archimedes Trajano (trajano) wrote :

I also do not have a display port adapter so I cannot test your scenario.

Changed in insomniat:
importance: Undecided → High
status: New → In Progress
assignee: nobody → Archimedes Trajano (archimedes)
Revision history for this message
Dustin Melancon (topside844) wrote :

Archimedes,

I'm able to replicate the problem and will see I can compile a fresh copy with the Lion SDK.

Fell free to get in touch with me if you'd like access to a developer machine with Lion and an external display.

Revision history for this message
Josh Kerr (joshkerr) wrote :

I compiled the code and got the same problem.

--
Josh Kerr

On Jul 12, 2011, at 3:01 PM, Dustin Melancon wrote:

> Archimedes,
>
> I'm able to replicate the problem and will see I can compile a fresh
> copy with the Lion SDK.
>
> Fell free to get in touch with me if you'd like access to a developer
> machine with Lion and an external display.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/804321
>
> Title:
> OSX 10.7 with external display causes CPU spike
>
> Status in InsomniaT:
> In Progress
>
> Bug description:
> I'm not expecting Lion support at this point, but I wanted to notify
> you of this strange bug. The app runs fine in Lion except when you
> connect an external display. Then the CPU spikes to 125% with configd
> and powerd going nuts. The fix is to either unplug the power adapter
> or to start InomniaT. Both fix the issue.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/insomniat/+bug/804321/+subscriptions

Revision history for this message
Archimedes Trajano (trajano) wrote :

Please make the following change

line 82 of the InsomniaTUserClient.cpp

 return super::externalMethod(selector,arguments,dispatch,target,reference);

to

 IOLog("InsomniaT: unknown message ignoring\n");
 return kIOReturnSuccess;

And verify that the message appears in the kernel.log file.

Also please let me know if the following message appears on the kernel.log

       InsomniaT: external method selector is

Revision history for this message
Archimedes Trajano (trajano) wrote :

I can probably add some detection logic to see an external display is connected, if it is I can disable insomniaT from doing its work. What is the behaviour of MacOS X when an external display is connected and the lid is closed normally?

Revision history for this message
Josh Kerr (joshkerr) wrote :

First, I use both monitors when connected to my external display. Second, Insomnia does not cause problems if it is enabled while connected to the second monitor. Meaning that insomnia mode is active. If it is inactive, you experience the problems.

jk

--
Josh Kerr

On Jul 13, 2011, at 11:06 AM, Archimedes Trajano wrote:

> I can probably add some detection logic to see an external display is
> connected, if it is I can disable insomniaT from doing its work. What
> is the behaviour of MacOS X when an external display is connected and
> the lid is closed normally?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/804321
>
> Title:
> OSX 10.7 with external display causes CPU spike
>
> Status in InsomniaT:
> In Progress
>
> Bug description:
> I'm not expecting Lion support at this point, but I wanted to notify
> you of this strange bug. The app runs fine in Lion except when you
> connect an external display. Then the CPU spikes to 125% with configd
> and powerd going nuts. The fix is to either unplug the power adapter
> or to start InomniaT. Both fix the issue.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/insomniat/+bug/804321/+subscriptions

Revision history for this message
Archimedes Trajano (trajano) wrote :

Ok I'll add some detection logic to see if there is more than one display connected (that would imply an external monitor is plugged in) then insomniaT will not try to disable sleep functionality.

Revision history for this message
Archimedes Trajano (trajano) wrote :

Can someone with multiple displays tell me if the search for IORegistryExplorer for IODisplayConnect returns more than one entry? I was planning to use that to count the number of displays (I can't use CGDisplay* functions on the IOKit level)

Revision history for this message
Josh Kerr (joshkerr) wrote :

--
Josh Kerr

On Jul 13, 2011, at 2:14 PM, Archimedes Trajano wrote:

> IODisplayConnect

Revision history for this message
Archimedes Trajano (trajano) wrote :
  • insomniat-3.0.1.dmg Edit (858.8 KiB, application/octet-stream; x-mac-type=64657669; x-mac-creator=6464736B; x-unix-mode=0644; name="insomniat-3.0.1.dmg")

Attached is a preview of the next release of InsomniaT with a check on how many displays are used. Please try to see if it fixes the problem.

If it hangs your system you can safe boot by holding down Shift while the machine restarts.

Revision history for this message
Archimedes Trajano (trajano) wrote :

I added some code to do the multiple monitor check. If it detects multiple monitors, it disables sleep all the time. Hopefully that would fix the issue.

Revision history for this message
Josh Kerr (joshkerr) wrote : Re: [Bug 804321] OSX 10.7 with external display causes CPU spike

System panic when connecting second monitor. System panic on startup. Had to boot into single user mode and remove the kext manually.

--
Josh Kerr

On Jul 13, 2011, at 3:37 PM, Archimedes Trajano wrote:

> I added some code to do the multiple monitor check. If it detects
> multiple monitors, it disables sleep all the time. Hopefully that would
> fix the issue.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/804321
>
> Title:
> OSX 10.7 with external display causes CPU spike
>
> Status in InsomniaT:
> In Progress
>
> Bug description:
> I'm not expecting Lion support at this point, but I wanted to notify
> you of this strange bug. The app runs fine in Lion except when you
> connect an external display. Then the CPU spikes to 125% with configd
> and powerd going nuts. The fix is to either unplug the power adapter
> or to start InomniaT. Both fix the issue.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/insomniat/+bug/804321/+subscriptions

Revision history for this message
Archimedes Trajano (trajano) wrote :

Thanks for the info. When rebooting with panic was the second monitor connected?

I guess this is not a trivial problem then, difficult to see what's going on without a test rig.

Revision history for this message
Archimedes Trajano (trajano) wrote :

Is the behaviour the same when using the current version of InsomniaT?

Another hypothesis I can try is changing the code as follows to make multiple displays do nothing.

    if (isMultipleDisplays()) {
  if (isLoggingEnabled()) {
   IOLog("InsomniaT: multiple displays detected doing nothing.\n");
  }
        return;
    }

    if (isSleepEnabled() && !isSleepEnabledBySystem()) {
  if (isLoggingEnabled()) {
   IOLog("InsomniaT: enabling sleep.\n");
  }
  enableSleep();
 } else if (!isSleepEnabled() && isSleepEnabledBySystem()) {
  if (isLoggingEnabled()) {
   IOLog("InsomniaT: disabling sleep.\n");
  }
  disableSleep();
 }

Revision history for this message
Archimedes Trajano (trajano) wrote : Re: [Bug 804321] Re: OSX 10.7 with external display causes CPU spike
  • insomniat-3.0.1.dmg Edit (859.0 KiB, application/octet-stream; x-mac-type=64657669; x-mac-creator=6464736B; x-unix-mode=0644; name="insomniat-3.0.1.dmg")

This is the one where if multiple displays are detected it does nothing.

Revision history for this message
Archimedes Trajano (trajano) wrote :
  • insomniat-3.0.1.dmg Edit (859.0 KiB, application/octet-stream; x-mac-type=64657669; x-mac-creator=6464736B; x-unix-mode=0644; name="insomniat-3.0.1.dmg")

This is another one where the check for isMultipleDisplays occurs on the enableSleep and disableSleep methods.

Changed in insomniat:
milestone: none → 3.0.1
Revision history for this message
Archimedes Trajano (trajano) wrote :
  • insomniat-3.0.1.dmg Edit (859.1 KiB, application/octet-stream; x-mac-type=64657669; x-mac-creator=6464736B; x-unix-mode=0644; name="insomniat-3.0.1.dmg")

Found the reason for crash on bootup. I added a NULL check in the getMultipleDisplays my suspicion is that getMatchingServices() reutrns NULL on boot up.

     OSDictionary* dict = OSDictionary::withCapacity(1);
     dict->setObject(kIOProviderClassKey, OSString::withCStringNoCopy("IODisplayConnect"));
     OSIterator* ioDisplayConnectIterator = getMatchingServices(dict);
+ if (ioDisplayConnectIterator == NULL) {
+ return false;
+ }
     unsigned int displayCount = 0;
     OSObject* obj;

Revision history for this message
Archimedes Trajano (trajano) wrote :
  • insomniat-3.0.1.dmg Edit (859.1 KiB, application/octet-stream; x-mac-type=64657669; x-mac-creator=6464736B; x-unix-mode=0644; name="insomniat-3.0.1.dmg")

Found the reason for crash on bootup. I added a NULL check in the getMultipleDisplays my suspicion is that getMatchingServices() reutrns NULL on boot up.

    OSDictionary* dict = OSDictionary::withCapacity(1);
    dict->setObject(kIOProviderClassKey, OSString::withCStringNoCopy("IODisplayConnect"));
    OSIterator* ioDisplayConnectIterator = getMatchingServices(dict);
+ if (ioDisplayConnectIterator == NULL) {
+ return false;
+ }
    unsigned int displayCount = 0;
    OSObject* obj;

Revision history for this message
Archimedes Trajano (trajano) wrote :

There is an attempt to fix this in the current release but it is not verified.

Changed in insomniat:
milestone: 3.0.1 → 3.0.2
Revision history for this message
Josh Kerr (joshkerr) wrote :

Last time I tried one of the Lion builds it caused my system to freeze on startup. I'm hesitant to try another one until another person verifies that it doesn't lockup their system.

Anyone?

--
Josh Kerr

On Jul 24, 2011, at 5:34 PM, Archimedes Trajano wrote:

> There is an attempt to fix this in the current release but it is not
> verified.
>
> ** Changed in: insomniat
> Milestone: 3.0.1 => 3.0.2
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/804321
>
> Title:
> OSX 10.7 with external display causes CPU spike
>
> Status in InsomniaT:
> In Progress
>
> Bug description:
> I'm not expecting Lion support at this point, but I wanted to notify
> you of this strange bug. The app runs fine in Lion except when you
> connect an external display. Then the CPU spikes to 125% with configd
> and powerd going nuts. The fix is to either unplug the power adapter
> or to start InomniaT. Both fix the issue.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/insomniat/+bug/804321/+subscriptions

Revision history for this message
Archimedes Trajano (trajano) wrote :

Just make sure you uninstall before putting in a new version using the script. The uninstaller that runs within the installer does not always work. 3.0.2 will have a check to force the user to uninstall before running.

Revision history for this message
Archimedes Trajano (trajano) wrote :

Tested the following on 3.0.2 :
Lion, then plugged the following in sequence:
mouse, keyboard, power and finally external display.

Worked successfully using the IODisplayConnect check.

Revision history for this message
Archimedes Trajano (trajano) wrote :

Disabled sending the power events if it is not needed, if it was sent when it is not needed it will cause the CPU spike.

Changed in insomniat:
status: In Progress → Fix Committed
Changed in insomniat:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.