Bug 468422 - Copied text from PDFs in Okular show up in clipboard but cannot be directly pasted after closing Okular
Summary: Copied text from PDFs in Okular show up in clipboard but cannot be directly p...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Clipboard (show other bugs)
Version: 5.27.4
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2023-04-12 14:46 UTC by postix
Modified: 2023-06-05 18:18 UTC (History)
4 users (show)

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


Attachments
Screen recording (442.20 KB, video/x-matroska)
2023-04-12 16:48 UTC, postix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2023-04-12 14:46:04 UTC
STEPS TO REPRODUCE
1. Download the following paper `https://core.ac.uk/download/pdf/18452666.pdf`
    It also works for other PDFs.
2. Open it in Okular
3. Select the title "Coherence effects in Mie scattering"
4. Press Ctrl+C to copy it to the clipboard
5. Close Okular
6. Try to paste the title somewhere with Ctrl+V, e.g. into Kate or try to rename the PDF by pasting the title in Dolphin

OBSERVED RESULT
Nothing is pasted! The copied text however appears in the clipboard applet.

If you however do not close Okular in step 5, pasting works. 
It also works if you copy it again by clicking on the copied content in the clipboard applet.

Interestingly, this bug appears only for some parts of the PDF, like the title or the first sentence of the first paragraph.
I could not reproduce it when I copied the authors name under the title.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20230411
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.8
Kernel Version: 6.2.9-1-default (64-bit)
Graphics Platform: Wayland
Okular 22.12.3
Kate 22.12.3
Dolphin 22.12.3
Comment 1 David Edmundson 2023-04-12 15:06:08 UTC
Can you confirm what the kwin debug console shows for the current clipboard during this
Comment 2 postix 2023-04-12 16:36:56 UTC
(In reply to David Edmundson from comment #1)
> Can you confirm what the kwin debug console shows for the current clipboard
> during this

kwin debug output shows the following. I could not find the keyword `clipboard` in log

```
18:33:57 dolphin[2965]: QString::arg: 2 argument(s) missing in org.kde.okular
18:33:57 systemd[1975]: Started Okular - Dokumentenbetrachter.
18:33:57 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN → DEBOUNCE_EVENT_RELEASE → DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS
18:33:57 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS → DEBOUNCE_EVENT_TIMEOUT_SHORT → DEBOUNCE_STATE_IS_UP_WAITING
18:33:57 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_UP
18:33:57 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 335489 (current: 335490)
18:33:57 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 335639 (current: 335640)
18:33:58 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - wheel state WHEEL_STATE_NONE → WHEEL_EVENT_SCROLL → WHEEL_STATE_ACCUMULATING_SCROLL
18:33:58 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - wheel state WHEEL_STATE_ACCUMULATING_SCROLL → WHEEL_EVENT_SCROLL_DIR_CHANGED → WHEEL_STATE_NONE
18:33:58 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - wheel state WHEEL_STATE_NONE → WHEEL_EVENT_SCROLL → WHEEL_STATE_ACCUMULATING_SCROLL
18:33:58 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - wheel state WHEEL_STATE_ACCUMULATING_SCROLL → WHEEL_EVENT_SCROLL_ACCUMULATED → WHEEL_STATE_SCROLLING
18:33:59 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - wheel state WHEEL_STATE_SCROLLING → WHEEL_EVENT_SCROLL_TIMEOUT → WHEEL_STATE_NONE
18:34:00 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_PRESS → DEBOUNCE_STATE_IS_DOWN_WAITING
18:34:00 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_DOWN
18:34:00 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN → DEBOUNCE_EVENT_RELEASE → DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS
18:34:00 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS → DEBOUNCE_EVENT_TIMEOUT_SHORT → DEBOUNCE_STATE_IS_UP_WAITING
18:34:00 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_UP
18:34:01 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 339906 (current: 339907)
18:34:02 systemd[1975]: app-org.kde.okular-4d4969472ff24f1b926beee0ba401dc1.scope: Consumed 1.681s CPU time.
18:34:02 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 340406 (current: 340407)
18:34:02 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_PRESS → DEBOUNCE_STATE_IS_DOWN_WAITING
18:34:02 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_DOWN
18:34:03 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN → DEBOUNCE_EVENT_RELEASE → DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS
18:34:03 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS → DEBOUNCE_EVENT_TIMEOUT_SHORT → DEBOUNCE_STATE_IS_UP_WAITING
18:34:03 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_UP
18:34:03 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 341122 (current: 341123)
18:34:03 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 341139 (current: 341140)
18:34:04 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 342639 (current: 342640)
18:34:05 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP → DEBOUNCE_EVENT_PRESS → DEBOUNCE_STATE_IS_DOWN_WAITING
18:34:05 kwin_wayland[2056]: kwin_core: Provided presentation timestamp is invalid: 343256 (current: 343257)
18:34:05 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_DOWN
18:34:05 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_DOWN → DEBOUNCE_EVENT_RELEASE → DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS
18:34:05 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_DETECTING_SPURIOUS → DEBOUNCE_EVENT_TIMEOUT_SHORT → DEBOUNCE_STATE_IS_UP_WAITING
18:34:05 kwin_wayland[2056]: kwin_libinput: Libinput: event0  - debounce state: DEBOUNCE_STATE_IS_UP_WAITING → DEBOUNCE_EVENT_TIMEOUT → DEBOUNCE_STATE_IS_UP
````
Comment 3 postix 2023-04-12 16:41:19 UTC
(In reply to David Edmundson from comment #1)
> Can you confirm what the kwin debug console shows for the current clipboard
> during this

Never mind the last comment, I got you wrong; will check
> qdbus org.kde.KWin /KWin org.kde.KWin.showDebugConsole
now.
Comment 4 postix 2023-04-12 16:48:54 UTC
Created attachment 158041 [details]
Screen recording

1) After copying _and_ Okular is still running, it shows 

```
Mime/type
text/plain   $copiedtext
text/...         $copiedtext
```

2) After then exiting Okular, the clipboard content in the kwin debug console vanishes _often / randomly_. Please see the screen recording.
Comment 5 Nate Graham 2023-04-13 18:57:38 UTC
On Fedora 37 with Plasma 5.27.4 on Wayland, I can reproduce with those steps and that file. In fact I can reproduce it with text in any PDF I open in Okular.

When this happens, if I click on the history item in the Clipboard popup for the text, I can then paste it. But until I do that, I cannot paste it, despite it appearing as the first entry in the Clipboard popup.
Comment 6 Bug Janitor Service 2023-05-08 07:42:04 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2908
Comment 7 Tobias Fella 2023-05-08 15:06:46 UTC
Git commit c6d52910ebc1fb1abd89d286aec9c24ca102db77 by Tobias Fella.
Committed on 08/05/2023 at 14:48.
Pushed by tfella into branch 'master'.

Fix Klipper empty prevention on wayland

When an application terminates, we receive a signal for the Selection and restore it. While restoring it,
we also receive a signal for the Clipboard, but don't handle it since we're currently locked due to the Selection.

This patch fixes that by creating separate locks for Selection and Clipboard.

M  +13   -10   klipper/klipper.cpp
M  +3    -2    klipper/klipper.h

https://invent.kde.org/plasma/plasma-workspace/commit/c6d52910ebc1fb1abd89d286aec9c24ca102db77
Comment 8 postix 2023-05-08 16:02:29 UTC
@Nate, in the MR it says Milestone 5.27, not 6 :)
Comment 9 postix 2023-05-08 16:04:57 UTC
... and thanks Tobias!
Comment 10 Nate Graham 2023-05-08 16:05:19 UTC
Yes, I'm doing the cherry-pick right now.
Comment 11 Nate Graham 2023-05-08 16:26:43 UTC
Git commit 16d7f44deac7621318be63438d0f8b8923d165df by Nate Graham, on behalf of Tobias Fella.
Committed on 08/05/2023 at 16:00.
Pushed by ngraham into branch 'Plasma/5.27'.

Fix Klipper empty prevention on wayland

When an application terminates, we receive a signal for the Selection and restore it. While restoring it,
we also receive a signal for the Clipboard, but don't handle it since we're currently locked due to the Selection.

This patch fixes that by creating separate locks for Selection and Clipboard.
(cherry picked from commit c6d52910ebc1fb1abd89d286aec9c24ca102db77)

M  +13   -10   klipper/klipper.cpp
M  +3    -2    klipper/klipper.h

https://invent.kde.org/plasma/plasma-workspace/commit/16d7f44deac7621318be63438d0f8b8923d165df
Comment 12 Lyubomir 2023-05-26 10:15:39 UTC
@Nate is this supposed to be fixed in 5.27.5? I have the same issue but with Authy on a newly installed OpenSUSE Tumbleweed..
Comment 13 Nate Graham 2023-05-28 04:11:12 UTC
If you're experiencing the same issue in another app, it could very well be an issue in that app. Every clipboard-based issue needs to be separately investigated, since it could be an issue in the source app, the target app, the Plasma clipboard, KWin (on Wayland) or the X server (on X11). Please submit a new bug report for it. Thanks!