Bug 487067 - Spectacle ignores delay option in main window
Summary: Spectacle ignores delay option in main window
Status: REOPENED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 24.02.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords:
: 486116 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-05-15 17:42 UTC by outfrost
Modified: 2025-02-26 19:01 UTC (History)
6 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description outfrost 2024-05-15 17:42:23 UTC
SUMMARY
When taking screenshots using buttons in the Spectacle main window, the "Delay" option is not taken into account. All screenshots are taken immediately, without waiting the set amount of time.

STEPS TO REPRODUCE
1. Open Spectacle main window (e.g. using PrintScreen on Plasma)
2. Set a non-zero delay, preferably 3+ seconds
3. Press "Rectangular Region"

OBSERVED RESULT
Screenshot is taken immediately and opens the cropping overlay right away

EXPECTED RESULT
Spectacle minimises its window, waits the set amount of time, then takes screenshot

SOFTWARE/OS VERSIONS
Windows: -
macOS: -
Linux/KDE Plasma: Manjaro Linux stable amd64, X11
(available in About System)
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION
Comment 1 Noah Davis 2024-05-15 22:22:58 UTC
Unfortunately, I cannot reproduce this on openSUSE Tumbleweed 240507 with 24.02 or git master. I've seen a few similar reports from other people, including someone who was on Fedora (bug 486116) and someone who was on Tuxedo OS2 with Spectacle 23.08.4 (bug 485240).
Comment 2 Noah Davis 2024-05-15 22:23:41 UTC
*** Bug 486116 has been marked as a duplicate of this bug. ***
Comment 3 Péter Ujfalusi 2024-05-21 11:42:39 UTC
Hi,

I can reproduce it on:
Operating System: Artix Linux 
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.8.9-artix1-2 (64-bit)
Graphics Platform: X11

$ spectacle --version
spectacle 24.02.2

Running it from console will result the following print and instantaneous screen capture even if the Delay is set to non 0:
$ spectacle
QVariantAnimation::setDuration: cannot set a negative duration
Comment 4 Tarulia 2024-08-24 04:54:16 UTC
Also seeing this on Fedora 40, Spectacle 24.05.2 with the same message in terminal as comment 3

Is there anything we can help with to debug this?
Comment 5 Waqar Ahmed 2024-08-28 11:36:19 UTC
Can confirm this, super annoying and makes spectacle useless in many scenarios :(

Also seeing the following, so at a high level the issue seems very obvious :

QVariantAnimation::setDuration: cannot set a negative duration
QVariantAnimation::setDuration: cannot set a negative duration
Comment 6 Waqar Ahmed 2024-08-28 12:35:47 UTC
I am running X11.

Are the supportedShutterModes incorrectly specified perhaps? I don't see the "Capture on click" button:

        text: i18n("Capture on click")
        visible: ImagePlatform.supportedShutterModes === (ImagePlatform.Immediate | ImagePlatform.OnClick)

The platform seems to be ImagePlatformKWin and it doesn't have OnClick.

More debug output from loadImagePlatform() function:

PlasmaVersion: 6 0 5
loadImagePlatform(): isReallyX11: true ScreenShotEffect::version():  4 ScreenShotEffect::isLoaded():  true PlasmaVersion::get(): 393221

---
workaround: force the xcb platform

export SPECTACLE_IMAGE_PLATFORM=ImagePlatformXcb
spectacle
Comment 7 Péter Ujfalusi 2024-08-28 12:50:37 UTC
Hi,

(In reply to Waqar Ahmed from comment #6)
> I am running X11.

I'm also, but I have a laptop with Wayland and it has the same issue.
 
> Are the supportedShutterModes incorrectly specified perhaps? I don't see the
> "Capture on click" button:

Me neither, I did not knew there should be such checkbox (neither on X11 or Wayland session)..

> workaround: force the xcb platform
> 
> export SPECTACLE_IMAGE_PLATFORM=ImagePlatformXcb
> spectacle

This makes spectacle working as expect.
Comment 8 Péter Ujfalusi 2024-08-28 19:40:32 UTC
The `export SPECTACLE_IMAGE_PLATFORM=ImagePlatformXcb` works with X11 while causes segfault on Wayland.

Interestingly on Wayland the delay actually works, but the checkbox is not visible.
Comment 9 Julian Pollak 2025-01-06 13:49:20 UTC
This also still happens in KDE Plasma Wayland session on Arch with the most recent version.

Spectacle: 24.12.0
KDE Frameworks: 6.9.0
Qt: Using 6.8.1 and built against 6.8.1
Arch Linux (Wayland)
Build ABI: x86_64-little_endian-lp64
Kernel: linux 6.12.8-arch1-1

The "Delay" simply gets ignored and every screenshot is taken immediately.
Comment 10 Julian Pollak 2025-01-06 13:55:50 UTC
(In reply to Julian Pollak from comment #9)
> This also still happens in KDE Plasma Wayland session on Arch with the most
> recent version.
> 
> Spectacle: 24.12.0
> KDE Frameworks: 6.9.0
> Qt: Using 6.8.1 and built against 6.8.1
> Arch Linux (Wayland)
> Build ABI: x86_64-little_endian-lp64
> Kernel: linux 6.12.8-arch1-1
> 
> The "Delay" simply gets ignored and every screenshot is taken immediately.

Investigating further, the issue seems to be intermittent. Right now, it is working just fine.
Comment 11 Waqar Ahmed 2025-01-29 08:33:09 UTC
This is such a massively annoying bug. I guess I need to now install a 3rdparty screenshot software because KDE keeps breaking basic shit.
Comment 12 Noah Davis 2025-01-29 17:46:05 UTC
Unfortunately, I have still never reproduced it.
Comment 13 Waqar Ahmed 2025-01-29 17:55:17 UTC
Ok, but did you read any of my comments above? There are explicit warnings from Qt, and some debug logs which might be helpful in debugging the issue or applying possible fixes. Even if that doesn't help, you can add logs / open a temporary MR with logging which I can pull and reproduce the issue which you can use to diagnose/fix the issue. (I am assuming you are an active spectacle dev)
Comment 14 Noah Davis 2025-01-29 21:04:25 UTC
It seem that I've already fixed the bug in October of last year.

*** This bug has been marked as a duplicate of bug 495216 ***
Comment 15 Waqar Ahmed 2025-01-30 06:16:38 UTC
Reopening. because
- Just pulled the latest master to check and no, I still can't take screenshots with a delay.
- its not a duplicate of the linked bug. I am not sure how you arrived at the conclusion

How I am testing (since the repo doesn't have any doc about new devs):
1. I build using kdesrc-build
2. I launched the app after sourcing prefix.sh with the command kdesrc-build --run spectacle
3. I get an error about kwin not allowing to do screenshots

After some searching and no results, I copy over the desktop file from ~/kde/usr/share/applications/org.kde.spectacle.desktop to my ~/.local/share/applications. Then launch spectacle again same as step 2 above. 

- Now it works without the kwin error
- set the delay to 3 seconds
- take screenshot -> takes screenshot (rect, active window, full screen) immediately

Let me know if this way of testing is incorrect.

Also, happy to help in any other way.
Comment 16 Noah Davis 2025-01-30 15:22:15 UTC
> Are the supportedShutterModes incorrectly specified perhaps? I don't see the "Capture on click" button:
> The platform seems to be ImagePlatformKWin and it doesn't have OnClick.

KWin doesn't support capture on click, so the code is correct. We only show the capture on click checkbox when you have a choice to use it. If a platform only has capture on click (the 1st version of the KWin screenshot API was like that), there's no point in presenting a checkbox that can't be unchecked.

(In reply to Waqar Ahmed from comment #15)
> - its not a duplicate of the linked bug. I am not sure how you arrived at
> the conclusion

"QVariantAnimation::setDuration: cannot set a negative duration" was what the linked bug fixed, which was an issue that caused the delay to fail.

> 3. I get an error about kwin not allowing to do screenshots

Spectacle has to be in the same install prefix to be allowed by KWin to use the KWin screenshot API. Make sure you are using KWin from your kdesrc-build environment. It is likely that despite copying the desktop file, you are still testing an older version of Spectacle.
Comment 17 Noah Davis 2025-01-30 15:24:33 UTC
> KWin doesn't support capture on click, so the code is correct. We only show the capture on click checkbox when you have a choice to use it. If a platform only has capture on click (the 1st version of the KWin screenshot API was like that), there's no point in presenting a checkbox that can't be unchecked.

In case my wording is confusing, what I mean is that the current version of KWin screenshot API doesn't support capture on click while an older version only supported it. There is still no point in showing the checkbox with either version of KWin screenshot API.
Comment 18 Waqar Ahmed 2025-01-31 05:21:46 UTC
> It is likely that despite copying the desktop file, you are still testing an older version of Spectacle.

I confirmed using the system monitor that the spectacle version was the one I built. 

But okay, there are more than 1 factors at play here and atm I dont have enough time/energy to fully try it out. So lets close this. I will upgrade to the newer version soon and will test then.
Comment 19 Waqar Ahmed 2025-02-05 18:50:33 UTC
Can confirm it works with spectacle 24.12.1

It didn't work right away. 
- I took a Rectangle Screenshot and the screenshot started immediately instead of delaying the specified amount of seconds
- When the screenshot UI appears, there is an "Options" button with menu. Inside the menu "Capture on Click" was checked. I unchecked that and after that it started working

So I think there is/was some unsynchronized state between the two gui elements after the update, maybe before as well?
Comment 20 Noah Davis 2025-02-05 19:25:33 UTC
(In reply to Waqar Ahmed from comment #19)
> So I think there is/was some unsynchronized state between the two gui
> elements after the update, maybe before as well?

Yes, that was another issue that was recently fixed. It has been backported to 24.12, so it might be released or it might be in an upcoming bugfix.
Comment 21 Tarulia 2025-02-08 01:53:06 UTC
I can also still reproduce this on 24.12.1 on Fedora 41 with an X11 session (Wayland isn't an option for me for unrelated reasons).

I had been using the environment variable proposed in Comment 6 since that comment was posted, and it still works.
I removed it for testing after this issue was closed and upon reboot I immediately get the faulty behaviour back:

- "Capture on click" button is missing
- Delay box is active, but doesn't have any effect

If I'm reading Comment 16 correctly:

> KWin doesn't support capture on click, so the code is correct.

That would still be a major regression compared to previous functionality. Of course that would need to be addressed in KWin if it's missing functionality on that side, but nevertheless it impacts Spectacle and this bug in particular.
There are many situations where capturing instantly is not an option, specifically for capturing tooltips or context menus among other things, because they immediately close when interacting with Spectacle in any way.

---

Side note: I don't quite understand the sentiment in Comment 11 when the same user was the one suggesting the (still functional) workaround 🤔
Comment 22 outfrost 2025-02-26 19:01:10 UTC
On my Manjaro stable with X11 the issue does not seem to occur any more, suggesting there is more than one root cause for this bug.

Spectacle: 24.12.2
KDE Frameworks: 6.10.0
Qt: Using 6.8.2 and built against 6.8.1
Manjaro Linux (Xcb)
Build ABI: x86_64-little_endian-lp64
Kernel: linux 6.12.12-2-MANJARO