Bug 490777 - Default scale is miscalculated for screen that mis-reports its physical height to be very small but not zero
Summary: Default scale is miscalculated for screen that mis-reports its physical heigh...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 6.1.1
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-24 14:07 UTC by fuemaknew
Modified: 2024-07-30 03:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 6.2.0
Sentry Crash Report:


Attachments
photo of wayland config file for kde plasma, highligting the dpi (2.60 MB, image/jpeg)
2024-07-24 14:07 UTC, fuemaknew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fuemaknew 2024-07-24 14:07:50 UTC
Created attachment 171956 [details]
photo of wayland config file for kde plasma, highligting the dpi

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
Kde plasma installion on any distro results to this bug where dpi is comically high instead of 96.
STEPS TO REPRODUCE
1. install distro
2. install kde and sddm if not already there
this is all default
OBSERVED RESULT
Dpi is set to 294912
Scaling is set to 300%
EXPECTED RESULT
Dpi set to 96
Scaling is set to 100%
SOFTWARE/OS VERSIONS
Windows:  --
macOS:  --
Linux/KDE Plasma: Any linux distro, 6.1.1
(available in About System)
KDE Plasma Version: 6.1.1
KDE Frameworks Version: 6.30
Qt Version: 6.7.2

ADDITIONAL INFORMATION
large display but 1080p. don't know if that matters.
Comment 1 Nate Graham 2024-07-24 19:13:51 UTC
Does it happen with only that specific screen? Do you have any others you can test with? Can you attach your ~/.config/kwinoutputconfig.json file?
Comment 2 fuemaknew 2024-07-25 06:59:34 UTC
(In reply to Nate Graham from comment #1)
> Does it happen with only that specific screen? Do you have any others you
> can test with? Can you attach your ~/.config/kwinoutputconfig.json file?

"[v0id@localhost ~]$ cat ~/.config/kwinoutputconfig.json
[
    {
        "data": [
            {
                "autoRotation": "InTabletMode",
                "brightness": 1,
                "colorProfileSource": "sRGB",
                "connectorName": "HDMI-A-1",
                "edidHash": "d5a6392353c14421115ec9cd4dde234c",
                "edidIdentifier": "SAM 1641 1 47 2009 0",
                "highDynamicRange": false,
                "iccProfilePath": "",
                "mode": {
                    "height": 1080,
                    "refreshRate": 60000,
                    "width": 1920
                },
                "overscan": 0,
                "rgbRange": "Automatic",
                "scale": 3,
                "sdrBrightness": 200,
                "sdrGamutWideness": 0,
                "transform": "Normal",
                "vrrPolicy": "Automatic",
                "wideColorGamut": false
            }
        ],
        "name": "outputs"
    },
    {
        "data": [
            {
                "lidClosed": false,
                "outputs": [
                    {
                        "enabled": true,
                        "outputIndex": 0,
                        "position": {
                            "x": 0,
                            "y": 0
                        },
                        "priority": 0
                    }
                ]
            }
        ],
        "name": "setups"
    }
]
[v0id@localhost ~]$   " I don't have any other screens to test, I have 2 other laptops and they work fine. It could be because I have a very large screen that is low resolution, 1080p. Every time I install kde plasma (void linux, kde neon, endeavour os...) on this system with this display, the scaling is set to 300% on default but sometimes It is set to 100% even though the screen is still large, The dpi setting for wayland is always very high on default. I attached the file you requested.
Comment 3 Nate Graham 2024-07-25 16:35:29 UTC
Thanks. What are the physical dimensions of the screen area?
Comment 4 fuemaknew 2024-07-26 08:38:27 UTC
(In reply to Nate Graham from comment #3)
> Thanks. What are the physical dimensions of the screen area?

I tried to measure,
38,5 cm~ height    73,2cm~ width.
Like I said it is 1080p.
Comment 5 Nate Graham 2024-07-29 22:09:44 UTC
Sounds like 32" diagonal, which means 69 DPI. Which means the automatically-calculated scale factor should actually be 75%, not 300%!

I see that you found the DPI that GTK calculated was 294912. Which is, um, quite a bit more than 69. If you plug that into our scale calculator, it spits out a scale factor of 307,200%. Which is, um, far too high. So our algorithm notices this and caps it to 300%, the maximum value.

The fact that both GTK and Qt get the wrong DPI means that your monitor is reporting the wrong physical size, which causes both toolkits to mis-calculate its DPI, and than that garbage value gets fed into the scale calculator.

It appears that the screen is reporting itself as having a 0.2mm diagonal measurement. So now I see why this happens: it doesn't trigger the special code to detect dumb screens that triggers if the width or height is zero; it's cleverly reporting itself as slightly larger than zero, but still not a sane size.

I think we can adjust this check to also check for slightly-higher-than-zero dimensions that are nonetheless too small to be usable.
Comment 6 Bug Janitor Service 2024-07-29 22:26:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6180
Comment 7 Nate Graham 2024-07-30 03:25:52 UTC
Git commit f015b73a48576b249bf0a424543d544326ca8b35 by Nate Graham.
Committed on 30/07/2024 at 03:16.
Pushed by ngraham into branch 'master'.

Loosen minimum screen size detection code for output scale calculation

We return early for screens with physical height reported as ≤ 0mm.

However some extremely dumb screens report a value for their height
greater than zero but absurdly small, causing the scale calculator to
go ballistic. Theoretically this could happen for widths, too.

Let's loosen the detection to flag a physical screen size as invalid if
either its width or height is less than 3mm. There is no screen that
can possibly make sense to exist at this physical size given the angular
resolution of the human eyeball. And if for some reason it does, 100%
scale is fine for it.
FIXED-IN: 6.2.0

M  +3    -2    src/outputconfigurationstore.cpp

https://invent.kde.org/plasma/kwin/-/commit/f015b73a48576b249bf0a424543d544326ca8b35