jonniek / mpv-playlistmanager

Mpv lua script to create and manage playlists
The Unlicense
537 stars 42 forks source link

Hovered cursor is slow to scroll with non-latin characters #131

Closed tupo2 closed 9 months ago

tupo2 commented 9 months ago

Playlist to test:

#EXTM3U
#EXTINF:,Oliver Anthony - Rich Men North Of Richmond
https://www.youtube.com/watch?v=sqSA-SY5Hro
#EXTINF:,【オリジナル楽曲】粛聖!! ロリ神レクイエム☆ / しぐれうい(9さい)
https://www.youtube.com/watch?v=Ci_zad39Uhw
#EXTINF:,Linda Remix - Marka Akme, Lautygram, Migrantes, Peipper, DJ Tao
https://www.youtube.com/watch?v=jRn_jPySTmI
#EXTINF:,The Beatles - Now And Then (Official Audio)
https://www.youtube.com/watch?v=AW55J2zE3N4

Does not happen when paused.

jonniek commented 9 months ago

I cannot reproduce. Can you share some more information like operating system and mpv version?

After removing the files with non-latin characters it works faster?

tupo2 commented 9 months ago

Debian Sid and mpv 0.36.0. If I remove line 5 (...Ci_zad39Uhw), it' smooth.

jonniek commented 9 months ago

If you make filename_replace setting null does it change anything?

Or can you try if it gets faster if you change parse_filename function to this:

function parse_filename(string, name, index)
  local base = tostring(plen):len()
  return string:gsub("%%pos", string.format("%0"..base.."d", index+1))
               :gsub("%%name", name)
end

I'm wondering if the gsubs are causing some performance issues with some characters.

Also can you try using this title:

#EXTINF:,【オリジナル楽曲】粛聖!! ロリ神レクイエム/ しぐれうい(9さい)

I wonder if it's the character causing the issue.

Also could you try using another font if that solves the issue? Then it could be some issue in font rendering rather than in this script.

tupo2 commented 9 months ago

If you make filename_replace setting null does it change anything?

Or can you try if it gets faster if you change parse_filename function to this:

function parse_filename(string, name, index)
  local base = tostring(plen):len()
  return string:gsub("%%pos", string.format("%0"..base.."d", index+1))
               :gsub("%%name", name)
end

I'm wondering if the gsubs are causing some performance issues with some characters.

Also can you try using this title:

#EXTINF:,【オリジナル楽曲】粛聖!! ロリ神レクイエム/ しぐれうい(9さい)

I wonder if it's the character causing the issue.

Same issue.

Also could you try using another font if that solves the issue? Then it could be some issue in font rendering rather than in this script.

The default font I'm using for OSD is sans-serif. Tested with others fonts and it's much better. I did not notice before, this message spam in the terminal when I display the playlist: [osd/libass] fontselect: failed to find any fallback with glyph 0xFF09 for font: (sans-serif, 400, 0)

jonniek commented 9 months ago

I think 0xFF09 is the character. FULLWIDTH RIGHT PARENTHESIS. It could be that causing the slowness in the rendering.

Maybe this discussion has some solutions https://www.reddit.com/r/archlinux/comments/8ciooy/support_for_fullwidth_latin_letters/

I'm not sure if there is anything I can do on the script level to fix this issue. It might be also useful to report to mpv repository, as they could probably do some caching and more performant fallbacks on missing characters.

tupo2 commented 9 months ago

I think 0xFF09 is the character. FULLWIDTH RIGHT PARENTHESIS. It could be that causing the slowness in the rendering.

0xFF09, is not the only character displayed in a loop in the terminal:

[osd/libass] fontselect: failed to find any fallback with glyph 0x30AA for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30EA for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30B8 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30CA for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30EB for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x697D for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x66F2 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x7C9B for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x8056 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30ED for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30EA for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x795E for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30EC for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30AF for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30A4 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30A8 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x30E0 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x3057 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x3050 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x308C for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x3046 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x3044 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0xFF08 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x3055 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0x3044 for font: (sans-serif, 400, 0)
[osd/libass] fontselect: failed to find any fallback with glyph 0xFF09 for font: (sans-serif, 400, 0)

I think this cause performance issues, do you know how to stop it (except to close the playlist)?

Maybe this discussion has some solutions https://www.reddit.com/r/archlinux/comments/8ciooy/support_for_fullwidth_latin_letters/

Thanks for the info, I tested fonts-noto-cjk and it's OK too.

jonniek commented 9 months ago

Here is a thread about similar topic, mentioning the slowdown as well. https://github.com/mpv-player/mpv/issues/8919

I think the solution is either in the system or optimizations in mpv/libass. I recommend opening or looking for an issue in those repositories if you cannot resolve the issue.

I'll close this as there is not really anything this script can do to avoid this issue, and my knowledge on the topic is limited.