jacquesh / foo_openlyrics

An open-source lyric display panel for foobar2000
MIT License
401 stars 24 forks source link

High cpu usage on some lyrics #276

Open strider16 opened 1 year ago

strider16 commented 1 year ago

Sometimes openlyrics loads lyrics, but for some reason it makes foobar take a higher cpu% than usual. A system running foobar should take no more than 2%,, but when the issue happens, it takes around 10%.

Steps to reproduce

  1. load an mp3 file
  2. let openlyrics find and show lyrics

Expected behavior

It keeping a constant low cpu usage %

Versions

Additional information

The cpu usage % goes low if the foobar is completely minimized. If it is on screen, or even if there's a maximized window from other program, foobar still have ~10% cpu usage until it goes to the next song, and it loads normally. I still don't have a complete rule for this to happen, but it happened, for example, in a song which loaded an incorrect lyric due to wrong tagging. Once I corrected the tag and it loaded the correct lyric, the cpu usage went low. In this case, it was a song with Japanese lyrics, unsynced. I have many other files with these same features and no problem.

jacquesh commented 1 year ago

I expect the most likely explanation would be that it's hitting some particularly bad case for rendering the lyrics, but without more info and/or a reproduction of the issue it's very hard to tell with any degree of certainty. I'm guessing "around 10%" is either ~8% (on a 12-core machine) or ~12% (on an 8-core machine). Do you know how many CPU cores your machine has?

If you manage to come up with a reproduction or a characterisation of the tracks/lyrics that cause the problem then that'd obviously be amazing. If you do manage to reproduce the issue then it'd be really helpful if you could collect & post some debug console output too (in case openlyrics is getting stuck loading/rendering the lyrics or something).

DanteDraconi commented 6 months ago

Same thing here, 8C/16T CPU but only a single thread spikes up.

The problem seems to be the rendering of lyrics with special characters and how many of them are present in the lyrics, songs in Japanese seem to be the biggest offenders. I've tried manually editing the lyrics to gradually add other special characters like emojis and odd punctuation signs and those also caused fb2k to gradually go from 0% to ~10% cpu usage so that's my best guess.

jacquesh commented 5 months ago

If anybody could provide an example of a lyric file that gives them very high CPU usage, that would be helpful

DanteDraconi commented 5 months ago

Here's one saved directly from the component

鬱P - 恐怖!スピーカー人間.txt

strider16 commented 5 months ago

じん feat.メイリア from GARNiDELiA - daze.txt

mixon606 commented 4 months ago

This issue seems to be caused by the default font not natively supporting Japanese characters, so for anyone experiencing this issue I would recommend changing the font in foobar or this addon to Meiryo UI or any other font that has native support for Japanese characters, my cpu usage dropped from 4-10% to 0-1.2% after this