26

I noticed every time I launch a Playground in Xcode (version 9.3) a daemon starts in the background and uses more that 100% of my CPU!

I deleted Xcode's cache and its DerivedData folder but no change.

Does anyone know how to resolve this problem?

4
  • Same issue here, I've filed radar 39085132 for this. You're welcome to dupe it. Commented Apr 1, 2018 at 13:00
  • I see the same behaviour. Looks like a bug introduced in 9E145. Commented Apr 2, 2018 at 7:07
  • 1
    Same issue here, but not only with Playground. Vanilla Swift code does the same. Commented Apr 6, 2018 at 6:55
  • What about Xcode 9.3.1? Commented May 18, 2018 at 23:01

6 Answers 6

16

diagnosticd is a daemon you need to stop/kill with launchctl. The daemon you most likely need to stop has 'SimDevice' in its name. To get the exact name do:

/bin/launchctl list | grep SimDevice

Then with the appropriate name(s) (there could be more than 1) do:

/bin/launchctl stop 'name'

In my case 'name' was: com.apple.CoreSimulator.SimDevice.380EFF06-B636-49CD-851E-5DB4890641AE

If you use Playground a lot and you usually have more than 1 simulator eating your CPU run this script instead:

/bin/launchctl list | grep SimDevice | awk '{print $3}' | xargs -I %s /bin/launchctl stop %s

Oh, and dont forget to file a bug report with apple here: https://bugreport.apple.com/web/

Btw, its kinda fun to see playground/diagnosticd struggle with your code; if you create a bug or some other elaborate syntax, cpu goes up. If you clear it, cpu goes down (just a bit). Almost hilarious how Apple implemented this...

Sign up to request clarification or add additional context in comments.

6 Comments

Yeah I noticed that too - the more complex your code is the more your CPU goes up. Just submitted a bug report to Apple. Thanks Yohst for your insight!
After kill, it will automatically start again after a while without do anything. still not work.
@JerryZhou: did you do a kill from Activity Monitor or use launchctl? The latter should really stop the process. The process does indeed restart if you kill it from Activity Monitor.
@Yohst I'm wrong with that, I didn't kill it on that day. By the way, it's not above 100% cpu after latest update to macOS High Sierra 10.13.4 Update
@Yohst I've tried your solution, but this is closing the simulator completely. Is that supposed to happen as a workaround or did something change between the date of your answer and now?
|
10

As a temporary workaround, I run this script after starting up a playground to kill the rogue diagnosticd and homed processes:

#!/bin/bash
kill $(ps -ef | grep Xcode.app | egrep "diagnosticd|homed" | awk '{ print $2 }')

Edit: This seems to be a problem with iOS playgrounds only, so another (less drastic) workaround is to use a macOS playgrounds for those cases where no UIKit components are needed.

2nd Edit: This bug appears to be fixed in Xcode 9.3.1 (available via MAS or direct download from developer.apple.com)

3rd Edit: 9.3.1 doesn't fully fix this, despite what the Release Notes say. According to the comments in my bug report, this is only be fully fixed in 9.4.

1 Comment

it seems to work on Mac 10.14.4, but the daemon started again
3

Get Xcode 9.4 Beta. It resolved my issue.

killing homed is not good solution and playground is not acting correctly anyway.

Had same issue and there was no way around it. People filed bugs as far back as April 8th.

Best solution is to download Xcode 9.4 Beta from Apple Developer Page.

This worked for me and CPU usage is low and Xcode doesn't crash on playgrounds anymore.

Comments

3

I also had the same issue with Xcode v 11.2.1(11B53) It seems the issue happened after updating Mac OS and Xcode.

I found out that diagnosticd has something to do with Xcode simulators. So I tried to Erase All Content and Settings... in Simulator menu.

enter image description here

Please refer to above picture.

After erasing all content and settings the issue was resolved. :D

2 Comments

This is ridiculous
@ArthurShkil Yup. Just restart the simulator didn't fix the problem so.. I tried the erase and finally it worked!
2

This is a known bug, attributed by Apple to “over-enthusiastic logging by the MediaRemote subsystem”. There is no official workaround at this time.

See https://forums.developer.apple.com/message/305885

2 Comments

I just opened a DTS Technical Support Incident for this issue (Case ID: 689578082).
That thread does now include someone saying that the 9.4 xcode beta fixes the issue.
2

Same problem here, the only temporary solution I found was to kill 'homed', which was flooding the system with errors like

MediaRemote reply error: <error: 0x11162ed20> { count = 1, transaction: 0, voucher = 0x0, contents =
    "XPCErrorDescription" => <string: 0x11162efc8> { length = 18, contents = "Connection invalid" }
}

I suppose diagnosticd, designed to report errors automatically, simply went in overdrive mode.

That's all I have for now...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.