This is caused by the following bug in xdg-mime (part of the xdg-utils package):
https://gitlab.freedesktop.org/xdg/xdg-utils/issues/131
which, if you have any *.desktop files containing spaces, may cause xdg-mime to recurse over your entire home directory or filesystem, causing it to consume much CPU and hang. The fix is committed to xdg-utils and maintainers should package it.
While you wait, you can simply add the missing pair of quotes by editing the xdg-mime script as in the pull request:
This occurs in the function search_desktop_file(), add those quotes on line 930 in xdg-utils 1.1.3, adding quotes around $dir in the following block:
for f in "$dir"/*/; do
[ -d "$f" ] && search_desktop_file "$MIME" "$f"
done
This is the cause of many bugs for years in other apps such as Discord, which starts with a black screen and spawns a process that consumes a lot of CPU while Discord waits for it to exit:
xdg-mime query default x-scheme-handler/spotify
Maintainers, please update xdg-utils!