Bug 483876

Summary: Spectacle takes blurry screenshots depending on the window position on Wayland with 1.5 fractional scale
Product: [Plasma] kwin Reporter: zvova7890
Component: compositingAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: andrea.ippo, mobile.harvey, nate, noahadvs, nyanpasu64, zvova7890
Priority: NOR Keywords: qt6, wayland
Version: 6.0.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.0.5
Sentry Crash Report:
Attachments: Clear screenshot
Blurred screenshot
Zoom comparison
photo from phone
blurry from spectacle
less blurry from spectacle (if window moved to laptop display and region captured there)
screen recording

Description zvova7890 2024-03-18 01:13:48 UTC
SUMMARY:
I was trying to figure out why Spectacle is getting blurred screenshots and discovered an interesting problem, and now Spectacle is not guilty. Apparently, KWin has some rounding-related issues when it creates an image from the surface (window). It seems that when the window position can't be divided by the scale factor into an integer value, KWin returns a little bit blurred screenshot, which Spectacle saves as it comes. Maybe it also depends on the window size, but I'm not sure.

STEPS TO REPRODUCE:
1. Set the scale factor to 1.5.
2. Open some window, for example Konsole.
3. Put it at the 0x0 coordinates (top-left corner). Also, for just in case, ensure that the current window size can be divided by 1.5 without problems.
4. Take a screenshot and save it as a file.
5. Then move this window to somewhere to achieve an XY value that can't be divided by 1.5.
6. Take another screenshot and save it as a file.
7. Open it in GIMP and compare font glyphs.

OBSERVED RESULT
The screenshot is blurred

EXPECTED RESULT
Crystal clear screenshot whatever coordinates it was

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.8.1-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 9 7940HS w/ Radeon 780M Graphics
Memory: 28,2 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Micro Computer (HK) Tech Limited
Product Name: Venus series
Comment 1 zvova7890 2024-03-18 01:18:56 UTC
Created attachment 167392 [details]
Clear screenshot
Comment 2 zvova7890 2024-03-18 01:19:24 UTC
Created attachment 167393 [details]
Blurred screenshot
Comment 3 zvova7890 2024-03-18 01:19:45 UTC
Created attachment 167394 [details]
Zoom comparison
Comment 4 Bug Janitor Service 2024-03-24 20:24:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5516
Comment 5 Nick 2024-03-24 21:09:13 UTC
I can duplicate this on Neon 6.0.2 Wayland with the instructions provided. Thanks.
Comment 6 Nate Graham 2024-04-04 19:47:58 UTC
Noah, is this different from Bug 478426?
Comment 7 Noah Davis 2024-04-04 19:58:59 UTC
(In reply to Nate Graham from comment #6)
> Noah, is this different from Bug 478426?

yes
Comment 8 Nate Graham 2024-05-20 16:35:20 UTC
This is fixed with the commits in https://invent.kde.org/plasma/kwin/-/merge_requests/5516, authored by Volodymyr Zolotopupov. They'll appear in Plasma 6.0.5
Comment 9 zvova7890 2024-05-20 18:04:50 UTC
Yep, that's me :) 
Thanks for the merge!
Comment 10 Andrea Ippolito 2024-07-15 09:24:03 UTC
My screenshots taken on the external display are still blurry, am I missing the correct version containing the fix?

Thanks

Operating System: openSUSE Tumbleweed 20240714
KDE Plasma Version: 6.1.2
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2
Kernel Version: 6.9.9-1-default (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Memory: 30.7 GiB of RAM
Graphics Processor: AMD Radeon 780M
Manufacturer: Framework
Product Name: Laptop 13 (AMD Ryzen 7040Series)
System Version: A7
Comment 11 zvova7890 2024-07-15 13:48:20 UTC
Are you talking about a full screen collage?

This issue is about a blurry window or rectangular screenshot.
Comment 12 Andrea Ippolito 2024-07-15 13:56:47 UTC
(In reply to zvova7890 from comment #11)
> Are you talking about a full screen collage?
> 
> This issue is about a blurry window or rectangular screenshot.

I'm talking of a rectangular region indeed. Attaching photo from phone VS captured by spectacle.
Comment 13 Andrea Ippolito 2024-07-15 13:57:32 UTC
Created attachment 171674 [details]
photo from phone
Comment 14 Andrea Ippolito 2024-07-15 13:58:02 UTC
Created attachment 171675 [details]
blurry from spectacle
Comment 15 Andrea Ippolito 2024-07-15 13:59:40 UTC
Created attachment 171676 [details]
less blurry from spectacle (if window moved to laptop display and region captured there)
Comment 16 zvova7890 2024-07-15 20:11:24 UTC
Just to be clear: are you comparing the results by viewing them in Spectacle? Is the saved result equally blurry?
Comment 17 Andrea Ippolito 2024-07-15 21:23:55 UTC
(In reply to zvova7890 from comment #16)
> Just to be clear: are you comparing the results by viewing them in
> Spectacle? Is the saved result equally blurry?

Hi, no the "blurry from spectacle" is captured with spectacle and then opened in gwenview. On my laptop it shows blurry (I dunno if it's a problem with gwenview, I hope you see it blurry as well)
Comment 18 Andrea Ippolito 2024-07-15 21:28:29 UTC
Created attachment 171691 [details]
screen recording
Comment 19 Andrea Ippolito 2024-07-15 21:30:57 UTC
The image is also bigger than the actual content.

Although gwenview confirms it's displaying it at 100%, you can clearly see that the text in the captured screenshot has not the original size.

My screen configuration:
laptop display 2256x1504@120%
external monitor 2560x1440@100% -> this is where the capture happens
Comment 20 zvova7890 2024-07-15 22:26:12 UTC
Now I see. It is a problem with rectangular screenshots in multiscreen systems with different output scale. The windowed screenshots are just fine. It is a separate issue. While this issue is about screenshot clarity depending on the window's(or rectangle) position and size. Please file another issue. 

It seems Spectacle is taking a composited image from all screens, regardless of whether it is making a rectangle for only one screen or if the rectangle joins several screens. The selected part is then cropped from this composited image, which is blurred under Wayland.
Comment 21 Andrea Ippolito 2024-07-16 11:49:11 UTC
(In reply to zvova7890 from comment #20)
> Now I see. It is a problem with rectangular screenshots in multiscreen
> systems with different output scale. The windowed screenshots are just fine.
> It is a separate issue. While this issue is about screenshot clarity
> depending on the window's(or rectangle) position and size. Please file
> another issue. 
> 
> It seems Spectacle is taking a composited image from all screens, regardless
> of whether it is making a rectangle for only one screen or if the rectangle
> joins several screens. The selected part is then cropped from this
> composited image, which is blurred under Wayland.

Hi, and thanks.

I followed your advice and filed it as bug 490353