plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

[bug][v2][clipboard-manager] Clipboard sometimes left empty after closing the Tauri app

Open vemonet opened this issue 1 year ago • 1 comments

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!

vemonet avatar Mar 24 '24 10:03 vemonet

Sorry for the long silence, which platforms did you test this on?

FabianLars avatar Aug 07 '24 13:08 FabianLars