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

I found a possible performance problem🤔. #25

Closed ChurchTao closed 5 months ago

ChurchTao commented 5 months ago
          @HuakunShen During use, I found a possible performance problem🤔. When using the API to read the Image or using the listener, I found that when the image is large, the main process will be blocked. This is the blocking time-consuming situation I debugged. It can happen in rust layer.I tried to copy a 4k picture, but the interface was blocked for about 7 seconds and became inoperable.

image

Originally posted by @Tester-957 in https://github.com/CrossCopy/tauri-plugin-clipboard/issues/21#issuecomment-2053622906

ChurchTao commented 5 months ago

I perform performance testing on clipboard-rs

HuakunShen commented 5 months ago

@ChurchTao How is the performance on clipboard-rs without Tauri?

HuakunShen commented 5 months ago

My performance results on a 5MB screenshot (2560x2880)

clipboard-rs

Debug Mode

Release Mode

tauri-plugin-clipboard demo

Debug Mode

Release Mode

Looks like getting the image is fast (indifferent between debug and release mode). Converting bytes / saving takes a lot more time in debug mode. I believe it's fine. In release mode it's really fast.

The blocking problem can be fixed by making the read_image() tauri commands async. I will fix it.