clapper icon indicating copy to clipboard operation
clapper copied to clipboard

Wrong detected fullscreen display resolution on multi-monitors setup

Open peteruithoven opened this issue 3 years ago • 15 comments
trafficstars

I have a laptop with a connected external monitor. I noticed that I'm only seeing things like the file name, current time, ends at ... when I fullscreen Clapper on my build in laptop screen. That is the OSD?

It doesn't seem to matter which is the primary screen.

Laptop screen: 2256 x 1504 External monitor: 3840 x 2160 Scaling factor: 2x This scaling factor leads to: Laptop screen: 1128 x 752 External monitor: 1920 x 1080

Laptop screen

Screenshot build in laptop screen

External monitor

Screenshot external monitor

Version: 0.5.2 Installed as Flatpak from Flathub.

peteruithoven avatar Jul 07 '22 21:07 peteruithoven

I wonder whether it has something to do with these checks? https://github.com/Rafostar/clapper/blob/9885a2f424e732c57ea02c8723d197c5ca8a0c16/src/revealers.js#L182-L185

peteruithoven avatar Jul 07 '22 21:07 peteruithoven

I assume the file name, current time etc is the OSD?

Both are the same OSD. Application has 2 display modes with different scaling, styles applied, etc. What you are seeing in first screen is the normal, desktop display mode (called TV mode in the code you attached). The other one is a mobile mode, meant to be shown on low application pixels screens (e.g. PinePhone, Librem 5, etc.). Otherwise UI wouldn't fit all kinds of displays.

The app tracks the display dimensions where its window is on right now and changes mode accordingly. With your laptop being 2256x1504 and scaling 2x => 1128x752 application pixels which is below HD where we go with mobile mode. While your external display is 1920x1080 application pixels, so we should be fine with normal mode.

Basically the problem here is that the mode you see on external monitor should be displayed on your laptop screen (with your 2x scaling) and vice-versa. Otherwise, as seen in your screenshots, UI on laptop is too big and on external screen is too small.

Try running:

DEBUG=Clapper flatpak run com.github.rafostar.Clapper

There should be lines like this printed:

Clapper monitor application-pixels: 1920x1080 +101µs
Clapper mobile monitor detected: false +26µs
Clapper using scaling mode: normal +217µs

Please check what these print in your configuration while moving the app window or starting it (dunno if you have this issue in multi monitor setup or with only one turned on at a time) between your 2 displays. The values should match the display where app is currently on and fullscreening it should not give mobile mode when display app-pixels width is over 1280.

Rafostar avatar Jul 08 '22 07:07 Rafostar

Ah interesting. These are the relevant looking debug lines when I open Clapper on my external monitor:

Clapper entered new monitor +2.264ms
Clapper monitor application-pixels: 1128x752 +20?s
Clapper mobile monitor detected: true +10?s
Clapper entered new monitor +3.542ms
Clapper monitor application-pixels: 1920x1080 +39?s
Clapper mobile monitor detected: false +13?s
Clapper using scaling mode: hires +65?s

When I drag the window to my build in laptop screen:

Clapper entered new monitor +3.729s
Clapper monitor application-pixels: 1128x752 +82?s
Clapper mobile monitor detected: true +23?s

When I drag the window back to the external monitor:

Clapper entered new monitor +1.969s
Clapper monitor application-pixels: 1920x1080 +108?s
Clapper mobile monitor detected: false +32?s
Clapper using scaling mode: hires +148?s

peteruithoven avatar Jul 08 '22 07:07 peteruithoven

Hmm. From your log, it works as expected. With this debug enabled, try going fullscreen after dragging to monitor. I would like to check if all this isn't printed again (check if detection isn't performed again) incorrectly when app goes fullscreen and if UI still appears wrong compared to what is printed.

Rafostar avatar Jul 08 '22 08:07 Rafostar

Dragging to build in laptop screen, going to and from fullscreen:

Clapper entered new monitor +8.224s
Clapper monitor application-pixels: 1128x752 +80?s
Clapper mobile monitor detected: true +38?s
Clapper changing fullscreen mode +1.094s
Clapper interface in fullscreen mode: true +979?s
Clapper entered new monitor +293?s
Clapper monitor application-pixels: 1920x1080 +41?s
Clapper mobile monitor detected: false +16?s
Clapper using scaling mode: hires +59?s
Clapper setting update time interval +483.471ms
Clapper updated current time: 10?20, ends at: unknown +533?s

Screenshot from 2022-07-08 10-20-35@2x

Dragging to external monitor, going to and from fullscreen:

Clapper entered new monitor +7.437s
Clapper monitor application-pixels: 1920x1080 +92?s
Clapper mobile monitor detected: false +31?s
Clapper using scaling mode: hires +134?s
Clapper changing fullscreen mode +1.513s
Clapper setting update time interval +755?s
Clapper updated current time: 10?22, ends at: unknown +466?s
Clapper interface in fullscreen mode: true +116?s
Clapper entered new monitor +270?s
Clapper monitor application-pixels: 1128x752 +70?s
Clapper mobile monitor detected: true +12?s
Clapper cleared update time interval +800.201ms
Clapper changing fullscreen mode +49.902ms
Clapper interface in fullscreen mode: false +325?s

Screenshot from 2022-07-08 10-23-16@2x

(Sorry I pressed the wrong button there for a moment and closed the issue)

It actually looks like it thinks it's on the other monitor when it's going fullscreen...

peteruithoven avatar Jul 08 '22 08:07 peteruithoven

A bit more info on my setup: OS: elementary OS 6.1 Jólnir (Built on Ubuntu 20.04.3 LTS) Kernel: Linux 5.13.0-52-generic Window Manager: Gala

A window & compositing manager based on libmutter and designed by elementary for use with Pantheon.

Mutter version that I assume is used for Gala:

libmutter-6-0/focal-updates,now 3.36.9-0ubuntu0.20.04.2 amd64 [installed,automatic]
  window manager library from the Mutter window manager
libmutter-6-dev/focal-updates,now 3.36.9-0ubuntu0.20.04.2 amd64 [installed,automatic]
  Development files for the Mutter window manager

Framework laptop Quad-Core 11th Gen Intel® Core™ i7-1185G7 @ 3.00GHz Intel® Xe Graphics (TGL GT2)

peteruithoven avatar Jul 08 '22 08:07 peteruithoven

It actually looks like it thinks it's on the other monitor when it's going fullscreen...

Ah yes, as I suspected. The display tracking works correctly, but when you go fullscreen the enter-monitor signal is fired again and for some reason it passes wrong GdkMonitor as arg with it.

We do not seem to be doing anything wrong here. Seems to be either your window manager issue or a GTK4 issue. I do not have a multiple monitors at hand right now (today) to check how Mutter behaves here.

Rafostar avatar Jul 08 '22 08:07 Rafostar

That makes sense. I'd love to know whether it's a gala or mutter issue.

I'm not really finding relevant issues for mutter: https://gitlab.gnome.org/GNOME/mutter/-/issues/

Nor for Gala: https://github.com/elementary/gala/issues

But I have to admit that Gala is probably the weakest link here, in terms of community & contributors size.

I have one suspicion, Gala puts fullscreened apps into their own new workspace, something might be going wrong there. But currently I'm not sure how to disable that. See: https://github.com/elementary/gala/discussions/1444 Update: Found a way to disable it, didn't make a difference.

peteruithoven avatar Jul 08 '22 09:07 peteruithoven

But I have to admit that Gala is probably the weakest link here, in terms of community & contributors size.

The lack of Wayland support in Elementary OS is also a minus. GTK4 nowadays targets (most work and testing goes towards) Wayland support, thus it seems to have more Xorg bugs nowadays. Clapper HW decoding performance will also take a huge hit compared to Wayland due to lack of dma-bufs, but that's unrelated to this issue.

Rafostar avatar Jul 08 '22 10:07 Rafostar

Did you get a change to test this with Mutter?

I've opened an issue with Gala for now: https://github.com/elementary/gala/issues/1445

Since this is probably not Clapper's fault should we close the issue?

peteruithoven avatar Jul 10 '22 09:07 peteruithoven

@peteruithoven

I did similar multi-display setup to test. I was able to reproduce with GNOME Shell 42, Wayland session. So not a Gala fault. Either Mutter which both Gala and GNOME use or a bug in GTK4 from where this signal with wrong display comes from.

Also regarding your other problem, where you said:

The pixel perfect ratio is indeed my main consideration. And the fact that my external monitor is perfect at 200% and I can't easily have a different scaling factor per screen.

FYI, on GNOME Shell Wayland session (tried on Fedora 36), once frictional scaling is enabled, I can easily set different scaling per-display from system settings app which makes this super easy.

Rafostar avatar Jul 11 '22 10:07 Rafostar

Ah, thanks for testing. I'll close the Gala issue.

FYI, on GNOME Shell Wayland session (tried on Fedora 36), once frictional scaling is enabled, I can easily set different scaling per-display from system settings app which makes this super easy.

Yeah, and this is really a my problem, but elementary OS doesn't really believe in the whole fractional scaling thing. It's just 1x, 2x, 3x. They do allow increasing text sizes for example. But even one of the co-founders reached to 1,5 using xrandr with the frame.work laptop: https://community.frame.work/t/using-elementary-os-on-the-framework-laptop/4453#display-scaling-5

peteruithoven avatar Jul 11 '22 10:07 peteruithoven

Not really finding relevant issues at gtk btw https://gitlab.gnome.org/GNOME/gtk/-/issues/

peteruithoven avatar Jul 11 '22 10:07 peteruithoven

Yeah, and this is really a my problem, but elementary OS doesn't really believe in the whole fractional scaling thing. It's just 1x, 2x, 3x.

With frictional scaling enabled, I have 100% (1x), 125%, 150%, 175%, 200% etc. options to select in system display setting. Can be set per-screen. I can say, it works great. Seems your shell is missing this unfortunately.

Not really finding relevant issues at gtk btw

Maybe you are just the first one to notice ;-). There definitely is something wrong going on with this signal. Sometimes when I quickly drag app between 2 screens its not being emitted at all.

Rafostar avatar Jul 11 '22 11:07 Rafostar

Taking a peek at GTK4 implementation, its really simple code, doesn't look wrong either: https://gitlab.gnome.org/GNOME/gtk/-/blob/636827800525770715bba96671edb2fc0234ccc2/gdk/wayland/gdksurface-wayland.c#L1339 where gdk_surface_enter_monitor() method called at the end of surface_enter function emits signal which passes monitor data to Clapper.

Rafostar avatar Jul 11 '22 15:07 Rafostar