Bug 484652 - [REGRESSION] Rectangle screenshot now includes spectacle window when `picom` is running
Summary: [REGRESSION] Rectangle screenshot now includes spectacle window when `picom` ...
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 24.02.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-28 09:15 UTC by Konstantin Kharlamov
Modified: 2024-04-05 18:56 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 24.02.2


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kharlamov 2024-03-28 09:15:50 UTC
SUMMARY

After updating to KDE6 `spectacle` no longer becomes invisible for the duration of making rectangular screenshot when `picom` is running. It seems to be spectale's problem and not picom's because of the two only spectacle got upgraded.

STEPS TO REPRODUCE

1. Put this config¹ to `~/.config/` dir
2. Start `picom`
3. Run `spectacle`
4. Press `Rectangular Region` button, which will start the process of making rectangular selection

OBSERVED RESULT

Spectacle window either does not disappear, or it may partially disappear leaving a transparent rectangle behind, in which case pressing Escape and `Rectangular Region` again would make the next time full window appear rather than gray rectangle.

EXPECTED RESULT

Spectacle window would just disappear.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2

-----------------------

1: https://github.com/Hi-Angel/dotfiles/blob/master/.config/picom.conf
Comment 1 Konstantin Kharlamov 2024-03-28 10:10:56 UTC
Tried bisecting. Older commits are unbuildable, probably due to deps, but I found that the problem appeared before commit

    ee79807a GIT_SILENT: use QStringLiteral. Avoiding runtime conversions including memallocs

when exactly is unclear.

-----------------------

Sorry, forgot to mention in the description: I'm not using kwin but i3, so the problem is not related to kwin either.
Comment 2 Konstantin Kharlamov 2024-03-28 10:29:54 UTC
(In reply to Konstantin Kharlamov from comment #1)
> Tried bisecting. Older commits are unbuildable, probably due to deps, but I
> found that the problem appeared before commit
> 
>     ee79807a GIT_SILENT: use QStringLiteral. Avoiding runtime conversions
> including memallocs
> 
> when exactly is unclear.

I'm willing to bisect further if you advice on how to overcome older dependencies problem. E.g. using some kind of container and a static build? Idk.
Comment 3 Konstantin Kharlamov 2024-04-02 05:55:30 UTC
I created a report on Picom as well¹, and with a hint from the amazing Picom maintainer I found out that the commit that introduced regression is:

    efc267076 "Only have minimum 50ms timer if using PlatformXcb"

It's an old commit, however due to Spectacle releases being tied to KDE commits from that timespan basically have never been tested by users (i.e. because it's a KDE6 commit whereas users couldn't use that version).

I'm writing a fix. I don't know yet how to handle it best; I looked through the surrounding code and I think best way would be to add a test for whether `kwin` is the compositor in use. However I haven't found so far any detection code around that, so maybe the solution will come down to just reverting the commit.

CC: Noah Davis, the commit author

1: https://github.com/yshui/picom/issues/1230
Comment 4 Bug Janitor Service 2024-04-02 07:41:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/342
Comment 5 Konstantin Kharlamov 2024-04-05 15:47:58 UTC
Git commit 73b88ab1eaee494c578ffe1fd2cafa8dd0d437a1 by Konstantin Kharlamov.
Committed on 05/04/2024 at 15:46.
Pushed by ndavis into branch 'master'.

SpectacleCore: make class inheritance check more robust

Commit

    f410b0814 "Rename Platform* to ImagePlatform*"

introduced a regression by making spectacle window visible at the
moment of making rectangular screenshot. That happened because the
check for inheritance was using a string instead of a dynamic/qobject
cast, so after the rename the fact the code broke went unnoticed.

Fix that by using qobject_cast() instead, so if rename ever happens
again the code would refuse to compile.

While at it, also add a point that the delay there isn't only because
of the crash but also because X11 compositors different from kwin may
require some time for effects to disappear before the shot can be
made.

M  +7    -4    src/SpectacleCore.cpp

https://invent.kde.org/graphics/spectacle/-/commit/73b88ab1eaee494c578ffe1fd2cafa8dd0d437a1
Comment 6 Noah Davis 2024-04-05 15:56:37 UTC
Git commit 5b8d6193561830036e7ad916ebbfd04a268af7ad by Noah Davis, on behalf of Konstantin Kharlamov.
Committed on 05/04/2024 at 15:56.
Pushed by ndavis into branch 'release/24.02'.

SpectacleCore: make class inheritance check more robust

Commit

    f410b0814 "Rename Platform* to ImagePlatform*"

introduced a regression by making spectacle window visible at the
moment of making rectangular screenshot. That happened because the
check for inheritance was using a string instead of a dynamic/qobject
cast, so after the rename the fact the code broke went unnoticed.

Fix that by using qobject_cast() instead, so if rename ever happens
again the code would refuse to compile.

While at it, also add a point that the delay there isn't only because
of the crash but also because X11 compositors different from kwin may
require some time for effects to disappear before the shot can be
made.


(cherry picked from commit 73b88ab1eaee494c578ffe1fd2cafa8dd0d437a1)

M  +7    -4    src/SpectacleCore.cpp

https://invent.kde.org/graphics/spectacle/-/commit/5b8d6193561830036e7ad916ebbfd04a268af7ad