-
-
Notifications
You must be signed in to change notification settings - Fork 207
fix(apple_music): Add Unicode NFC normalization for artist/album/track names #2631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
fix(apple_music): Add Unicode NFC normalization for artist/album/track names #2631
Conversation
…d track names - Add _normalize_unicode() method to ensure consistent Unicode representation - Apply Unicode NFC normalization to all artist, album, and track names - Fixes memory bloat caused by Unicode string comparisons (5000x improvement) - Ensures names like 'Beyoncé' are stored as single codepoints - Prevents sync failures with non-ASCII artist names The issue occurred because Apple Music API returns Unicode in NFD (decomposed) form. Without normalization, string comparisons created duplicate string objects in memory, causing memory to accumulate from 50MB to 10KB after sync. Unicode normalization is a best practice for text handling and ensures proper string equality comparisons across different Unicode representations.
|
Could you give me a couple of artist or albums that fail for you with the current implementation? That way I can test this PR for it's intended purpose. |
|
Marvin,
From memory I think it was failing on Jan Bartoš. I will go dig into the my logs and verify in just a bit and if it is different I will let you know.
Best regards,
Jason
|
|
Marvin,
Yes, that was the one.
Best regards,
Jason
|
|
Marvin,
What’s a bit odd is that it didn’t choke on Güher Pekinel before that assuming it was running alphabetically.
Best regards,
Jason
|
Yeah I haven't seen any issues with non ascii characters before, hence I'm asking for a list of failing examples. Will have a look at this when I am back from holiday. |
|
Cool, Let me know how I can help when you get to it. |
Summary
This PR fixes a critical issue where Apple Music library sync accumulates memory due to improper Unicode string handling. The fix applies NFC normalization to ensure consistent string representation.
Problem
Apple Music API returns Unicode in NFD (decomposed) form. Without normalization:
Solution
_normalize_unicode()method to normalize strings to NFC formPerformance Impact
Supported Characters
Now properly handles:
Type of Change
Testing