Apple Intelligence is now available on iPhone, iPad, and Mac!

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Music hangs on Saving Music Library

This question has been posted before many times and never successfully answered. This is specific to Music.app with local files. Apple Music is turned off.


For context, my old iMac running Catalina with Music 1.0.6.10 has no problem with my music library which has about 275,000 tracks in it. (I work in radio so I have a lot of music).


This problem crops up when I try and restore/convert the Music to a new machine running Ventura.


Music seemingly hangs on quitting, showing "Saving music library..." for a very long time or forever. I've lost track after 24 hours and then force quit it. However, I find that when it's force quit, when it opens again, it has lost the location of my files.


If I get info on a song, I can see the path where it thinks the file is. But if I look on the disk, that file doesn't exist, BUT there is a file with the same name with the track number preceding it. So "Keep Organized" has updated the file name to include the track number, but the iTunes database didn't get saved after updating.


Songs that didn't have a track number in their info field are still found.


I've repeated this many times by restoring backups and trying again.


When I let the "Saving music library..." box do it's thing after 10 hours, I go and look at modification times for the files inside ~/Music/Music/Music\ Library.musiclibrary nothing has been updated.


This leads me to think it's a bug in the code that's causing this hang, and that it's related to "Keep Library Organized" and for some reason, the Music database isn't getting updated.

Posted on Jan 17, 2023 5:09 PM

Reply

Similar questions

20 replies

Feb 8, 2023 4:47 PM in response to Rusty SomaFM

Here's an update on the slow progress I've been making.


As an experiment, I exported the library to an XML file and I made a clone of the original Media Library folder on an external SSD. I then edited the Library.xml file so the path pointed to the external volume*; created a new blank music library on Ventura, and imported that XML into it. It kind of worked, but indicated it got some errors.


*Before I imported it, I opened it with Bbedit to edit the path. Bbedit gave me an alert about malformed UTF-8. Which I just ignored, but turns out it was significant.


I used 'xmllint' to look for issues. Sure enough, there were a couple files that had invalid UTF-8 in their metadata. xmllint tells you the line number of the offending data, I then scrolled to that line in Bbedit and scrolled back a few lines to determine the track / artist with the issue. I then went into Music.app and edited the Metadata (with Song -> Info) and either removed the offending field (2 were in Genre, the other in the track filename).


I exported the library again, and this time xmllint showed the file was valid.


Great! Although it's still taking forever to load into the new instance, so I don't know if it truly works. But the bad unicode may be what was crashing it when it goes to save the library. I'll keep you posted.

Feb 9, 2023 5:44 PM in response to myalterego

Here's some comments I got from jwz (.org), who had done some open source tools working with the iTunes library file:


"HFS+ would normalize Unicode characters in pathnames using the NFKD form, but APFS does not normalize at all (arbitrary bytes are allowed) and I believe that iTunes/Music.app normalizes using the NFKC form prior to writing to APFS. So depending on when and where that file was first "kept organized", it might be encoded differently, and you can end up with two different files that are equivalent Unicode strings once normalized."


This might explain issues moving to to a NAS as well.

Feb 9, 2023 11:20 PM in response to Rusty SomaFM

Here's an interesting datapoint. I just started with a blank library on the Ventura machine, and manually dragged all the files into a new, blank library. 270k files. Took a while but eventually loaded. Spot checked them, the seemed to all be there.


Then I quit music.


The "Saving Library" dialog came up for about 15 minutes and then the app exited normally.


Except the library file wasn't updated.


And when reopening it, nothing was there.


It failed silently. I'm trying again, bringing about 1/4the of the library at a time, and will report back on how that goes. I'm not sure if it's something in the metadata of one of the tracks, or the size of the library.


I did experiment with bringing in just a few thousand tracks and that saved properly and was there when reopening.

Music hangs on Saving Music Library

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.