How to prevent mediaanalysisd from hogging the CPU in macOS

52703 105881 lede


AppleInsider may earn an affiliate commission on purchases made through links on our site.

There have been several reports of the mediaanalysisd background process causing excessive CPU usage in macOS when scanning photos. Here’s what it is, what it does, and how to stop it.

The internet has been abuzz for the past year with discussions about whether or not Apple has quietly scanned user photo libraries to submit to law enforcement. Independent tests have confirmed without a doubt that this is not the case.

However, high CPU usage has been reported by mediaanalysisd from various sources. This background processing can load your Mac CPUs and slow down your machine to varying degrees. Even in the absence of silent Apple reports, mediaanalysisd is simply scanning photo libraries for AI purposes like facial recognition and Spotlight indexing.

In any case, you might want to disable mediaanalysisd to avoid excessive CPU usage.

To do this, you must first disable macOS System Integrity Protection (SIP).

How to disable System Integrity Protection in macOS

To disable SIP in macOS, follow the instructions on Apple SIP page.

Apple cautions that disabling System Integrity Protection should only be done temporarily and should be re-enabled as soon as possible thereafter. The company also claims it can leave your computer “vulnerable to malicious code.”

Disabling SIP involves restarting the Mac in recovery mode and in the terminal by entering:

You may or may not also need to unlock the file LaunchAgents directory itself by changing the directory permissions. Just make sure you reset the permissions back to what they were when done. You can use a third party utility like BatchMod to do this:

52703 105882 batchmod

Do not change user or group permissions on the folder, only the file -rxw permissions. Make sure you return them to their original state when you’re done.

Then, remove /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist In terminal by typing:

sudo rm -R /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist

Apple’s com.apple.mediaanalysisd.plist is Launch Services demon loader which tells macOS where to find the mediaanalysisd binary and how to run it. Once you remove the com.apple.mediaanalysisd.plist, macOS will no longer launch it on startup or intermittently.

If macOS automatically regenerates the .plist file, you’ll need to edit the file directly to set the extension com.apple.mediaanalysisd.photos setting a NO. The default is YES.

Beware that editing this file may alter the behavior of your Mac or even render parts non-functional, so do so at your own risk.

You could also try changing the value of com.apple.mediaanalysisd.realtime from YES to NO. In fact, you could try disabling all but the two Homekit settings of MachServices. But again, it’s currently unclear what each of these does.

But again, note that changing these settings will disable some macOS features, namely Spotlight indexing and text selection in Photos and Preview.

You may also want to play with the Enable Transactions setting, although it’s not yet clear whether this value is what tells the daemon to use network transactions or not.

Apple’s plist files are just xml File. So if you know XML, you can use any text editor or use the one from Apple Xcode developer tool to edit them.

When editing .plist files in Xcode, you get a built-in editor that converts the XML into a table of editable fields with data types and presets for some types in the center column:

52703 106002 xcode

The .plist file also gives us a clue as to where the actual binary daemon resides on disk in macOS. Below the “ProgramArguments” field: In “Item 0” we see a value of:

/System/Library/PrivateFrameworks/MediaAnalysis.framework/Versions/A/mediaanalysisd

So the mediaanalysisd binary itself resides inside the MediaAnalysis.framework package. It is unclear what disabling this package would do, but do so at your own risk as we have not determined the impact of removing this framework from your system.

Peering into the LaunchEvents .plist

Looking into the LaunchEvents->com.apple.xpc.activity dictionary in the .plist file, let’s see some more interesting items. In fact, that dictionary contains five photo analysis entries:

  1. com.apple.mediaanalysisd.photosanalysis
  2. com.apple.mediaanalysisd.photos.visualsearch
  3. com.apple.mediaanalysisd.photos.face
  4. com.apple.mediaanalysisd.photos.maintenance
  5. com.apple.mediaanalysisd.photos.ocr

XP extension (sometimes called IPC) is Apple’s interprocess communication technology by which applications can communicate with each other via XPC services, even across networks.

The com.apple.mediaanalysisd.photos.ocr activity is obviously used to convert the words in the images to text, both for selection and for Spotlight.

But the full extent of what com.apple.mediaanalysisd.photosanalysis and com.apple.mediaanalysisd.photos.maintenance are doing is still unknown.

The “ExpectedDuration” field of each com.apple.xpc.activity element is the activity execution time in seconds. So “3600” would be 60 minutes – one hour.

The “Priority” and “CPUIntensive” fields are also interesting. It’s unclear what setting the CPUIntensive field to NO would do to system performance, and there’s scant Apple documentation on it.

The “Interval” field is the time between the process starts, even in a few seconds. In the case of com.apple.mediaanalysisd.photosanalysis, this is set to 7200, which means 120 minutes.

The Interval field for the com.apple.mediaanalysisd.photos.maintenance service is set to 86400 by default, which means it runs once every 24 hours.

There are also fields to report if an activity repeats, if it runs during screensavers, and if it runs during PowerNap.

Final considerations and additional information

Most of the macOS daemon architecture is handled by a background daemon called launched which handles starting, running and closing daemons. You can learn more about launchd in Terminal using the man page:

man launchd and pressing Return.

There is another Terminal command, launchctl, which interfaces with launchd to control daemons and background processes. It too has a man page for usage and more information.

In Terminal you can also view all running processes (apps and daemons) on your Mac by typing the superior command:

An easier and cleaner way is to use Apple’s /Applications/Utilities/Activity Monitor app. Typing “media” into its search field will reveal the use of mediaanalysisd:

52703 106003 act mon

If you double-click on a process name in Activity Monitor, you will get a window with more detailed information about the process:

52703 106004 act mon2

Under the Open files and doors tab we can also see more about where mediaanalysisd is interacting with the filesystem. We also see that it uses several other Apple frameworks:

  1. CoreNLP.framework
  2. DataDetectorsCore.framework
  3. Lexicon.framework
  4. MetalPerformanceShaders.framework

We also learn from this log that there is another mysterious Apple daemon in the system: analyticsd. There is an analyticsd man page, but it has little information and just says it is used for “diagnostics”.