mpv icon indicating copy to clipboard operation
mpv copied to clipboard

wayland hidpi scaling behavior 3840x2160 opens as 11520x6480

Open 24fpsDaVinci opened this issue 1 year ago • 35 comments

Important Information

Provide following Information:

  • mpv version: master
  • Linux Distribution and Version: fedora 38
  • Source of the mpv binary: master
  • If known which version of mpv introduced the problem: latest
  • Window Manager and version: mutter44 wayland latest
  • GPU driver and version: intel igpu

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?

24fpsDaVinci avatar Mar 20 '23 17:03 24fpsDaVinci

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 avatar Mar 20 '23 17:03 Dudemanguy

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

Dudemanguy avatar May 04 '23 17:05 Dudemanguy

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

24fpsDaVinci avatar May 04 '23 17:05 24fpsDaVinci

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.

Dudemanguy avatar May 04 '23 18:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 00:05 24fpsDaVinci

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

Dudemanguy avatar May 05 '23 02:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 02:05 24fpsDaVinci

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 avatar May 05 '23 02:05 Dudemanguy

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]  -> [email protected]_registry(new id wl_registry@2)
[3484499.386]  -> [email protected](new id wl_callback@3)
[3484499.440] [email protected]_id(3)
[3484499.445] [email protected](1, "wl_shm", 1)
[3484499.449]  -> [email protected](1, "wl_shm", 1, new id [unknown]@4)
[3484499.452] [email protected](2, "wl_drm", 2)
[3484499.455] [email protected](3, "zwp_linux_dmabuf_v1", 4)
[3484499.457]  -> [email protected](3, "zwp_linux_dmabuf_v1", 4, new id [unknown]@5)
[3484499.459]  -> [email protected]_default_feedback(new id zwp_linux_dmabuf_feedback_v1@6)
[3484499.462] [email protected](4, "wl_compositor", 5)
[3484499.464]  -> [email protected](4, "wl_compositor", 4, new id [unknown]@7)
[3484499.466]  -> [email protected]_surface(new id wl_surface@8)
[3484499.468]  -> [email protected]_surface(new id wl_surface@9)
[3484499.470]  -> [email protected]_region(new id wl_region@10)
[3484499.471]  -> [email protected]_input_region(wl_region@10)
[3484499.473]  -> [email protected]()

Dudemanguy avatar May 05 '23 03:05 Dudemanguy

I think you uploaded the wrong log

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

24fpsDaVinci avatar May 05 '23 14:05 24fpsDaVinci

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

Dudemanguy avatar May 05 '23 14:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 15:05 24fpsDaVinci

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)

Dudemanguy avatar May 05 '23 16:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 16:05 24fpsDaVinci

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?

Dudemanguy avatar May 05 '23 16:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 20:05 24fpsDaVinci

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)

Dudemanguy avatar May 05 '23 21:05 Dudemanguy

still happening with the patch mpv.log

24fpsDaVinci avatar May 05 '23 21:05 24fpsDaVinci

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);

Dudemanguy avatar May 05 '23 22:05 Dudemanguy

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)

24fpsDaVinci avatar May 05 '23 22:05 24fpsDaVinci

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

Dudemanguy avatar May 05 '23 22:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 22:05 24fpsDaVinci

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.

Dudemanguy avatar May 05 '23 22:05 Dudemanguy

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

24fpsDaVinci avatar May 05 '23 22:05 24fpsDaVinci

I'm out of ideas unfortunately.

Dudemanguy avatar May 06 '23 00:05 Dudemanguy

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

24fpsDaVinci avatar Jan 18 '24 02:01 24fpsDaVinci

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 avatar Jan 21 '24 05:01 Dudemanguy

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.

Dudemanguy avatar Jan 21 '24 14:01 Dudemanguy

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

24fpsDaVinci avatar Jan 21 '24 15:01 24fpsDaVinci

mpv.log added new log using latest main branch

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

24fpsDaVinci avatar Jan 28 '24 04:01 24fpsDaVinci