mpv-player / mpv

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

wayland hidpi scaling behavior 3840x2160 opens as 11520x6480 #11477

Open 24fpsDaVinci opened 1 year ago

24fpsDaVinci commented 1 year ago

Important Information

Provide following Information:

Reproduction steps

open 3840x2160 video wayland scaling is set to 300% on 13.3" 4k laptop

Expected behavior

open as 3840x2160

Actual behavior

actual size is 11520x6480

Log file

mpv.log

maybe hidpi behavior should be integer scaling closest to display resolution?

Dudemanguy commented 1 year ago

Huh so mutter has fractional scaling now apparently. This is weird though because obviously something is multiplying by 3 somewhere internally, but that's not supposed to be happening. Why this would be different among compositors is not clear. I sure hope mutter isn't delivering coordinates differently or something.

Dudemanguy commented 1 year ago

@24fpsDaVinci: Is this still a problem for you? I was finally able to test mutter 44.1 and it worked normally (video was 3840x2160).

24fpsDaVinci commented 1 year ago

still happening for me with the default config, as a workaround i'm using no-hidpi-window-scale . also using 44.1 mutter

Dudemanguy commented 1 year ago

Could you rebuild mpv from git if you haven't already? The coordinates for configure_bounds was incorrect when this issue was made which maybe is related. That is fixed now though.

24fpsDaVinci commented 1 year ago

Could you rebuild mpv from git if you haven't already? The coordinates for configure_bounds was incorrect when this issue was made which maybe is related. That is fixed now though.

its still happening even with the latest commits, odd mpv.log

Dudemanguy commented 1 year ago

Does this behavior for happen with specifically only 4k video? Or is anything multiplied by three?

24fpsDaVinci commented 1 year ago

everything is original resolution x3, as far as i can tell

Dudemanguy commented 1 year ago

It's weird, your log seemingly does a Resize: 11520x6480 for no real reason. It's not meaningfully different from my own log aside from that line (for me, it's Resize: 3840x2160 as expected). Could you post a wayland debug log of this happening (WAYLAND_DEBUG=1 mpv ... 2> wayland.log)?

Dudemanguy commented 1 year ago

I think you uploaded the wrong log. I was looking for the wayland debug one (gets generated when you set that variable). It should look something like:

[3484499.350]  -> wl_display@1.get_registry(new id wl_registry@2)
[3484499.386]  -> wl_display@1.sync(new id wl_callback@3)
[3484499.440] wl_display@1.delete_id(3)
[3484499.445] wl_registry@2.global(1, "wl_shm", 1)
[3484499.449]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[3484499.452] wl_registry@2.global(2, "wl_drm", 2)
[3484499.455] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[3484499.457]  -> wl_registry@2.bind(3, "zwp_linux_dmabuf_v1", 4, new id [unknown]@5)
[3484499.459]  -> zwp_linux_dmabuf_v1@5.get_default_feedback(new id zwp_linux_dmabuf_feedback_v1@6)
[3484499.462] wl_registry@2.global(4, "wl_compositor", 5)
[3484499.464]  -> wl_registry@2.bind(4, "wl_compositor", 4, new id [unknown]@7)
[3484499.466]  -> wl_compositor@7.create_surface(new id wl_surface@8)
[3484499.468]  -> wl_compositor@7.create_surface(new id wl_surface@9)
[3484499.470]  -> wl_compositor@7.create_region(new id wl_region@10)
[3484499.471]  -> wl_surface@9.set_input_region(wl_region@10)
[3484499.473]  -> wl_region@10.destroy()
24fpsDaVinci commented 1 year ago

I think you uploaded the wrong log

oops , here is the correct log wayland.log @Dudemanguy

Dudemanguy commented 1 year ago

Mind doing some print debugging real quick? What does the terminal print out for you with this patch applied?

diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 55cf059394..8e59e92145 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1637,6 +1637,8 @@ static void request_decoration_mode(struct vo_wayland_state *wl, uint32_t mode)
 static void rescale_geometry(struct vo_wayland_state *wl, double old_scale)
 {
     double factor = old_scale / wl->scaling;
+    printf("wl->scaling: %lf\n", wl->scaling);
+    printf("old scale: %lf\n", old_scale);
     wl->window_size.x1 /= factor;
     wl->window_size.y1 /= factor;
     wl->geometry.x1 /= factor;

Should show something like:

wl->scaling: 3.0000
old scale: 1.0000
24fpsDaVinci commented 1 year ago

applied

 mpv --no-config bigBuckBunny4k.mkv 
 (+) Video --vid=1 (*) (vp9 3840x2160 60.000fps)
 (+) Audio --aid=1 (*) (aac 6ch 48000Hz)
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pipewire] 48000Hz 5.1 6ch floatp
VO: [gpu] 3840x2160 yuv420p
wl->scaling: 3.000000
old scale: 1.000000
(Paused) AV: 00:00:04 / 00:10:34 (1%) A-V:  0.000 Dropped: 5
Dudemanguy commented 1 year ago

Okay so that's correct. What does this print out (you can remove the old patch if you want)?

diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 55cf059394..25269daf0d 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1641,6 +1641,8 @@ static void rescale_geometry(struct vo_wayland_state *wl, double old_scale)
     wl->window_size.y1 /= factor;
     wl->geometry.x1 /= factor;
     wl->geometry.y1 /= factor;
+    printf("width: %d\n", mp_rect_w(wl->geometry));
+    printf("height: %d\n", mp_rect_h(wl->geometry));
 }

 static void clean_feedback_pool(struct vo_wayland_feedback_pool *fback_pool)
24fpsDaVinci commented 1 year ago

here is the new output

mpv --no-config bigBuckBunny4k.mkv 
 (+) Video --vid=1 (*) (vp9 3840x2160 60.000fps)
 (+) Audio --aid=1 (*) (aac 6ch 48000Hz)
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pipewire] 48000Hz 5.1 6ch floatp
VO: [gpu] 3840x2160 yuv420p
width: 3840
height: 2304
Dudemanguy commented 1 year ago

I'm not sure why the height coordinate is weird for you. Surely it should be less than 2160 because of maximization and all that. I did notice that your log does this though:

[cplayer] Set property: fullscreen -> 1

And it doesn't look like you are running a cycle command there. Do you know where that fullscreen is coming from? Is it mutter doing it?

24fpsDaVinci commented 1 year ago

i think the fullscreen was caused by me clicking the window. I ran again without clicking window this time. mpv.log

Dudemanguy commented 1 year ago

Does this patch fix it?

diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 55cf059394..5ca0d1ad6b 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1641,6 +1641,8 @@ static void rescale_geometry(struct vo_wayland_state *wl, double old_scale)
     wl->window_size.y1 /= factor;
     wl->geometry.x1 /= factor;
     wl->geometry.y1 /= factor;
+    wl->vo->dwidth /= factor;
+    wl->vo->dheight /= factor;
 }

 static void clean_feedback_pool(struct vo_wayland_feedback_pool *fback_pool)
24fpsDaVinci commented 1 year ago

still happening with the patch mpv.log

Dudemanguy commented 1 year ago

Getting really confused here, what does this patch print for you?

diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index 0380114e95..9397857c63 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -78,6 +78,9 @@ static void resize(struct ra_ctx *ctx)
     const int32_t width = mp_rect_w(wl->geometry);
     const int32_t height = mp_rect_h(wl->geometry);

+    printf("width: %d\n", width);
+    printf("height: %d\n", height);
+
     vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
     if (p->egl_window)
         wl_egl_window_resize(p->egl_window, width, height, 0, 0);
24fpsDaVinci commented 1 year ago
mpv --no-config bigBuckBunny4k.mkv
 (+) Video --vid=1 (*) (vp9 3840x2160 60.000fps)
 (+) Audio --aid=1 (*) (aac 6ch 48000Hz)
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pipewire] 48000Hz 5.1 6ch floatp
VO: [gpu] 3840x2160 yuv420p
width: 1280
height: 768
width: 3840
height: 2304
width: 11520 / 00:10:34 (0%) A-V:  0.000 Dropped: 5
height: 6480
AV: 00:00:03 / 00:10:34 (1%) A-V:  0.000 Dropped: 20

Exiting... (Quit)
Dudemanguy commented 1 year ago

I'm sad to say, but right now I have no idea how that's even possible.

24fpsDaVinci commented 1 year ago

https://koji.fedoraproject.org/koji/buildinfo?buildID=2192568 this is the mutter build im using, with 1441.patch for triple buffering

Dudemanguy commented 1 year ago

with 1441.patch for triple buffering

Okay, that might explain it. Could you try mutter without that patch? I'm testing with just plain 44.1.

24fpsDaVinci commented 1 year ago

using the f38 official 44.1 build now and its still happening mpv.log

Dudemanguy commented 1 year ago

I'm out of ideas unfortunately.

24fpsDaVinci commented 7 months ago

running fedora 40 rawhide now and gnome46 alpha 300% desktop scaling this issue still happens for me on latest mpv git build, as a temp solution i use --no-hidpi-window-scale

Dudemanguy commented 7 months ago

I haven't opened up gnome in a while but what's supposed to happen is that the compositor's configure bounds request limits the size which is what happened for me. It's been a while since I looked at your logs, but if I remember right the configure bounds did happen but for some reason the window resizes for you by itself anyway.

Dudemanguy commented 7 months ago

Oh P.S. could you try #13325 and see if anything is different. On paper it's not supposed to be anyway, but maybe something happens.

24fpsDaVinci commented 7 months ago

I tested #13325, it has the same behaviour as main branch as far as I can tell

24fpsDaVinci commented 7 months ago

mpv.log added new log using latest main branch

Screenshot from 2024-01-27 23-03-56

Dudemanguy commented 7 months ago

I still can't reproduce. According to your log (did you cut it off?), it's the correct size although the screenshot obviously says different.

[vo/gpu] Resize: 3840x2304
[vo/gpu] Window size: 3840x2304 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu] Video source: 3840x2160 (1:1)
24fpsDaVinci commented 7 months ago

i included the screenshot because the log was showing the correct size, which is odd. It is the full log but i removed a few status lines at the end

24fpsDaVinci commented 7 months ago

mpv.log this new output shows the incorrect size

KucharczykL commented 1 month ago

I am not sure whether this is the same issue but running the latest KDE Plasma under Wayland with 2x scaling, if I use --vo=gpu-next the resolution is multiplied by the scaling factor, if I use --vo=x11 the resolution is correct. This also affects things like --autofit-larger and --autofit-smaller where instead of, for example, 90%x90% resizing the video to mostly fill the screen it makes it overflow the screen dimensions.

Fiddling with --hidi-window-scale doesn't change anything.

stereomato commented 1 month ago

fwiw, under intel + gnome on wayland, resultion is fine with fractional scaling and dmabuf-wayland or gpu-next as vo