Bug 430869 - Spectacle on Wayland not able to capture region on multi-monitor systems
Summary: Spectacle on Wayland not able to capture region on multi-monitor systems
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 20.12.0
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2020-12-27 22:43 UTC by zerocostabstraction
Modified: 2023-02-15 14:42 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zerocostabstraction 2020-12-27 22:43:18 UTC
SUMMARY
When trying to capture the region on Wayland I get the above error:
org.kde.spectacle.core: ERROR: images received from KWin do not match, expected: 1 actual: 2.

Turning off the secondary monitor makes the command work again. Although, curiously the "region capture" entry in the dropdown menu of spectacle is also gone. It is not gone on Xorg version of KDE.

STEPS TO REPRODUCE
1. spectacle -r in the terminal
2. Wait a few seconds
3. Error spits out, process doesn't end

OBSERVED RESULT
Error spit out.

EXPECTED RESULT
Region capture of a screenshot

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
/
Comment 1 Méven Car 2021-01-08 12:11:12 UTC
I guess you are using multiple scale factor, if that is the case, the rectangular selection cannot work until Plasma 5.21 (which is what the UI is suggesting by missing the option from the dropdown menu).

Please confirm, you have multiple scale factors, if that is the case we can close the bug as resolved for Plasma 5.21.
Comment 2 zerocostabstraction 2021-01-08 14:10:39 UTC
Both monitors run at scale factor 100% (in display configuration). And also, at the same refresh rate. So I'm not sure this applies to me.
Comment 3 Méven Car 2021-01-11 09:58:05 UTC
Did you plug in a screen after you launched or took a screenshot and this failure, or does it happen also when you start your system with two screens attached and active ?
Comment 4 zerocostabstraction 2021-01-11 10:02:21 UTC
(In reply to Méven Car from comment #3)
> Did you plug in a screen after you launched or took a screenshot and this
> failure, or does it happen also when you start your system with two screens
> attached and active ?

This happens when I boot up with both screens attached. As soon as I disconnected one of them (physically or in Display Configuration), everything works again. Once I re-connect them, it fails again.
Comment 5 Méven Car 2021-01-20 16:53:20 UTC
I suspect https://invent.kde.org/plasma/kwin/-/merge_requests/597 to fix this.

What is your screen configuration ?
Could you share the result of `kscreen-doctor -o`.
Comment 6 zerocostabstraction 2021-01-20 20:27:14 UTC
(In reply to Méven Car from comment #5)
> I suspect https://invent.kde.org/plasma/kwin/-/merge_requests/597 to fix
> this.
> 
> What is your screen configuration ?
> Could you share the result of `kscreen-doctor -o`.

Output: 33 XWAYLAND0 enabled connected  Unknown Modes: 36:1920x1080@60*! Geometry: 0,360 1920x1080 Scale: 1 Rotation: 1 
Output: 35 XWAYLAND1 enabled connected  Unknown Modes: 37:2560x1440@60*! Geometry: 1920,0 2560x1440 Scale: 1 Rotation: 1
Comment 7 Nate Graham 2021-02-01 19:33:33 UTC
Thanks.
Comment 8 zerocostabstraction 2021-02-17 15:26:45 UTC
(In reply to Méven Car from comment #5)
> I suspect https://invent.kde.org/plasma/kwin/-/merge_requests/597 to fix
> this.
> 
> What is your screen configuration ?
> Could you share the result of `kscreen-doctor -o`.

I've upgraded to 5.21. Currently experiencing this error:

spectacle -c -r
Icon theme "candy-icons" not found.
Error calling KWin DBus interface: "org.kde.kwin.Screenshot.Error.ScreenMissing" "Screen not found"
QPixmap::scaled: Pixmap is a null pixmap
Comment 9 zerocostabstraction 2021-02-17 15:28:00 UTC
Sorry for another comment, but I will report that I've since gotten a third monitor. Just in case it matters, this is my kscreen-doctor -o output:

Output: 33 XWAYLAND0 enabled connected  Unknown Modes: 38:1920x1080@60*! Geometry: 4480,360 1920x1080 Scale: 1 Rotation: 1 
Output: 35 XWAYLAND1 enabled connected  Unknown Modes: 38:1920x1080@60*! Geometry: 0,360 1920x1080 Scale: 1 Rotation: 1 
Output: 37 XWAYLAND2 enabled connected  Unknown Modes: 39:2560x1440@60*! Geometry: 1920,0 2560x1440 Scale: 1 Rotation: 1
Comment 10 Vlad Zahorodnii 2021-03-09 09:02:15 UTC
Git commit 1fb44b5bd500a32cb47062b41453848df1799f4f by Vlad Zahorodnii.
Committed on 09/03/2021 at 08:58.
Pushed by vladz into branch 'master'.

effects/screenshot: Prepare for versioned dbus interface

On Wayland, when the compositor sends a screenshot to the requesting
app, it encodes the screenshot as a PNG image and sends the encoded data
over the pipe. The requesting app (Spectacle) then needs to decode the
data.

The issue is that encoding PNG images is not cheap. This is the main
reason why Spectacle is shown with a huge delay after you press the
PrtScr key.

In order to fix the latency issue, we need to transfer raw image data.
Unfortunately, the current dbus api of the screenshot is too cluttered
and the best option at the moment is to start with a clean slate.

This change prepares the screenshot effect for versioned dbus interface.
Most of existing dbus logic was moved out in a separate class. In order
to schedule screen shots, the screenshot effect got some new API.

    QFuture<QImage> scheduleScreenShot(window, flags)
    QFuture<QImage> scheduleScreenShot(area, flags)
    QFuture<QImage> scheduleScreenShot(screen, flags)

If a dbus interface needs to take a screenshot, it needs to call one of
the overloaded scheduleScreenShot() functions. Every overload returns a
QFuture object that can be used for querying the result.

This change also introduces "sink" and "source" objects in the dbus api
implementation to simplify handling of QFuture objects.

Note that the QFutureInterface is undocumented, so if you use it, you do
it on your own risk. However, since Qt 5.15 is frozen for non-commercial
use and some other Plasma projects already use QFutureInterface, this
is not a big concern. For what it's worth, in Qt 6, there's the QPromise
class, which is equivalent to the QFutureInterface class.
Related: bug 433776

M  +1    -0    src/effects/screenshot/CMakeLists.txt
M  +307  -699  src/effects/screenshot/screenshot.cpp
M  +60   -139  src/effects/screenshot/screenshot.h
A  +860  -0    src/effects/screenshot/screenshotdbusinterface1.cpp     [License: GPL(v2.0+)]
C  +61   -74   src/effects/screenshot/screenshotdbusinterface1.h [from: src/effects/screenshot/screenshot.h - 066% similarity]

https://invent.kde.org/plasma/kwin/commit/1fb44b5bd500a32cb47062b41453848df1799f4f
Comment 11 Vlad Zahorodnii 2021-03-09 09:50:50 UTC
I believe that this issue should be fixed with kwin from git master. Can somebody please confirm it?
Comment 12 Nate Graham 2021-03-09 18:42:25 UTC
Confirmed fixed with a multi-monitor setup on Wayland.
Comment 13 zerocostabstraction 2021-04-16 22:57:23 UTC
(In reply to Nate Graham from comment #12)
> Confirmed fixed with a multi-monitor setup on Wayland.

When is this getting released? I'm on 5.21.4 and still not able to take screenshots.
Comment 14 Méven Car 2021-04-17 04:55:09 UTC
(In reply to zerocostabstraction from comment #13)
> (In reply to Nate Graham from comment #12)
> > Confirmed fixed with a multi-monitor setup on Wayland.
> 
> When is this getting released? I'm on 5.21.4 and still not able to take
> screenshots.

The fix will be part of Plasma 5.22 (it is written in the bug status), it is scheduled to be released in June.

In the meantime you can use X to make your screenshots.
Comment 15 zerocostabstraction 2021-06-12 08:49:40 UTC
Just upgraded to 5.22, and currently still getting a similar issue of not being able to screenshot on Wayland. The error output now is:

spectacle -c -r -b 
qt.qpa.wayland: EGL not available

This output is only on Wayland, and on a VEGA56 graphics card. And the region selection is again not showing up in the Spectacle dropdown. Can anyone else reproduce?
Comment 16 zerocostabstraction 2021-06-19 10:14:29 UTC
(In reply to zerocostabstraction from comment #15)
> Just upgraded to 5.22, and currently still getting a similar issue of not
> being able to screenshot on Wayland. The error output now is:
> 
> spectacle -c -r -b 
> qt.qpa.wayland: EGL not available
> 
> This output is only on Wayland, and on a VEGA56 graphics card. And the
> region selection is again not showing up in the Spectacle dropdown. Can
> anyone else reproduce?

Sorry for messing up, it appears I have accidentally installed Spectacle through nix. The correct error output on wayland right now is:

Screenshot request failed: "Invalid screen requested"
Comment 17 dct 2023-02-15 14:17:05 UTC
This issue is still present with 5.27.0 just released. Error is: Screenshot request failed: "Invalid screen requested"
Comment 18 Nate Graham 2023-02-15 14:42:50 UTC
Spectacle isn't a part of Plasma. Please re-test with Spectacle's upcoming 23.04 release. If it's still an issue, please open a new bug report as the root cause may be different.