mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.13k stars 2.88k forks source link

Mouse wheel up and down emit two events per input under Wayland #12966

Closed Lovecraft-github closed 8 months ago

Lovecraft-github commented 10 months ago

Important Information

I noticed after installing https://github.com/jonniek/mpv-playlistmanager and mapping WHEEL_UP and WHEEL_DOWN that it jumped two items at a time. I made a report to the developer key_moveup and key_movedown mapped to WHEEL_UP and WHEEL_DOWN jump two items in osd #133, and he recommended me to post the problem here.

Using a Xorg session works fine.

Console output of mpv --no-config --input-test --force-window --idle when doing one mouse wheel up and down

[input] Key WHEEL_DOWN is bound to: [input] 1. 'add volume -2' in <builtin>:1 (default) [input] 2. 'script-binding osc/__keybinding10' in section {input} in <api>:6 [input] Key WHEEL_DOWN is bound to: [input] 1. 'add volume -2' in <builtin>:1 (default) [input] 2. 'script-binding osc/__keybinding10' in section {input} in <api>:6 [input] Key WHEEL_UP is bound to: [input] 1. 'add volume 2' in <builtin>:1 (default) [input] 2. 'script-binding osc/__keybinding9' in section {input} in <api>:5 [input] Key WHEEL_UP is bound to: [input] 1. 'add volume 2' in <builtin>:1 (default) [input] 2. 'script-binding osc/__keybinding9' in section {input} in <api>:5

I tried another two mouses with the same results and testing with xev seems to work just fine, only one event (press and release) per input.

`ButtonPress event, serial 38, synthetic NO, window 0x1600001, root 0x3d1, subw 0x0, time 126367019, (166,1), root:(316,188), state 0x10, button 4, same_screen YES

ButtonRelease event, serial 38, synthetic NO, window 0x1600001, root 0x3d1, subw 0x0, time 126367019, (166,1), root:(316,188), state 0x810, button 4, same_screen YES

ButtonPress event, serial 38, synthetic NO, window 0x1600001, root 0x3d1, subw 0x0, time 126369194, (166,1), root:(316,188), state 0x10, button 5, same_screen YES

ButtonRelease event, serial 38, synthetic NO, window 0x1600001, root 0x3d1, subw 0x0, time 126369194, (166,1), root:(316,188), state 0x1010, button 5, same_screen YES `

Provide following Information:

Reproduction steps

Just run mpv --no-config --input-test --force-window --idle in a Wayland session.

In a Xorg session work fine

Expected behavior

Only one event per wheel up and down under Wayland as happens in Xorg

Actual behavior

Two events per input

Log file

output.txt

Sample files

Not needed

llyyr commented 10 months ago

Check your compositor settings, I can't reproduce this issue on sway.

xev

you want to use wev instead, xev will use xwayland.

Also logs from input-test with WAYLAND_DEBUG=1 would be interesting to see:

WAYLAND_DEBUG=1 mpv --no-config --input-test --force-window --idle

christoph-heinrich commented 10 months ago

Doesn't happen for me on KDE plasma on wayland either.

Lovecraft-github commented 10 months ago

Check your compositor settings, I can't reproduce this issue on sway.

Do you know how to do that in gnome? I can't find any option to modify scroll lines. I used to do it with imwheel but it doesn't seems to work under Wayland

xev

you want to use wev instead, xev will use xwayland.

With wev

[13: wl_pointer] axis_source: 0 (wheel) [13: wl_pointer] frame [13: wl_pointer] axis_source: 0 (wheel) [13: wl_pointer] axis_stop: axis: 0 (vertical), discrete: 1 [13: wl_pointer] axis: time: 129372906; axis: 0 (vertical), value: 10.000000 [13: wl_pointer] frame [13: wl_pointer] axis_source: 0 (wheel) [13: wl_pointer] frame [13: wl_pointer] axis_source: 0 (wheel) [13: wl_pointer] axis_stop: axis: 0 (vertical), discrete: -1

Also logs from input-test with WAYLAND_DEBUG=1 would be interesting to see:

WAYLAND_DEBUG=1 mpv --no-config --input-test --force-window --idle

output.log

console output

llyyr commented 10 months ago
[3542022.467] wl_pointer@8.axis(130172947, 0, 10.00000000)
[input] Key WHEEL_DOWN is bound to:
[input] 1.  'add volume -2' in <builtin>:1 (default)
[input] 2.  'script-binding osc/__keybinding10' in section {input} in <api>:6
[3542022.856] wl_pointer@8.axis(130172947, 0, 10.00000000)
[input] Key WHEEL_DOWN is bound to:
[input] 1.  'add volume -2' in <builtin>:1 (default)
[input] 2.  'script-binding osc/__keybinding10' in section {input} in <api>:6

mpv responds to the events it gets, not really a mpv issue. I don't know where GNOME's mouse settings are but I'd guess it's likely the cause

Lovecraft-github commented 10 months ago

The mouse settings are very "minimalistic", there are not options to change scroll lines in wheel.

Could you please leave this open a little bit more time in case anybody know how to fix it?

mario-g98 commented 10 months ago

I have the exact same issue, which happens under Wayland only (EndeavourOS, Gnome). I guess the problem might actually be in mpv, as SMPlayer (with mpv engine) works as expected.

llyyr commented 10 months ago

I have the exact same issue, which happens under Wayland only (EndeavourOS, Gnome). I guess the problem might actually be in mpv, as SMPlayer (with mpv engine) works as expected.

SMPlayer runs as an Xwayland app on Wayland https://github.com/smplayer-dev/smplayer/commit/a4dd1953c0f2ad9bdcb455279d3409d3ce68873b

mario-g98 commented 10 months ago

SMPlayer runs as an Xwayland app on Wayland https://github.com/smplayer-dev/smplayer/commit/a4dd1953c0f2ad9bdcb455279d3409d3ce68873b

What about Celluloid? It runs on Wayland (I checked with xlsclients and xeyes) and with the exact same config and input files it doesn't have this bug.

llyyr commented 10 months ago

What about Celluloid? It runs on Wayland (I checked with xlsclients and xeyes) and with the exact same config and input files it doesn't have this bug.

Run Celluloid with WAYLAND_DEBUG=1 and post the logs here with mouse up and down inputs. Even if it works for other apps it's probably because of some app-specific setting.

The wayland debug logs show that mpv gets duplicated events https://github.com/mpv-player/mpv/issues/12966#issuecomment-1826389767

mario-g98 commented 10 months ago

Here are the logs from both players:

WAYLAND_DEBUG=1 mpv --no-config --input-test --force-window --idle output_mpv.txt

WAYLAND_DEBUG=1 celluloid --mpv-input-test --mpv-force-window --mpv-idle output_celluloid.txt

Celluloid registers only one input, while mpv registers two.

llyyr commented 10 months ago

WAYLAND_DEBUG logs aren't captured in mpv's log file, you can either pipe it to a file or copypaste the terminal output.

mario-g98 commented 10 months ago

My bad. Here is the terminal output: celluloid_console_output.txt mpv_console_output.txt

llyyr commented 10 months ago

from the celluloid output

[3177724.544] wl_pointer@10.axis_source(0)
[3177724.581] wl_pointer@10.axis_value120(0, 120)
[3177724.596] wl_pointer@10.axis(13019138, 0, 10.00000000)

@Dudemanguy I wonder if this happens due to high resolution scrolls?

For example, an axis_value120 of 30 is one quarter of a logical scroll step in the positive direction, a value120 of -240 are two logical scroll steps in the negative direction within the same hardware event.

I think this is still probably a Mutter bug? They shouldn't be sending us the event twice I don't think

Lovecraft-github commented 10 months ago

Can confirm that it works in celluloid under wayland https://streamable.com/hwtght but not in mpv https://streamable.com/iaskdb

Dudemanguy commented 10 months ago

@Dudemanguy I wonder if this happens due to high resolution scrolls?

We don't currently use the high resolution scroll events in wayland. Maybe we should. Still, the compositor sending us the event twice cannot be our bug.

na-na-hi commented 8 months ago

@mario-g98 @Lovecraft-github Can you try if https://github.com/mpv-player/mpv/pull/13390 fixes this issue? What's happening here appears to be a compositor bug, but from the output of celluloid, the PR linked should be able to sidestep that.

mario-g98 commented 8 months ago

@mario-g98 @Lovecraft-github Can you try if #13390 fixes this issue? What's happening here appears to be a compositor bug, but from the output of celluloid, the PR linked should be able to sidestep that.

Yes, with the latest github version the problem is solved!

Lovecraft-github commented 8 months ago

Same here