Xcode 9.2 (9C40b): Xcode sometimes gets stuck using 600% CPU

Number:rdar://38037155 Date Originated:01-Mar-2018 03:51 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 9.2 (9C40b) on macOS 10.13.3 (17D102)
Classification:Power Reproducible:Sometimes
I don’t know what causes this, but every once in a while (maybe once a week), I’ll notice the fans running on my MacBook Pro, and Activity Monitor shows that Xcode is hovering right around 600% CPU (almost like it’s trying to use as much CPU as possible, but something is limiting it to use no more than 3/4 of the virtual cores on my 4-core, Hyperthreaded machine).

Restarting Xcode or the computer sometimes works, maybe. Clearing derived data and/or module cache sometimes works, maybe.

Attached sysdiagnose captured while this behavior was happening.

Steps to Reproduce:
1. Use Xcode a lot.

Expected Results:
Fans run during heavy load, like repeatedly building a project.

Actual Results:
Fans also run when Xcode is just sitting there.

Xcode 9.2 (9C40b) on macOS 10.13.3 (17D102)

Sorry I can’t provide more detail! Also, I don’t know whether I’ve seen this in Xcode 9.3, since I haven’t been using it full time yet. If I do happen to see this behavior, I’ll attach a new sysdiagnose.


My reply

In fact, I do have such a breakpoint! It breaks on UIViewAlertForUnsatisfiableConstraints and passes this:

@(NSString *)[(id)$arg2 description]@

to this script:

!/usr/bin/env python

import sys import subprocess import urllib

input = ", ".join(sys.argv[1:]).decode('string_escape') stripped_input = input.rstrip('"').lstrip('@"') quoted_log = urllib.quote(stripped_input)

url = 'http://wtfautolayout.com/?constraintlog=%s' % quoted_log subprocess.call(['open', url])

call with these parameters:

@(NSString *)[(id)$arg2 description]@

It's a utility that Harlan Haskins and I cooked up to open wtfautolayout.com when you hit an Auto Layout conflict. But I disabled all my breakpoints, and nothing changed. The CPU of Xcode is still hovering around 400%. I'm attaching another syasdiagnose with all breakpoints disabled in case it helps.

I also have Facebook's chisel installed: https://github.com/facebook/chisel

It's a set of lldb utilities, and it's activated via this in ~/.lldbinit: command script import /usr/local/opt/chisel/libexec/fblldb.py

So maybe that's to blame? Not sure. Hope this helps!

Apple Developer Relations

Xcode has several threads doing a bunch of work in a shell breakpoint action. We can't tell from the spindump what those shell actions might be executing. Can you see if you have any breakpoints with actions, and if disabling them works around this issue? Maybe you are autocontinuing and hitting more often than you expect?

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!