Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mike MA

macrumors 68020
Sep 21, 2012
2,090
1,813
Germany
Just quickly wanted to share that the Apple Developer Team contacted me today after submitting a bug report last week.

So at least they beginn to show some interest. Anybody else got a response yet?
 

colloc

macrumors member
Jul 27, 2012
87
0
ML clean install, SSD installed, boot time 10 secs, shutdown time still as long as ever.
 

maxonthemac

macrumors newbie
Oct 28, 2012
9
0
Hi all! I'm at my first post, but think I have some useful information to share.

As correctly pointed out in post #79, in my case the slow shutdown was due to the appleeventsd process hanging.

To discover it, I went through 2 steps:
  • booting in verbose mode and checking the messages issued during shutdown; you may notice repeated attempts to quit a specific process; in my case, they addressesed some stuck com.apple.coreservices.appleevents task;
  • launching the Console application from the Spotlight and browsing through one of the system-wide launchd-shutdown logs; in my case, I found that the above mentioned task was killed after an expired timeout of 20 seconds; not much surprisingly, my shutdown took 22 seconds (=20 seconds for the timeout + the usual 2 seconds I normally experienced for the shutdown).
So, the culprit apparently was a service managed by launchd. launchd is a daemon that takes care of starting, stopping, and monitoring many system-wide and user-specific services. From the documentation (man page) of launchd.plist, when one of these services is to be stopped, it is sent a SIGTERM signal to halt gracefully. If it does not react within the predefined 20 seconds timeout, it is hardly terminated with a SIGKILL.

So, I have put the following workaround in place.
The default timeout value can be changed by editing the .plist XML file that describes the service parameters. For the case of appleeventsd, this file is /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist. So, I made a backup copy of this file and carefully edited it by adding the following 2 lines right before the two final closing tags </dict> and </plist>:
<key>ExitTimeOut</key>
<integer>2</integer>
Be very careful when editing this file and, really, make a backup copy, because there are chances that a wrong edit may screw some system components (most notably, the Finder application).

It took a reboot cycle to make launchd fetch the updated timeout value, but this did the trick: the appleeventsd service is still reported as stuck during shutdown, but at least only 2 seconds are waited before giving up waiting, totaling 4 (=2+2) seconds of shutdown time. I know, it's a very dirty workaround but, until a proper fix comes, it makes me very happy! :D


A couple of side notes:
  • In my personal experience there have been different services intermittently affected by this issue but, ultimately, killing appleeventsd seems to have (hopefully) permanently solved the slow shutdown problem for me.
  • I have just noticed that a similar solution has already been independently posted elsewhere: https://discussions.apple.com/thread/4339540?start=60&tstart=0. If only I could find it earlier...

I would really like to also post this to the relevant Apple Discussions forums, but it seems the system decided not to let me even create a nickname, leaving me with a mysterious "An unknown error has occurred" message. Apparently, logging in to Apple Discussions is another problem that has been suffered for long by many people, therefore I'm giving up on that (for now...)

I hope this helps someone.
 

RS2

macrumors member
Apr 4, 2011
84
17
These terminal commands should also fix the problem then and kill the services after 2 seconds:

Code:
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist

sudo defaults write /System/Library/LaunchDaemons/com.apple.coreservices.appleevents ExitTimeOut -int 2

sudo launchctl load /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist
 
Last edited:

MacMan988

macrumors 6502a
Jul 7, 2012
869
150
I love apple products. But it would have been even better if Apple spends a bit more on software QA than this. Specially since Apple products always comes with a larger price tag attached.

----------

You should file a bug report dealing with your findings:

https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/wa/signIn

As I stated before, Apple began to show some interest after I provided some system logs.

When I try to login to that link you have given, it gives the following error.


An error has occurred. Please report the error to Apple Inc. by emailing the error detail to devbugs@apple.com.

I think apple should start reading about software testing before releasing their next software product....
 

maxonthemac

macrumors newbie
Oct 28, 2012
9
0
I think the solution proposed by RS2 in this post implements even more cleanly what I have proposed in the workaround I have described.

I'm not sure whether the -w option of launchctl is required, though. AFAIK, what it does is to permanently flag the affected service as "Disabled", so that it is never loaded at reboot (or whenever it would need to). Given that here we just want the service to be temporarily unloaded (so that launchd can fetch the configuration change without rebooting) and that the launchctl unload -w is immediately compensated by a launchctl load -w, I think the -w can be safely avoided overall.

P.S. I'm still suspicious about what could be causing appleeventsd to hang, but still could not consistently ascribe this to any specific softwares I am using. The only thing I have noticed is that, the more applications I run since boot, the more likely it is that appleeventsd needs to be killed. Apparently, just starting and immediately closing an Office application (Word, Excel, PowerPoint) significantly increases the chance that the hang happens for me.
 

razmarino

macrumors member
Mar 1, 2012
55
0
These terminal commands should also fix the problem then and kill the services after 2 seconds:

Code:
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist

Code:
sudo defaults write /System/Library/LaunchDaemons/com.apple.coreservices.appleevents ExitTimeOut -int 2

Code:
sudo launchctl load /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist
still 20sec to shutdown.. am i missing smth?
 

maxonthemac

macrumors newbie
Oct 28, 2012
9
0
still 20sec to shutdown.. am i missing smth?

Maybe it's some other service that is slowing down your shutdown. You can attempt discovering which one by booting in verbose mode and looking at the messages issued during shutdown, or by opening the Console application and browsing through the system-wide and user-specific launchd-shutdown logs. Of course, provided that it's some launchd managed service that is causing the slowdown.
 

razmarino

macrumors member
Mar 1, 2012
55
0
EDIT: Everythin is fine) its like a pain relief! thx maxonthemac & RS2!! now i can go to sleep without irritation every time when turnin off this machine)
 

RS2

macrumors member
Apr 4, 2011
84
17
When I compare the launchd-shutdown logs there are two processes that are killed after 20 seconds.

Code:
com.apple.launchd  1  com.apple.securityd  15  Exit timeout elapsed (20 seconds)
com.apple.launchd  1  com.apple.securityd  15  Sent SIGKILL signal

com.apple.launchd  1  com.apple.coreservices.appleevents  63  Exit timeout elapsed (20 seconds)
com.apple.launchd  1  com.apple.coreservices.appleevents  63  Sent SIGKILL signal

Looks like the securityd daemon is supposed to do something at shutdown but is also killed?

Code:
sudo defaults read /System/Library/LaunchDaemons/com.apple.securityd

{
    BeginTransactionAtShutdown = 1;
    EnableTransactions = 1;
    Label = "com.apple.securityd";
    LaunchOnlyOnce = 0;
    MachServices =     {
        "com.apple.SecurityServer" =         {
            ResetAtClose = 1;
        };
    };
    ProgramArguments =     (
        "/usr/sbin/securityd",
        "-i"
    );
    RunAtLoad = 1;
}
 
Last edited:

razmarino

macrumors member
Mar 1, 2012
55
0
im guessin, if apple will release a fix for this with 8.3 update, do we have to reverse those changes we made before updatin, or just update as usual?
also noticed, that shutdown is not always quick after those changes to appleeventsd, looks like there is smth else which still hangin up..
but when i kill appleeventsd manually before shutdown, its always rapid, so a little confused here
 

RS2

macrumors member
Apr 4, 2011
84
17
im guessin, if apple will release a fix for this with 8.3 update, do we have to reverse those changes we made before updatin, or just update as usual? also noticed, that shutdown is not always quick after those changes to appleeventsd, looks like there is smth else which still hangin up.. but when i kill appleeventsd manually before shutdown, its always rapid, so a little confused here

You can update as usual and reverse the changes by deleting the ExitTimeOut key from the plist.

Please see above. The securityd daemon can also be the problem. Check the launchd-shutdown logs.
 

razmarino

macrumors member
Mar 1, 2012
55
0
guys, can anyone send me an original appleevents.plist in pm?)) looks i messed up everything here)) this is how looks mine now after those manipulations)))
 

Attachments

  • ?????? ?????? 2012-10-30 ? 21.13.31.png
    ?????? ?????? 2012-10-30 ? 21.13.31.png
    58.4 KB · Views: 340

RS2

macrumors member
Apr 4, 2011
84
17
guys, can anyone send me an original appleevents.plist in pm?

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	[B]<key>ExitTimeOut</key>
	<integer>2</integer>[/B]
	<key>Label</key>
	<string>com.apple.coreservices.appleevents</string>
	<key>LowPriorityIO</key>
	<false/>
	<key>MachServices</key>
	<dict>
		<key>com.apple.coreservices.appleevents</key>
		<true/>
	</dict>
	<key>ProgramArguments</key>
	<array>
		<string>/System/Library/CoreServices/appleeventsd</string>
		<string>--server</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>UserName</key>
	<string>_eppc</string>
</dict>
</plist>

Code:
sudo defaults read /System/Library/LaunchDaemons/com.apple.coreservices.appleevents

{
    [B]ExitTimeOut = 2;[/B]
    Label = "com.apple.coreservices.appleevents";
    LowPriorityIO = 0;
    MachServices =     {
        "com.apple.coreservices.appleevents" = 1;
    };
    ProgramArguments =     (
        "/System/Library/CoreServices/appleeventsd",
        "--server"
    );
    RunAtLoad = 1;
    UserName = "_eppc";
}
 

Attachments

  • com.apple.coreservices.appleevents.plist.zip
    539 bytes · Views: 292
Last edited:

RS2

macrumors member
Apr 4, 2011
84
17
guys, can anyone send me an original appleevents.plist in pm?

Don't try to use TextEdit to read or change plist files! Please use terminal commands to reverse instead.

Code:
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist

sudo defaults delete /System/Library/LaunchDaemons/com.apple.coreservices.appleevents ExitTimeOut

sudo launchctl load /System/Library/LaunchDaemons/com.apple.coreservices.appleevents.plist
 

razmarino

macrumors member
Mar 1, 2012
55
0
Don't try to use TextEdit to read or change plist files! Please use terminal commands to reverse instead.
yes, i know that, i was using text wrangler, but not sure what i did wrong.. i have already replaced corrupted file and everythin is ok now. thanks a lot for your support! will make another attempt after reading correct info on the subject)
 

razmarino

macrumors member
Mar 1, 2012
55
0
pheeew, missed slash before second "integer", right before your nose and invisible)
used terminal this time and it turned out pretty simple, so fix itself is really :apple:
 

blatopilot

macrumors regular
Sep 24, 2011
149
0
Sharing a couple of thoughts:

Is anyone experiencing this, and NOT using iCloud? Is anyone experiencing this and NOT have an mobile device they are syncing?

I'm curious because I backed up my MBP and iPhone 4s, then signed out of icloud and deleted all data related to iCloud I could find (contacts, calendars, notes, photo stream etc) on both devices. I tried to purge any trace of this data ever existed. On the MBP, this includes: Caches, application support, application saved state, even plists if you know what you are doing.

I then signed into iCloud on my phone, toggled what I wanted to sync, and now my iPhone and MPB are running like brand new. Very fast start up and shut down. My phone became more responsive and smooth (I forgot how fast it WAS), my MPB is loading pages faster than I can keep up. I have not re-set up iCloud on my Mac (I don't need it as much), but if you have backups, it wouldn't hurt to purge everything and start over.
 

Eithanius

macrumors 68000
Nov 19, 2005
1,556
419
Sharing a couple of thoughts:

Is anyone experiencing this, and NOT using iCloud? Is anyone experiencing this and NOT have an mobile device they are syncing?

I'm curious because I backed up my MBP and iPhone 4s, then signed out of icloud and deleted all data related to iCloud I could find (contacts, calendars, notes, photo stream etc) on both devices. I tried to purge any trace of this data ever existed. On the MBP, this includes: Caches, application support, application saved state, even plists if you know what you are doing.

I then signed into iCloud on my phone, toggled what I wanted to sync, and now my iPhone and MPB are running like brand new. Very fast start up and shut down. My phone became more responsive and smooth (I forgot how fast it WAS), my MPB is loading pages faster than I can keep up. I have not re-set up iCloud on my Mac (I don't need it as much), but if you have backups, it wouldn't hurt to purge everything and start over.

That does not make any sense at all... I don't use iCloud, yet ML still startup and shut down slower than SL...

If there are some correlations over iCloud and the the speed of ML starting up and shutting down, I'm glad iCloud is never on SL...
 

blatopilot

macrumors regular
Sep 24, 2011
149
0
That does not make any sense at all... I don't use iCloud, yet ML still startup and shut down slower than SL...

If there are some correlations over iCloud and the the speed of ML starting up and shutting down, I'm glad iCloud is never on SL...

That is why I was asking if it was limited to icloud users. To assist in troubleshooting. Hopefully there is a fix soon.
 

RS2

macrumors member
Apr 4, 2011
84
17
If you have a very slow shutdown time (+20 seconds) please open the Console app and check the system launchd-shutdown logs and search for the text "timeout" to find out which processes that are causing the slow shutdown. For me the problem is the securityd daemon and the appleevents services.
 

Attachments

  • launchd-shutdown_log.png
    launchd-shutdown_log.png
    161.5 KB · Views: 561
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.