tauri-apps / tauri-apps/plugins-workspace
[bug][v2][clipboard-manager] Clipboard sometimes left empty after closing the Tauri app
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
Hi, I am using tauri v2 for a basic emoji popup desktop app: when the user click an emoji we add it to the clipboard, and we close the app (we don't want it to be running in the background)
But if I try to close the app after copying to the clipboard, the clipboard is left empty about 30 to 40% of the time (sometimes it works, sometimes no, without really a pattern, it seems to be random)
I tried many different approaches to paste the emoji to the clipboard and close the app:
* Adding to clipboard and closing app window both using the JS API: clipboard empty 40% of the time
* Adding to clipboard, and closing app both using the rust API: clipboard always empty
* Adding to clipboard using the JS API, and closing the app in a separate thread using the rust API: seems to be the most reliable, but still fails too much, probably 30% of the time
Copying the emoji in the clipboard works 100% of the time if I just hide the window (no closing the app). So the issue seems to come from closing the app.
Here is the relevant code:
* write emoji to clipboard: https://github.com/vemonet/EmojiMart/blob/main/src/routes/%2Bpage.svelte#L29
* exit the app: https://github.com/vemonet/EmojiMart/blob/main/src-tauri/src/main.rs#L96
Do you have any idea why the clipboard is sometimes lost when closing the app or window? And how it could be fixed?
Thanks a lot!
Contributor guide
Assessment
This issue has not been assessed yet.