Page 1 of 1

[SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Mon Feb 03, 2020 3:04 pm
by MadMax1998
I started a new thread to provide my findings so anyone who has this problem can easily find the solution here!

This problem was discussed in this and this thread. Shanee mentioned it could be related to sleep and power management. This is true in some situations [German link] but since sleep (AFAIK) is not working with Catalina on AMD systems, it should be disabled by default through NullCPUPowerManagement.kext and you should also turn off automatic sleep in Catalina's power saver options.

The cause of the freezing/crashing (kernel panic) is the daemon mediaanalysisd which attempts to curate any videos in your photo library, assuming you have one. So users that a) don't have a photo library or b) don't have videos in it should NOT be affected by the issue. Some people have theorized that the issue might only appear on certain video cards, most likely Navi cards (because of buggy drivers).

The issue can be tracked down as follows:

1) Remove the photo library from "Pictures" by moving it to the trash (do not empty the trash). The system will be stable.
2) Put the library back, open Activity Monitor and sort by CPU load. Wait five to ten minutes and when the system freezes, mediaanalysisd will be at the top of the process list.
3) Disabling/deleting mediaanalysisd stops the freezes from occurring.

Source to confirm this problem has existed since Sierra. This thread also describes that simply disabling the daemon with a Terminal command will likely fail:
Code: Select all
sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist 
/System/Library/LaunchAgents/com.apple.mediaanalysisd.plist: Could not find specified service

The thread suggests to delete the plist file instead of disabling it. I did that (backing it up first!) and rebooted, but the daemon STILL launched after idling. So the plist file is not the trigger in this situation. My guess is that photoanalysisd or photolibraryd are controlling the start of mediaanalysisd.

SOLUTION

I ended up outright removing mediaanalysisd which completely fixed the problem. This is not very elegant but it does work! As always, BACK UP the file you are deleting in case it's needed in future!

You can run these Terminal commands to automate the process. The first command is required since you need write access to the Catalina system files. The following commands remove mediaanalysisd and its plist file after backing them up to your desktop.
DO THIS AT YOUR OWN RISK! I'm not liable for any damage you do to your Catalina installation. Use common sense!
Code: Select all
sudo mount -uw /
sudo cp /System/Library/PrivateFrameworks/VideoProcessing.framework/Versions/A/mediaanalysisd ~/Desktop
sudo rm /System/Library/PrivateFrameworks/VideoProcessing.framework/Versions/A/mediaanalysisd
sudo cp /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist ~/Desktop
sudo rm /System/Library/LaunchAgents/com.apple.mediaanalysisd.plist

Feedback is appreciated in this thread. If anyone wants to add info, I'd be interested in what triggers mediaanalysisd so the trigger can be removed. I hope this solution proves useful to those having the problem.

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Sun Feb 16, 2020 5:54 pm
by Marco Ledri
I got this issue even without a photo library. I’ll try the solution you suggest and let you know.
Post Merged
I tried this solution now and I can confirm it fixes the problem. My hack has been running now inactive for a couple of hours with no freezing or panics. Thanks for the tip!

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Wed Feb 19, 2020 11:54 pm
by mikigal
I had same issue on Vega 64, macOS 10.15.3 with working sleep. Logs from my Kernel Panic: https://pastebin.com/vaNwb56R
I fixed it by setting monitors sleep to 5 minutes (maybe it can be longer, I didn't tried), without removing any system files. I have photos in Library.
If you manually disable monitors, it works too. When you watch film (I guess due to non-static screen) it doesn't freeze.
I'm using Dummy Power Management quirk now.
I left my hackintosh without sleep at night, tomorrow everything worked :)
Zrzut ekranu 2020-02-20 o 00.53.56.png
Zrzut ekranu 2020-02-20 o 00.53.56.png (46.98 KiB) Viewed 1764 times

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Thu Mar 05, 2020 6:11 pm
by vint
Many thanks ! I had been trying to fix freezes issue for 3 days, and I have no idea that it was cause by photo library. ( my library is around 50GB)..
I put it into trash, and confirm that the problem is gone.
I tried to remove mediaanalysisd and its plist file, but..:

~ % sudo mount -uw /
Password:
mount_apfs: volume could not be mounted: Operation not permitted
mount: / failed with 77

I failed to delete it in terminal or by manually; it was protected. Can you help with it?

Now I move that 50GB photo library to HD, and create an empty library in SSD as primary photo library. and keep it in trash... :D (Just in case..)
Post Merged
notice that, Photo.app:

Curation Completed
Photos and videos are curated when your device is connected to power

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Wed Mar 11, 2020 7:39 pm
by bjar
disable SIP

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Fri Mar 13, 2020 10:38 am
by vint
many thanks, yes, I figured out SIP.

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Mon Mar 23, 2020 7:10 pm
by 3pod
Do we know what "mediaanalysisd" actually does?
Post Merged
Hi, I found this post viewtopic.php?f=61&t=9619#p52731 and I just tried setting my SMBIOS to iMac19,1 and it seems to have solved this issue. Going to test it more today.

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Sun Mar 29, 2020 1:49 pm
by MadMax1998
3pod wrote:Do we know what "mediaanalysisd" actually does?
I think it analyses videos in the photo library. It can still run after curation of the library is shown as "completed".

Re: [SOLUTION] Catalina freezes/crashes after minutes of inactivity

Posted: Sun Mar 29, 2020 5:26 pm
by Alpine
With Catalina 10.15.4 this seems to be fixed.