Bug 488233 - [wayland] Rectangle Region Recordings Have Incorrect Resolution on Scaled Displays
Summary: [wayland] Rectangle Region Recordings Have Incorrect Resolution on Scaled Dis...
Status: REPORTED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-08 23:59 UTC by Eamonn Rea
Modified: 2025-02-18 22:47 UTC (History)
6 users (show)

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


Attachments
Resolution of this rectangular area is completely wrong (258.63 KB, video/mp4)
2024-10-27 16:49 UTC, Oleg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eamonn Rea 2024-06-08 23:59:46 UTC
SUMMARY
Rectangle Region Recordings have incorrect resolution on scaled displays.

A region taking up most of a 3840x2160 display @ 150% scaling will have a resolution of approximately 5,000 across by 2,800 pixels down.

Region screenshots have a very similar problem, except that affects scaled and unscaled displays. In the case of screen recordings, the resolution is correct for recordings on non-scaled displays.

The compression used (or default compression settings if it's configurable?) means that the filesize and video quality are not particularly adversely affected here, so it is not as much of an issue.

There is a similar issue with Single-Window recordings, but I will report that separately as the resolution problem is different.

It is worth noting that single screen recordings ("Record Screen") work correctly and use the correct resolution.

STEPS TO REPRODUCE
1. Record a Region Screenshot on a scaled display.
2. Save it.
3. The resolution will be incorrect.

OBSERVED RESULT
The resolution for Rectangle Region Recordings is incorrect.

EXPECTED RESULT
The resolution for Rectangle Region Recordings should be the same resolution as though the Screen recording resolution were cropped down.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 6.9.3 Linux Zen
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1

ADDITIONAL INFORMATION
I took a look at the codebase out of curiosity. C++ is outside of my wheelhouse, doubly so for anything specific to Qt/Wayland (although I am hoping to learn more overtime as it is a fascination of mine!). I'm not saying I found anything here that should be fixed, more that for my own understanding of what the problem is I wanted to point to a few areas in the code :-)
- For Screen recordings (which call Screencasting::createOutputStream), it looks like the native wl_output is used, which I guess returns the raw 3840x2160 (https://invent.kde.org/graphics/spectacle/-/blob/3f6c5b6c7207959221d225ea0c6d0b03c82fa16f/src/Platforms/screencasting.cpp#L101). I guess this is why single-screen recordings work?
- For Region recordings (which calls Screencasting::createRegionStream) it seems to use the QScreen(?) geometry which is then increased by the scaling. However I think QScreen geometry might be returning 2560x1440 for the width/height (which is the 150% scaled value of my 3840x2160 display), which is then multiplied by a scale factor of 2 (instead of 1.5, possibly intentionally, given the use of std::max (https://invent.kde.org/graphics/spectacle/-/blob/3f6c5b6c7207959221d225ea0c6d0b03c82fa16f/src/Platforms/VideoPlatformWayland.cpp#L192)), which would give 5120 and that would line up with my approximate 5,000x2,800 resolution (allowing for the fact that my region didn't encompass the entire screen and had some margin on all sides).
    - I guess a sub-question here if the scale factor is rounded up is, why? Something specific to rounding pixels with fractional-scale-v1? If so, once implemented in Qt and Plasma, could fractional-scale-v2 also fix this the same way it can fix other issues with fractional scales? As many Wayland devs evangelise, "screens don't have fractional pixels" so perhaps that's the reasoning of the rounding here? I'm not saying it's wrong, you and the KDE folks know better than me for sure, just wondering!
- For Window recordings, I'm not sure, I couldn't find how that part works (I got as far as here: https://invent.kde.org/graphics/spectacle/-/blob/3f6c5b6c7207959221d225ea0c6d0b03c82fa16f/src/Platforms/screencasting.cpp#L121). Although my guess would be that it uses QScreen geometry without any scaling, which is why a window maximised on my scaled display would give 2560x1440, since unscaled QScreen geometry may be returning that value?
Comment 1 Aleksander 2024-10-04 11:32:24 UTC
Can confirm. KDE Plasma 6.1.5, Qt 6.7.2, Wayland, 150% scale.
Comment 2 Oleg 2024-10-27 16:49:15 UTC
Created attachment 175279 [details]
Resolution of this rectangular area is completely wrong

Can confirm

Operating System: Arch Linux 
KDE Plasma Version: 6.2.2
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.5-2-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700K CPU @ 4.20GHz
Memory: 15.6 ГиБ of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Comment 3 Eamonn Rea 2025-02-18 22:47:49 UTC
This bug is still present in Plasma 6.3.1.