Closed NaiveInvestigator closed 1 year ago
same here, seems to be related to the menu entries that also have key-binds set for them
I've never noticed this and it's weird that it happens randomly.
The only thing I can think of is that it for some reason thinks the title has 0 width. Are you using text_width_estimation=no
?.
Maybe some debug output can shed some light on this. The following patch prints all the titles, hints and their widths whenever a menu gets opened. It would be interesting to know what gets printed for the items that don't get shown.
diff --git a/scripts/uosc_shared/elements/Menu.lua b/scripts/uosc_shared/elements/Menu.lua
index 336cbd0..f7ba065 100644
--- a/scripts/uosc_shared/elements/Menu.lua
+++ b/scripts/uosc_shared/elements/Menu.lua
@@ -209,6 +209,8 @@ function Menu:update_content_dimensions()
local icon_width = item.icon and self.font_size or 0
item.title_width = text_width(item.title, title_opts)
item.hint_width = text_width(item.hint, hint_opts)
+ print('title', item.title, item.title_width)
+ print('hint', item.hint, item.hint_width)
local spacings_in_item = 1 + (item.title_width > 0 and 1 or 0)
+ (item.hint_width > 0 and 1 or 0) + (icon_width > 0 and 1 or 0)
local estimated_width = item.title_width + item.hint_width + icon_width
I'm also in the "can't replicate" camp here.
i just did a test for this issue without my uosc.conf file and it's gone, there is something in our old conf file that causes this, i don't know what but at least now i know i need to make a new config file
Edit: Btw this is all based on the old commits, haven't tried the new ones from today. Will try those and post more info.
I tried this diff and I got this in my console. Sadly I tried make a new conf file AND also just simply delete the conf file but in my case it hasn't changed much, I only have custom control buttons and everything else is at default values. and also I am using text_width_estimation=yes
You can see my conf file here if it is needed. My config is basically that repo, nothing else is changed.
https://github.com/NaiveInvestigator/mpv-config/blob/main/script-opts/uosc.conf
================================================================================== My menu this time:
I think you want to see this so I'll keep this separate. The rest that render properly usually output nil with some few exceptions. But if you need the full console output tis given below:
[uosc] title Toggle Deinterlace 0
[uosc] hint D 14.916291803279
[uosc] title Save Playlist In Current Path 0
[uosc] hint ALT+s 60.417606557377
[uosc] title Show Clock 0
[uosc] hint c 10.397357377049
[uosc] title Toggle CRT Shader 0
[uosc] hint C 14.916291803279
[uosc] title Toggle Info About Torrent 0
[uosc] hint p 11.475718032787
[uosc] title Increase Audio Delay 0
[uosc] hint CTRL+n 77.522668852459
[uosc] title Decrease Audio Delay 0
[uosc] hint CTRL+N 80.963242622951
[uosc] title Increase Subtitle Scale 0
[uosc] hint ' 3.991788
[uosc] title Decrease Subtitle Scale 0
[uosc] hint ; 5.785788
[uosc] title Move Subtitle Up 0
[uosc] hint : 5.785788
[uosc] title Move Subtitle Down 0
[uosc] hint " 7.3357180327869
[uosc] title Increase Subtitle Delay 0
[uosc] hint x 10.397357377049
[uosc] title Decrease Subtitle Delay 0
[uosc] hint y 10.397357377049
[uosc] title Toggle Deband 0
[uosc] hint d 11.475718032787
[uosc] title With Subtitles 0
[uosc] hint Ctrl+S 58.098357442623
[uosc] title Increase Speed 0
[uosc] hint > 12.101619672131
[uosc] title Decrease Speed 0
[uosc] hint < 12.101619672131
[uosc] title Reset Speed 0
[uosc] hint / 5.785788
I have tried new commits, and the issue still persists. but what I have noticed is that it only happens to those menus titles always. hit or miss tho. Namely:
D cycle deinterlace #! Video > Toggle Deinterlace
ALT+s script-binding save-playlist #! Utils > Save Playlist In Current Path
Ctrl+S script-binding clipshot-subs #! Utils > Screenshot To Clipboard > With Subtitles
c script_message show-clock #! Utils > Show Clock
> add speed +0.25; script-binding uosc/flash-speed #! Utils > Speed > Increase Speed
< add speed -0.25; script-binding uosc/flash-speed #! Utils > Speed > Decrease Speed
/ set speed 1; script-binding uosc/flash-speed #! Utils > Speed > Reset Speed
C change-list glsl-shaders toggle "~~/shaders/crt-mpv.glsl" #! Utils > Toggle CRT Shader
p script-binding webtorrent/toggle-info #! Utils > Toggle Info About Torrent
Out here the Speed Menu title gets rendered but not tis own submenues.
But this time around most of the speed submenus get rendered except one.
As suspected it thinks that a lot of the widths are 0, but I have no idea why that may be.
The only thing I can think of is that you try setting the osd-font
in mpv.conf
and see if that changes anything.
It really shouldn't make a difference, but it doesn't hurt to rule out any font shenanigans.
https://github.com/tomasklaen/uosc/issues/354#issuecomment-1297190975
Even though I cloned your repo, I could not reproduce the issue.
I tried changing the osd-font
but to no avail sadly.
I wonder if there are some special characters that might be causing issues. Like \r
or something. Menu parser should be stripping them, but I don't know anymore.
It's also weird that it only happens in submenus it seems.
Edited: I find the bug too. So I did some tests, here are the results:
Only happens on windows, not on mac.
Only happens on videos with subtitles tracks or videos with external subtitles(referring to the subtitle files having the same name as the video files' in the same directory) randomly.
Videos without subtitles tracks are fine.
Open the mpv's window first, and then drag the video file into the mpv window, everything runs smoothly.
Here's my input.conf:
# script-binding uosc/open-file #! 打开 > 文件浏览器
# script-binding uosc/load-subtitles #! 打开 > 导入字幕轨
CTRL+c script-binding SmartCopyPaste_II/copy #! 打开 > 复制文件路径及进度
CTRL+ALT+c script-binding SmartCopyPaste_II/copy-specific #! 打开 > 复制文件路径
CTRL+v script-binding SmartCopyPaste_II/paste #! 打开 > 跳转到复制内容
CTRL+ALT+v script-binding SmartCopyPaste_II/paste-specific #! 打开 > 复制内容添加至播放列表
# script-binding uosc/playlist #! 导航 > 播放列表
# script-binding uosc/editions #! 导航 > 版本列表
# script-binding uosc/chapters #! 导航 > 章节列表
# script-binding uosc/video #! 导航 > 视频轨列表
# script-binding uosc/audio #! 导航 > 音频轨列表
# script-binding uosc/subtitles #! 导航 > 字幕轨列表
# playlist-shuffle #! 导航 > 播放列表乱序重排
c add audio-delay -0.1 #! 音频 > 音频预载 100ms
v add audio-delay 0.1 #! 音频 > 音频延迟 100ms
# cycle audio-normalize-downmix #! 音频 > 切换 音频规格化
z add sub-delay -0.1 #! 字幕 > 字幕预载 100ms
x add sub-delay +0.1 #! 字幕 > 字幕延迟 100ms
, frame-back-step #! 播放 > 上一帧
. frame-step #! 播放 > 下一帧
l ab-loop #! 播放 > 设置/清除 AB循环点
- no-osd add volume -1 ; script-message-to uosc flash-elements volume #! 播放 > 音量 -
= no-osd add volume 1 ; script-message-to uosc flash-elements volume #! 播放 > 音量 +
Shift+BS set audio-delay 0 ; set sub-delay 0 #! 播放 > 重置 音频与字幕同步
# script-binding uosc/shot #! 截屏
# cycle-values hwdec "auto" "auto-copy" "no" #! 视频 > 切换 解码模式
# cycle deband #! 视频 > 切换 去色带状态
# cycle deinterlace #! 视频 > 切换 去隔行状态
# cycle icc-profile-auto #! 视频 > 切换 自动校色
# cycle correct-pts #! 视频 > 切换 时间码解析模式
1 add contrast -1 #! 视频 > 均衡器 > 对比度 -
2 add contrast 1 #! 视频 > 均衡器 > 对比度 +
3 add brightness -1 #! 视频 > 均衡器 > 明度 -
4 add brightness 1 #! 视频 > 均衡器 > 明度 +
5 add gamma -1 #! 视频 > 均衡器 > 伽马 -
6 add gamma 1 #! 视频 > 均衡器 > 伽马 +
7 add saturation -1 #! 视频 > 均衡器 > 饱和度/纯度 -
8 add saturation 1 #! 视频 > 均衡器 > 饱和度/纯度 +
9 add hue -1 #! 视频 > 均衡器 > 色相 -
0 add hue 1 #! 视频 > 均衡器 > 色相 +
Ctrl+BS set contrast 0 ; set brightness 0 ; set gamma 0 ; set saturation 0 ; set hue 0 #! 视频 > 均衡器 > 重置全部
# script-binding stats/display-stats-toggle #! 工具 > 常驻显示统计信息
# script-binding console/enable #! 工具 > 显示控制台
# cycle border #! 工具 > 切换 窗口边框
# cycle ontop #! 工具 > 切换 窗口置顶
# script-binding uosc/audio-device #! 工具 > 音频输出设备列表
# script-binding uosc/stream-quality #! 工具 > 流式传输品质
# script-binding uosc/show-in-directory #! 工具 > 打开当前文件所在路径
# script-binding uosc/open-config-directory #! 工具 > 打开设置目录
# quit #! 退出
#############
## LUA脚本 ##
#############
##⇘⇘追加绑定外置脚本内建的快捷键方案,此处追加绑定的按键会与脚本内建的方案共存
##个别外置脚本的部分快捷键也可在 /script-opts/ 文件夹内找对应的配置文件进行修改,遵原作者介绍优先
F8 script-binding playlistmanager/showplaylist # 打开高级播放列表(替换原默认的简易OSD播放列表;超时自动或手动再次按下关闭)
Ctrl+a script-binding cycle_adevice/back # 切换到上一个音频设备
Alt+a script-binding cycle_adevice/next # 切换到下一个音频设备
m script-binding input_plus/mark_aid_fin # 标记当前音轨为A--标记B--合并--取消
Alt+p script-binding input_plus/playlist_shuffle # 播放列表的洗牌与撤销
CLOSE_WIN script-binding input_plus/quit_real # 对执行退出命令前的确认(防止误触)
b script-binding input_plus/speed_auto # 按下3倍速,松开一倍速
##⇘⇘MPV内部自带的LUA脚本
i script-binding stats/display-stats # 临时显示统计信息(此时01234翻页,024页可方向上下键滚动查看)
I script-binding stats/display-stats-toggle # 开/关 常驻显示统计信息
TAB script-binding stats/display-stats-toggle # 开/关 常驻显示统计信息
` script-binding console/enable # 进入控制台(此时Esc退出)
DEL script-binding osc/visibility # 切换 内置OSC的可见性
##############
## 其它操作 ##
##############
##⇘⇘此处展示MPV的部分初始快捷键方案,可自行修改至顺手
##个别操作例如显示播放列表,可直接右键单机OSC控件上的◀︎▶︎显示。
##左中右分别为 —— 键值/键位名(必要);触发操作名(必要);注释的中文解释(可删)
##完整的内建快捷键方案见 https://github.com/mpv-player/mpv/blob/master/etc/input.conf 全部功能见 https://mpv.io/manual/master/#input-conf
##⇘⇘鼠标
MBTN_LEFT show-progress # 临时显示时间码/进度条
MBTN_LEFT_DBL cycle fullscreen # 切换 全屏状态 [左键-双击]
MBTN_RIGHT script-binding uosc/menu # 鼠标右键唤起uosc的OSD上下文菜单
MBTN_BACK playlist-prev # 切换到列表中的上个文件 [后退键]
PGUP playlist-prev
MBTN_FORWARD playlist-next # 切换到列表中的下个文件 [前进键]
PGDWN playlist-next
MBTN_MID ignore # 默认没给定义但是很多人用,要用建议清空下两条操作名(易误触)[中键(按压滚轮)]
WHEEL_UP add volume 1 # 后退10秒 [滚轮-向上]
WHEEL_DOWN add volume -1 # 前进10秒 [滚轮-向下]
WHEEL_LEFT ignore # <无操作> [滚轮-向左]
WHEEL_RIGHT ignore # <无操作> [滚轮-向右]
##⇘⇘键盘
q quit # 关闭MPV程序
Q quit-watch-later # 关闭MPV程序 稍后观看(保存当前文件状态)
o show-progress # 临时显示时间码/进度条
P show-progress # 临时显示时间码/进度条
O no-osd cycle-values osd-level 3 1 # 常驻显示时间码
##当输出旋转之后,垂直方向因跟随输出方向的变化而改变。输出旋转操作会启动缩略图重建进程
##输出旋转可能产生色度升频的bug,可改 mpv.conf 中 --cscale=bilinear 或启用去色带或使用软解解决
CTRL+LEFT cycle-values video-rotate "0" "270" "180" "90" # 视频输出逆时针旋转90°
CTRL+RIGHT cycle-values video-rotate "0" "90" "180" "270" # 视频输出顺时针旋转90°
ALT+0 cycle-values current-window-scale "0.5" "1.0" "1.5" # 快速缩放窗口大小
ALT+` set current-window-scale 1.0 # 重置窗口大小为一倍
ALT+1 add current-window-scale -0.1 # 窗口 -
ALT+2 add current-window-scale 0.1 # 窗口 +
ALT+9 cycle-values panscan "0.0" "1.0" # 视频缩放以适合/填充窗口
ALT+- add video-zoom -0.1 # 视频缩放 -(窗口不变)
ALT+= add video-zoom 0.1 # 视频缩放 +(窗口不变)
ALT+LEFT add video-pan-x -0.1 # 视频移动 ←(窗口不变)
ALT+RIGHT add video-pan-x 0.1 # 视频移动 →(窗口不变)
ALT+UP add video-pan-y -0.1 # 视频移动 ↑(窗口不变)
ALT+DOWN add video-pan-y 0.1 # 视频移动 ↓(窗口不变)
ALT+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 # 重置视频的缩放与移动
ALT+b cycle border # 切换 窗口边框
#CTRL+v cycle video # 切换视频轨
p cycle pause # 切换 暂停/播放状态
SPACE cycle pause # 切换 暂停/播放状态 [空格键]
CTRL+ALT+SPACE stop # 停止
T cycle ontop # 切换 置顶状态
t set ontop yes # 进入置顶状态
f cycle fullscreen # 切换 全屏状态
ENTER set fullscreen yes # 进入全屏状态 [回车键]
ESC set fullscreen no # 退出全屏状态
l ab-loop # 设置/清除 A-B循环点
L cycle-values loop-file "inf" "no" # 切换 当前文件循环播放
, frame-back-step # (暂停)帧步退
. frame-step # (暂停)帧步进
CTRL+, add chapter -1 # 章节 -
CTRL+. add chapter 1 # 章节 +
< playlist-prev # 列表中的上个文件
> playlist-next # 列表中的下个文件
LEFT seek -5 # 后退05秒 [方向左键]
SHIFT+LEFT seek -1 exact # 后退01秒(精确)
RIGHT seek 5 # 前进05秒 [方向右键]
SHIFT+RIGHT seek 1 exact # 前进01秒(精确)
UP add volume 1 # 音量加1 [方向上键]
DOWN add volume -1 # 音量减1 [方向下键]
[ add speed -0.1 # 播放速度 -(最小0.01)
] add speed 0.1 # 播放速度 +(最大100)
{ multiply speed 0.5 # 播放速度 半减
} multiply speed 2.0 # 播放速度 倍增
BS set speed 1.0 # 重置播放速度 [退格键]
d cycle deinterlace # 切换 去隔行状态
D cycle deband # 切换 去色带状态
j add sharpen -0.1 # 清晰度 -(勿低于-1)
k add sharpen 0.1 # 清晰度 +(勿高于1)
CTRL+h cycle-values hwdec "auto" "auto-copy" "no" # 切换 优先硬解//硬解+//软解
##快速在指定的音频输出设备间切换、设备名的获取见发布页FAQ或文档 https://mpv.io/manual/master/#options-audio-device
#A cycle-values audio-device "wasapi/{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" "wasapi/{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"
- add volume -1 # 音量 -
= add volume 1 # 音量 +
#m cycle mute # 切换 静音状态
ALT+c add aid -1 # 音轨 上一个
ALT+v add aid 1 # 音轨 下一个
c add audio-delay -0.1 # 音频同步 预载100ms
v add audio-delay 0.1 # 音频同步 延迟100ms
z add sub-delay -0.1 # 字幕同步 预载100ms
x add sub-delay +0.1 # 字幕同步 延迟100ms
SHIFT+BS set audio-delay 0 ; set sub-delay 0 # 重置音频与字幕同步
Z add sub-scale -0.1 # 字幕缩放 -
X add sub-scale +0.1 # 字幕缩放 +
CTRL+z add sub-pos -1 # 字幕移动 ↑
CTRL+x add sub-pos +1 # 字幕移动 ↓
ALT+z add sid -1 # 字幕轨 上一个
ALT+x add sid 1 # 字幕轨 下一个
ALT+Z add secondary-sid -1 # 次字幕轨(原生) 上一个
ALT+X add secondary-sid 1 # 次字幕轨(原生) 下一个
##当前原生双字幕的问题与另一种实现多字幕的方案: https://github.com/hooke007/MPV_lazy/discussions/61
s screenshot # 截屏(有字幕、有OSD) 输出原始分辨率
S screenshot video # 截屏(无字幕、无OSD) 输出原始分辨率
CTRL+s screenshot window # 截屏(有字幕、有OSD) 输出实际分辨率
ALT+s screenshot each-frame # 截屏(逐帧)
##截屏(逐帧),再次执行该命令停止。默认方式等同"s",可以在"each-frame"后添加" video"或" window"修改逐帧截图的方式。可能需要在mpv.conf使用 --framedrop=no 来避免截图丢帧与重复
I went back to 4.3.0 and this bug disappeared
It looks fine for me :(
And it doesn't look like it's an error in text measuring, as it really only happens when there are hints. This is so weird...
I guess we need someone who can replicate and dig into the code and find the cause.
I went back to 4.3.0 and this bug disappeared
4.3.0 doesn't have text measuring, so it does just a dumb assumption that every letter is the same width, which leads to other issues.
I also noticed this happens on files where there are two or more subtitles of the same language. It doesn't matter whether if it is embed with the vid or not. I also happen to use secondary-sid=auto
in my mpv.conf
and the moment I commented that option out, the issue stops occurring. I also tried adding the option back and as suspected it the issues starts again. I think it has to do something with secondary-sid
.
@NaiveInvestigator Could you test this snapshot? This is the last "safe" version here. https://github.com/tomasklaen/uosc/archive/26648f081a18fdf0890c9b789403e83672b1f6f6.zip
@NaiveInvestigator Could you test this snapshot? This is the last "safe" version here. https://github.com/tomasklaen/uosc/archive/26648f081a18fdf0890c9b789403e83672b1f6f6.zip
https://github.com/tomasklaen/uosc/commit/26648f081a18fdf0890c9b789403e83672b1f6f6 , no bug. https://github.com/tomasklaen/uosc/commit/bef4a77139bda67fb0fc43731b0716d4d4a15be4 , has bug.
Video files where there's only one subtitle track also have issue randomly. Strange thing is, the same file, sometimes has no issue, sometimes has issue.
A workaround: in "uosc.conf", change to text_width_estimation=no
, the bug is gone. So there's something wrong with text measuring.
@NaiveInvestigator Could you test this snapshot? This is the last "safe" version here. https://github.com/tomasklaen/uosc/archive/26648f081a18fdf0890c9b789403e83672b1f6f6.zip
I tested this snapshot and can confirm it is safe.
Is someone that experiences his issue able to switch their lua runtime to see if that changes anything? So from luajit to lua or from lua to luajit. Would be wild if that is actually somehow caused by a bug in the lua implementation.
Another thing we could try is to see if that patch makes a difference.
diff --git a/scripts/uosc_shared/lib/text.lua b/scripts/uosc_shared/lib/text.lua
index 7c1cf4e..8518e2c 100644
--- a/scripts/uosc_shared/lib/text.lua
+++ b/scripts/uosc_shared/lib/text.lua
@@ -116,7 +116,7 @@ local function unicode_to_utf8(unicode)
end
local text_osd = mp.create_osd_overlay("ass-events")
-text_osd.compute_bounds, text_osd.hidden = true, true
+text_osd.compute_bounds, text_osd.hidden = true, false
---@type integer, integer
local osd_width, osd_height = 100, 100
mp.observe_property('osd-dimensions', 'native', function (_, dim)
@@ -134,7 +134,7 @@ local function measure_bounds(ass_text)
end
---@type {wrap: integer; bold: boolean; italic: boolean, rotate: number; size: number}
-local bounds_opts = {wrap = 2, bold = false, italic = false, rotate = 0, size = 0}
+local bounds_opts = {wrap = 2, bold = false, italic = false, rotate = 0, size = 0, opacity = 0}
---Measure text width and normalize to a font size of 1
---text has to be ass safe
From what I remember this will reduce the performance a little bit, and it will also lead to mpv rendering completely transparent bitmaps each frame, but if it avoids issues that might be worth it.
If that still doesn't help, you could try that patch but without the opacity = 0
. That will lead to the measured text actually being visible and therefore certainly not a real solution, but if that actually makes a difference for you then I don't even know what we could possibly do about this (other then going back to the old way of estimating width). At that point it might some weird libass behavior something :confused:.
@christoph-heinrich Weird thing is if I open the mpv's window first, and then drag the video file into the mpv window, everything runs smoothly, why?
@christoph-heinrich Weird thing is if I open the mpv's window first, and then drag the video file into the mpv window, everything runs smoothly, why?
Beats me. It indicates that it might be some weird timing thing, but it's odd that when it happens, it consistently happens for the title but not for the hint, even though they literally use the exact same function right after each other.
@junguler how is your new config coming along? Have you found which part of your config was causing it?
Not one part. Even though only one simple (in the menu) item would cause the issue.
edit: It looks like magic...
Can someone please test if #383 makes a difference here?
Can someone please test if #383 makes a difference here?
it seems to have fixed the issue for me, i'm using this input.conf, windows 10, latest commit with your pr applied using github cli
Can someone please test if #383 makes a difference here?
Yes, fix my issue too.
It seems to fix it, but has anyone noticed that text width measurement is off again? Specifically the video title.
Can someone please test if #383 makes a difference here?
Looks good to me.
Since it seems like #383 fixed it, I'm gonna close this. If someone still has issues I'll reopen.
It seems to fix it, but has anyone noticed that text width measurement is off again? Specifically the video title.
Can be reproduced with https://github.com/tomasklaen/uosc/pull/383.
Can confirm that #396 returns the text width measurement behaviour before #383, while ensuring the menu text are rendered.
So was #396 the culprit, this is fixed, and can be closed now?
This doesn't always happen, only sometimes randomly but also kinda frequently. Also the elements that dissappear are also random at times.
This is my menu: