iOS 15 Simulator's Spotlight process consistently uses ~100% of CPU. Any ideas for mitigation?

I've noticed that the iOS 15 simulator's Spotlight process hovers around 100% of (the Mac's) CPU pretty consistently. Since SwiftUI previews spin and keep simulator instances around aplenty, this pretty quickly adds up to an unusable development setup.

Somehow this only got my attention after working against iOS 15 simulators for close to two weeks, so I am wondering if it might be a corruption known to occur, similar to what happens to Spotlight on the Mac occasionally and requires a forced re-index. That said, spinning up a blank slate simulator doesn't seem to fix the issue, which points more to a bug in the beta. Any ideas for steps to try?

Filed as FB9196320

Answered by pi80223 in 682047022

As I haven't found a way to edit my first answer above: I have found a solution to fix the SwiftUI Preview simulators

  • Find all com.apple.suggestions.plist files in ~/Library/Developer/Xcode/UserData/Previews/Simulator Devices/
  • Set the key SuggestionsAppLibraryEnabled to NO

The following script does the job nicely:

cd ~/Library/Developer/Xcode/UserData/Previews/Simulator\ Devices/

find . -name com.apple.suggestions.plist -exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} ";" 

 


 

This approach also works for regular Simulator instances.
Instead of opening "Settings" and disabling "Suggestions on Home Screen", you can use below script to do the job:

cd ~/Library/Developer/CoreSimulator/Devices 

find . -name com.apple.suggestions.plist -exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} ";" 

Hi Alex

I'm also annoyed by this bug and filed a feedback >2 weeks ago (FB9208491). Today I went to tracking down the problem and even found a doable workaround (later more on this).

First, the Spotlight process is spilling a lot of warnings to the log. You can check the "Console" app and see the logs for your simulator device: Thousands of "No system placeholder found with identifier ...".
It seems that Spotlight is stuck in some strange loop, trying to find some placeholders and generating logs. One way to resolve this: Kill the Spotlight process in Activity Monitor.

But whenever Spotlight is triggered in the Simulator, it will start again. Also when you restart the simulator instance, this will start again. Therefore I tracked down the root cause for the error and found it in "Siri suggestions":

  • It seems that for an unknown reason, Siri suggests on Simulator devices the use of "Mail" and "Tips" app. But those apps do not exist in the Simulator environment! Therefore Spotlight cannot find the apps icon...

So the real workaround which works for me:

  1. Go to "Settings" > "Siri & Search"
  2. Disable anything related to "Siri suggestions".
  3. Restart the device

After restarting, the Spotlight search can be triggered without any issue. No more CPU cycles wasted to logging about missing placeholders.

I filed this as a new feedback (FB9335101) to Apple, in the hope somebody fixes it soon.

One caveat: It is not possible to apply this workaround for the Simulator devices used by SwiftUI previews.

So if you use SwiftUI previews, you will have to stop/kill the Spotlight process yourself using the Activity Monitor app.

If somebody finds a solution to configure the SwiftUI Preview simulator instances (which can be found ~/Library/Developer/Xcode/UserData/Previews/Simulator Devices) I would gladly learn about it.

Kind regards
Philipp

Accepted Answer

As I haven't found a way to edit my first answer above: I have found a solution to fix the SwiftUI Preview simulators

  • Find all com.apple.suggestions.plist files in ~/Library/Developer/Xcode/UserData/Previews/Simulator Devices/
  • Set the key SuggestionsAppLibraryEnabled to NO

The following script does the job nicely:

cd ~/Library/Developer/Xcode/UserData/Previews/Simulator\ Devices/

find . -name com.apple.suggestions.plist -exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} ";" 

 


 

This approach also works for regular Simulator instances.
Instead of opening "Settings" and disabling "Suggestions on Home Screen", you can use below script to do the job:

cd ~/Library/Developer/CoreSimulator/Devices 

find . -name com.apple.suggestions.plist -exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} ";" 
53

Hey Philipp,

Thanks so much for this very thorough investigation. Can confirm that this issue persists in Beta 3 and that your scripts above eliminate the issue for both categories of simulators. I had toggled those switches off in the standalone simulators but somehow expected an immediate result rather than one after a restart. So I thought it wasn't effective. But upon checking after your post, it does seem like simply toggling and restarting also does the trick (for anyone reading this who doesn't want to mess with their simulator search preferences, I guess).

Thanks again!

Updated to new XCode 13.1 and still the same problem.

I confirm the problem is still there in 13.1 (hopefully the hack/fix is still working).

The fix worked for me. Have to keep doing it for new installations and updates.

I must say I am disappointed Apple has not fixed this when shipping Xcode 13.1 Fix was confirmed three months ago and Xcode 13.1 was shipped when?

Thanks! It worked, steps as below:

1/ disabled Siri related settings

2/ replace setting

cd ~/Library/Developer/CoreSimulator/Devices find . -name com.apple.suggestions.plist -exec plutil -replace SuggestionsAppLibraryEnabled -bool NO {} ";"

3/ kill Spotlight Process in Activity Monitor 4/ restart simulator -> not all cores on my M1 are used now! temperature drops from 6x to 4x!

I thought Xcode is optimised but i guess we'll have to monitor any release from A. Team then! :)

On Xcode 13.1 tried the above scripts. It didn't stop Spotlight when running SwiftUI in a Playground.

If you want to modify the configuration of the simulator instance used by Xcode Playgrounds you have to switch to the ~/Library/Developer/XCPGDevices directory before executing the find command above.

Basically there are at the moment three locations where Xcode is storing simulator related container data:

  • Regular Simulators (created within Xcode's "Devices & Simulators" window): ~/Library/Developer/CoreSimulator/Devices

  • Preview Simulators (automatically created based on the currently selected device): ~/Library/Developer/Xcode/UserData/Previews/Simulator Devices

  • Playgrounds: ~/Library/Developer/XCPGDevices

All of those locations can also be accessed through the command line utility xcrun simctl by specifying the --set <PATH> argument

Crazy, but this still seems to be an issue. Even on Xcode 13.3.1. My simulator is running with 90-100% even though its doing NOTHING.

iOS 15 Simulator's Spotlight process consistently uses ~100% of CPU. Any ideas for mitigation?
 
 
Q