DEV Community

Controlling photoanalysisd

Guy Bianco IV on August 14, 2018

Background I recently bought a new MacBook. This article gets better, I promise. I decided to set it up fresh instead of restoring from...
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

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

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

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
 
ethanholman profile image
Ethan Holman

If you don't use the Photos app on your Mac, I have found a possible solution. Delete the albums used by Photos app -- open finder and navigate to wherever your Photos album is stored (for me in ~/Pictures).

After deleting these albums, the Photos app will no longer launch correctly (complaining about not being able to find the albums file). Upon doing this, the photoanalysisd process immediately stopped!

Collapse
 
naryfa profile image
naryfa • Edited

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
 
n13 profile image
Nikolaus

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
 
johnstonesnow profile image
johnstonesnow

I am SO sick of Apple. I have the same issue, nearly making my machine totally unusable. photoanalysisd and photolibraryd constantly running. If I kill the process in Activity Monitor it just comes back, and seems to want to punish me for killing it by using EVEN MORE CPU!! I don't understand much code, are the commands given above ready to use "as is", or do we need to insert our own info somewhere, such as username?
Thanks, would be so cool if I could get this working for me!

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

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

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
 
atalantia profile image
Atalantia • Edited

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
 
n13 profile image
Nikolaus • Edited

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
 
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
 
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
Nikolaus

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

Collapse
 
hrvstr profile image
hrvstr

Does any of this work on Big Sur? I am trying multiple approaches and can't get this annoying daemon from spinning up my HDD a couple of times a day.

I tried disabling, stopping, and killing the daemon via launchctl (both GUI and service) and creating an empty library on my SSD.

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.