Bug 460675 - blurry screenshot under wayland with fractional scaling
Summary: blurry screenshot under wayland with fractional scaling
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-18 18:27 UTC by Toby
Modified: 2023-02-18 17:22 UTC (History)
4 users (show)

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


Attachments
Dolphin window across screen border (119.41 KB, image/png)
2023-02-16 14:07 UTC, Ye Jingchen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toby 2022-10-18 18:27:08 UTC
SUMMARY
Under KDE wayland, with fractional scaling, screenshots taken by Spectacle are blurry.


STEPS TO REPRODUCE
1. Login using wayland display server (should be default now), set the display scale to 175%
2. Take a screenshot with Spectacle


OBSERVED RESULT
The screenshot is blurry, like it is being scaled down and up again.

EXPECTED RESULT
The screenshot should look sharp like what is seen on screen

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 36
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.15-201.fc36.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i5-1035G4 CPU @ 1.10GHz
Memory: 7.5 GiB of RAM
Graphics Processor: Mesa Intel® Iris® Plus Graphics
Manufacturer: Acer
Product Name: Spin SP513-54N
System Version: V1.10
Comment 1 Nate Graham 2022-10-18 19:03:39 UTC
In fact that's exactly what's happening; this is how fractional scaling works on Wayland for the time being. It's an active area of work though, so hopefully it will be better with Plasma 5.27.
Comment 2 zvova7890 2023-01-09 13:27:12 UTC
kwin 5.26.5 and related components is achieved support for fractional scale protocol, and now content on the screen looks not blurry with non power of two scales! This bug was my critical blocker before I can move to wayland session. And now finally we have some initial support, that is great :)
But spectacle continues to take blurry screenshot. Also final image resolution is not match to monitor resolution. With 150% scale on monitor with resolution 2560x1440 - final spectacle image resolution is 2561x1440. This is some rounding issue, I assume.
Comment 3 Vlad Zahorodnii 2023-02-07 13:05:35 UTC
The reason why screenshots are blurry is that kwin downscales the window contents. 5.27 should be better. Note that the client side should also support fractional scaling. Qt should support fractional scaling in 6.5+
Comment 4 Ye Jingchen 2023-02-16 13:59:59 UTC
(In reply to Vlad Zahorodnii from comment #3)
> The reason why screenshots are blurry is that kwin downscales the window
> contents. 5.27 should be better. Note that the client side should also
> support fractional scaling. Qt should support fractional scaling in 6.5+

I think the situation is a bit frustrating even in 5.27, because I still can't get a screenshot that looks the same as what is on screen.

My theory is the same as what Toby described initially, that screenshots by Spectacle are way blurrier that on screen, not only because window content is scaled down (from 2x), but it's *scaled down and up again*, creating artifacts not present on screen.

Though I wonder whether this is caused by kwin sending blurry images to Spectacle, or Spectacle mess up scaling stuff internally.
Comment 5 Ye Jingchen 2023-02-16 14:07:04 UTC
Created attachment 156301 [details]
Dolphin window across screen border

I have two monitors side by side, the left one scaled at 200% and the right one 150%. This is what Spectacle takes after putting a Dolphin window at screen border: left half is pixel sharp, but the right half is weirdly scaled. To the eye, the right half roughly similar to the left half.

Using Plasma Wayland 5.27 on Arch Linux. GPU is AMD Radeon 680m (integrated graphics), mesa 22.3.4-1.
Comment 6 Toby 2023-02-17 22:40:12 UTC
I can confirm that the 5.27 update fixed my issue (Wayland, 1.75 scale, single monitor), so I suggest marking this as solved.

The multi-monitor case is more tricky and maybe should have its own separate issue.
Comment 7 Nate Graham 2023-02-17 22:43:35 UTC
Indeed, that would make sense.
Comment 8 Toby 2023-02-17 22:50:13 UTC
(In reply to Ye Jingchen from comment #4)
> (In reply to Vlad Zahorodnii from comment #3)
> > The reason why screenshots are blurry is that kwin downscales the window
> > contents. 5.27 should be better. Note that the client side should also
> > support fractional scaling. Qt should support fractional scaling in 6.5+
> 
> I think the situation is a bit frustrating even in 5.27, because I still
> can't get a screenshot that looks the same as what is on screen.
> 
> My theory is the same as what Toby described initially, that screenshots by
> Spectacle are way blurrier that on screen, not only because window content
> is scaled down (from 2x), but it's *scaled down and up again*, creating
> artifacts not present on screen.
> 
> Though I wonder whether this is caused by kwin sending blurry images to
> Spectacle, or Spectacle mess up scaling stuff internally.

5.27 worked for me on Fedora KDE. I tested by displaying an image with single-pixel dots on the screen and taking a screenshot, all dots are clearly visible and not blurry. I guess it could be a distribution-specific issue.
Comment 9 Toby 2023-02-17 22:51:06 UTC
(In reply to Toby from comment #8)
> (In reply to Ye Jingchen from comment #4)
> > (In reply to Vlad Zahorodnii from comment #3)
> > > The reason why screenshots are blurry is that kwin downscales the window
> > > contents. 5.27 should be better. Note that the client side should also
> > > support fractional scaling. Qt should support fractional scaling in 6.5+
> > 
> > I think the situation is a bit frustrating even in 5.27, because I still
> > can't get a screenshot that looks the same as what is on screen.
> > 
> > My theory is the same as what Toby described initially, that screenshots by
> > Spectacle are way blurrier that on screen, not only because window content
> > is scaled down (from 2x), but it's *scaled down and up again*, creating
> > artifacts not present on screen.
> > 
> > Though I wonder whether this is caused by kwin sending blurry images to
> > Spectacle, or Spectacle mess up scaling stuff internally.
> 
> 5.27 worked for me on Fedora KDE. I tested by displaying an image with
> single-pixel dots on the screen and taking a screenshot, all dots are
> clearly visible and not blurry. I guess it could be a distribution-specific
> issue.

Or might be related to multi-monitor setups
Comment 10 Ye Jingchen 2023-02-18 17:22:55 UTC
(In reply to Toby from comment #6)
> I can confirm that the 5.27 update fixed my issue (Wayland, 1.75 scale,
> single monitor), so I suggest marking this as solved.
> 
> The multi-monitor case is more tricky and maybe should have its own separate
> issue.

You're right, it works fine on a single monitor. I will open another issue.