loading...

Controlling photoanalysisd

gjbianco profile image Guy Bianco IV Updated on ・4 min read

Background

I recently bought a new MacBook. This article gets better, I promise.

I decided to set it up fresh instead of restoring from a backup. I like to take the time to try and simplify what I've got on my machine.

Naturally, I expect most applications to take a little bit to sync down settings, files, etc. All of Apple's stuff in particular has a lot to do and I'm fine with that. However, the one I am not so fine with is Photos.

Specifically, a process called photoanalysisd.

This is a background service that, as the name implies, is responsible for analyzing your photos. For the most part, it seems like it is trying to recognize people. This service is directly tied to the "People" tab in Photos (more on this in a moment).

The fact that this happens on your machine and each of your machines is a good thing! There may be some things that get sent off to Apple, but the majority of the work seems to be happening on your hardware.

What is not so good is the level of control you have around if/when/how this service is controlled. Or, in this case, how it seems to control your machine.

If you go into the People tab of Photos before it is done analyzing, you will see its progress. Even if you have a fairly beefy machine, this process takes a long time. Weeks kind of long time. The only exception seems to be if you have a photo library barely into or lower than quadruple digits.

On the surface, this shouldn't be an issue. The sorts of analysis its doing is probably computationally intense. It uses a good amount of resources, but doesn't try to fully harness the machine since it is meant to be a background process that occurs over the course of days.

The main issue seems to be that you have no control over this process. I never plan to use the People tab, yet my machine still has to painstakingly go through my entire library. I have a medium size photo library (~10k) and after a few hours on the 12" i5 MacBook, it has managed to go through almost 300 of them. Many people complain about their way more powerful iMacs taking weeks to go through libraries of similar size.

During this process, the machine is still usable, but it doesn't go unnoticed. It does use about 25% of the CPUs constantly. This causes the fanless machine to constantly stay pretty warm and chug on some things. Usually not enough to notice, but seems like it might cause someone to be less than impressed with their brand new device if they didn't know this was going on.

On top of that, it is almost impossible for a normal user to learn this is going on. The only mention of "photoanalysisd" is in Activity Monitor. This should not be the only location to learn about something that is using days of CPU time. For a feature I imagine a lot of people either don't want or don't care about having on every device with Photos.

Yet it gets worse.

There are seemingly very few ways to actually get it to stop or even pause. Supposedly, it only runs when a) the machine is plugged in and b) Photos isn't running. This means that people that want it to pause so they can get CPU cycles back resort to running off battery unnecessarily or leaving Photos open for no reason. Even leaving Photos minimized makes it start up again. However, mine still runs even with Photos focused, so I guess it doesn't really matter.

You can also just let it finish, but this takes quite a long time (well after their 14 day return policy is up). It also seems like it gets stuck for some people, never finishing.

You can use launchctl to disable and kill the service. However, you have to make sure to disable all the appropriate services, otherwise this is only a temporary reprieve.

Per user Gordan Aspin (https://dev.to/gordonaspin):

you do disable it but only in the gui context which is created every time the user logs in and why it keeps be “re-enabled”. Your disable is only for the current GUI login.

You also should be able to (re)move the service file, but that may or may not affect system stability. Not something I really want to try, personally. YMMV.

How to actually do it

To do this, you'll need to open up Terminal and run a couple of commands. Any time you're asked to copy and paste commands into your terminal, it's a good idea to at least have at least a basic understanding of what the commands are actually doing to your system.

The following commands are really 4 command. The && basically means "run the first one (on the left) and if that's successful, run the second one (on the right). launchctl is the command that is used to control system services in macOS.

First, you'll disable and kill the GUI instance:

launchctl disable gui/$UID/com.apple.photoanalysisd && launchctl kill -TERM gui/$UID/com.apple.photoanalysisd

As well as the actual service:

launchctl disable user/$UID/com.apple.photoanalysisd && launchctl kill -TERM user/$UID/com.apple.photoanalysisd

Closing Thoughts

First off, if anybody from the Photos team somehow ends up reading this, I'm begging you to give us an off switch for the People tab. I don't use it, I don't plan to use it, and it is a huge waste of resources.

Discussion

pic
Editor guide
Collapse
gordonaspin profile image
Gordon Aspin

I think a more permanent solution is to disable the photoanalysisd service entirely. The service runs in the launchd user domain, so to disable it:

launchctl disable user/$(id -u)/com.apple.photoanalysisd

and re-enable:
launchctl enable user/$(id -u)/com.apple.photoanalysisd

and to check disabled status look at the JSON "disabled services" output of:
launchctl print user/$(id -u)

Even more simply, you could find and delete (or move) its plist file:
sudo mv /System/Library/LaunchAgents/com.apple.photoanalysisd.plist

Collapse
gjbianco profile image
Guy Bianco IV Author

If you look again, I actually do disable it as part of the cron. The problem is that something in the OS re-enables that service every so often. Running it once is not actually permanent.

Removing the plist should also work, but I didn't want to (re)move anything tied into the system.

Collapse
gordonaspin profile image
Gordon Aspin

I missed that, you do disable it but only in the gui context which is created every time the user logs in and why it keeps be “re-enabled”. Your disable is only for the current GUI login. The OS is behaving as designed.

If you disable it in the user context, it will never be started again. Once and done :)

launchctl disable user/$(id -u)/com.apple.photoanalysisd

Thread Thread
gjbianco profile image
Guy Bianco IV Author

That's quite a bit nicer! Testing it out currently and will update the article once I'm satisfied it worked (not that I doubt you, just want to make sure).

Thread Thread
santafearttweet profile image
incidental intention

Hi Guy,
all this code stuff is unknown to me. I was using a command in Terminal to stop photoanalysisd that I found somewhere. It only works temporary and photoanalyssid take up over 90% of my CPU per activity monitor. Could you please give me instructions where I enter: launchctl disable user/$(id -u)/com.apple.photoanalysisd
I am not fmailiar with any of these procedurea and do not understand code at all. Is there a way to guide me through this in a simple way?
Thanks, Walter

Thread Thread
gjbianco profile image
Guy Bianco IV Author

I've updated the article to reflect the advice from Gordon. You should be able to run the commands provided in Terminal like you've been doing. You should only have to run them once, however! Hope this helps :)

Thread Thread
santafearttweet profile image
incidental intention

Thank you very much.
I'll try this.
Sorry, I had a lot of typos in my previous post!
Thanks

Collapse
tom79 profile image
Tom Williamson

Having failed to get the launchctl disable method to work in macOS 10.15.4, I have found a pretty neat alternative which works perfectly. In addition to photoanalysisd, there are three other agents that can be disabled assuming you don't use Apple Photos.

SIP must be disabled before running these commands but can be enabled again afterwards if so desired.

This method has the advantage of leaving all files on the system and they can easily be restored if required.

To disable :

sudo mount -uw /
sudo mv -v /System/Library/LaunchAgents/com.apple.cloudphotod.plist /System/Library/LaunchAgentsIgnored/
sudo mv -v /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist /System/Library/LaunchAgentsIgnored/
sudo mv -v /System/Library/LaunchAgents/com.apple.photoanalysisd.plist /System/Library/LaunchAgentsIgnored/
sudo mv -v /System/Library/LaunchAgents/com.apple.photolibraryd.plist /System/Library/LaunchAgentsIgnored/

To enable :

sudo mount -uw /
sudo mv -v /System/Library/LaunchAgentsIgnored/com.apple.cloudphotod.plist /System/Library/LaunchAgents/
sudo mv -v /System/Library/LaunchAgentsIgnored/com.apple.mediaanalysisd.plist /System/Library/LaunchAgents/
sudo mv -v /System/Library/LaunchAgentsIgnored/com.apple.photoanalysisd.plist /System/Library/LaunchAgents/
sudo mv -v /System/Library/LaunchAgentsIgnored/com.apple.photolibraryd.plist /System/Library/LaunchAgents/

Collapse
naryfa profile image
naryfa

I've been pulling my hair to figure this out with Amazon Music Helper. Launchctl disable user/$UID/username/Library/LaunchAgents/com.some.service.plist just doesn't do anything. I know there are three domains (system, gui and user). But it's not yielding anything no matter how I try it.

Your way of doing it will work for some apps, but not for others. For example Amazon Music Helper will be recreated the moment you move it.

The only solution I found was to edit the ~/Library/LaunchAgents/com.amazon.music.plist file itself by setting:

<key>KeepAlive</key>
<false/>

<key>RunAtLoad</key>
<false/>

Then saving the file and locking it by:

sudo chflags uchg ~/Library/LaunchAgents/com.amazon.music.plist

(to unlock back swap uchg for nouchg)

However, I still want to know how to properly disable the service since there are others that I want disabled as well. It must be doable by hand somehow!


Edit:

It seems to be enough to amend the plist file at the beginning with:

<key>Disabled</key>
</true>

I guess locking the file afterwards won't hurt.

Collapse
hangingtentco profile image
Hanging Tent Company

Just to add; this is brilliant btw, it really works, In order for this to work it seems that you need to quit photoanalysisd once manually using activity monitor or launchctl disable user/$(id -u)/com.apple.photoanalysisd. thanks

Collapse
ddorejuela profile image
ddorejuela

Do I have to disable SIP to get these commands to work?

I get:

sudo rm com.apple.photoanalysisd.plist
Password:
override rw-r--r-- root/wheel restricted,compressed for com.apple.photoanalysisd.plist? y
rm: com.apple.photoanalysisd.plist: Operation not permitted

Collapse
maxdiluca profile image
Massimiliano Di Luca

In Photos general preferences, disable "show memories notifications" and the problem is solved

Collapse
jaiment profile image
Jaime Navarrete

As Francesco said, I've unchecked "show memories notifications" several times but it does not save changes.
Still struggling with photoanalysisd on Catalina ... tried almost everything.
Any updates with macOS Catalina?

Collapse
leobartowski95 profile image
Francesco D'Angelo

I've unckecked that option and after 3 seconds re-opened Photos and it was still checked. WTF

Collapse
n13 profile image
Nik

This is great, thank you. I hope it works long term. I've renamed by photo library as well - this must be one of the most annoying features in OS X. I also don't use Photos, but I have a lot of photos stored in it which I don't want to lose, and I don't want to give google all my photos... so I am stuck with it.

I have previously tried to "just let it run" until done, but that takes literally many days, and I don't have so much downtime for my computer. In addition, there seem to be bugs where it does run forever.

Collapse
n13 profile image
Nik

Edited: The final solution

Shut down Photos
Hold down option key while tapping on Photos in the Dock -> This brings up the option of choosing a library, or creating a new one!
Create a new library, call it "Empty Photos Library"

Done. Keep the original library around and switch back to it using the same system in case you need it.

I even tried deleting the Photos app - turns out that is impossible. Photos is basically the Adobe Acrobat of 2019. A horrible POS that installs itself like a Kraken into your system, impossible to remove.

Nothing else worked for me in OS X Catalina.

Collapse
atalantia profile image
Atalantia

Spyware is never meant to switch of. I disabled System Integrity Protection and switched of the daemon in SystemAgents.
But the process spied out 740 photos already. I would like to delete this data file but I don't know where it is.

Collapse
dunhamgithub profile image
DunhamGitHub

Hi. Updated to MacOS Catalina (Photos Version 5.0...)
Would be great if you updated your solution, it does not seem to work anymore.

Collapse
gjbianco profile image
Guy Bianco IV Author

I haven't updated yet, so I can't test it out.

Is it still actually running and using CPU in the background for this? Is there a way to turn it off from their settings?

Which method did you try? The current one or the cron-based one?

Sorry for all of the questions, but it's possible with the major update to Photos that they changed if/how the process works.

Collapse
dunhamgithub profile image
DunhamGitHub

Yeah it is a) still running and b) still using CPU (20-25%)

  • I even tried entering the cronjobs in terminal directly to see if it quits. No chance.

I have now simply removed the following files but I am 100% sure the next update will bring them back:

  • com.apple.photoanalysisd.plist file in /System/Library/LaunchAgents
  • photoanalysisd in /Sytem/Library/PrivateFrameworks/Photo.../Versions/A/Support
Thread Thread
gjbianco profile image
Guy Bianco IV Author

Interesting. So it looks like the service is still called the same thing. I'm wondering if you go back to the old way I listed (using a cron job to kill the service every 20 minutes) would work. Kind of a jackhammer, but should still work. Maybe need to have it run more often :/

Sounds like I get to play around with it once I upgrade :)

Thread Thread
dunhamgithub profile image
DunhamGitHub

Hmmm - I assume it's still called the same yes, but again, somehow the command won't kill nor stop it.

This is what I have been using since before Mojave and now has stopped working as cron:

/1 * * * * launchctl disable gui/501/com.apple.photoanalysisd && launchctl kill -TERM gui/501/com.apple.photoanalysisd

My current solution is even worse -> deleting the system plist and unix exe:)

Collapse
odechelette61 profile image
Olivier DECHELETTE

The easiest way to solve this issue is to move the Photo folder to an external disc and remove it from the Macintosh HD SSD or hard drive.
Works great for me.

Cheers!
Olivier.

Collapse
n13 profile image
Nik

I renamed the file - but just now in Catalina, this seemed to no longer work.

Collapse
n8vision profile image
n8vision

Thank you. Unfortunately, despite endless complaints from the community about this in the past few years, no change to Apples stance in Mojave...

Yay for cron.