CrossCopy / tauri-plugin-clipboard

A Tauri clipboard plugin with text, files, html, RTF, and image support. Clipboard content update monitoring is also supported.
https://crosscopy.github.io/tauri-plugin-clipboard/
MIT License
145 stars 10 forks source link

Re-use arboard clipboard instance (relevant for X11 and Wayland) #12

Closed ktlwap closed 10 months ago

ktlwap commented 11 months ago

Releasing the arboard instance will cause an instant crash on X11 and Wayland because it's also releasing internal ressources on display server / compositor. Keeping exactly one instance seems to fix that issue. (tested both X11 and Wayland on Gnome)

https://docs.rs/arboard/latest/arboard/struct.Clipboard.html#linux

ktlwap commented 11 months ago

@HuakunShen may I ask you to have a look into this PR?

HuakunShen commented 11 months ago

@ktlwap How can I reproduce this problem?

ktlwap commented 11 months ago

I was able to reproduce it with GNOME (Ubuntu) inside a Virtual Machine. In order to be able to reproduce you do need rust, node and npm installed.

Then just clone https://github.com/nero-tools/clipboard-manager. Switch the used plugin version back to 0.3.1 in Cargo.toml

Once you've done the prior steps you could launch the application. With 0.3.1 it'll crash as soon you did the first image copy / read operation. (sometimes also reproducible while switching between virtual desktops)

(Not needed for wayland but I'd suppose that you do need that export for X11: export WEBKIT_DISABLE_COMPOSITING_MODE=1)

In this GIF you'll see that the application crashes as soon as I take the first screenshot: 1

The application logic will periodically check on the content inside your clipboard and once new content is available it will crash.

For reference a build with my fixes: 2

As you can see, it's not crashing at all. Make sure that you delete all the compiler output before starting a new build once you switched the version.

This issue is on Windows not reproducible at all.

HuakunShen commented 10 months ago

@ktlwap Thank you for the feedback. I tried to run your code and the original example, but failed for some reason. Probably because I had a new environment and the code was out dated.

I ended up upgrading all dependency versions, and the example app had no problem to run on ubuntu 22.04 (wayland).

I tried your repo with v0.3.2 but no window shows up.

Can you try again with the new v0.3.2?

I will merge the new version with your PR after testing. Thanks.

HuakunShen commented 10 months ago

Merged version available at v0.4.0