xarantolus / mysti

Self-hosted clipboard sync and remote command runner for Linux and Windows
MIT License
2 stars 0 forks source link

Feedback Loop #5

Open michalsteyn opened 2 months ago

michalsteyn commented 2 months ago

It seems that copy and paste between two machines often times result in a feedback loop. So the process seems to be:

Machine A copies data to System Clipboard. This is then synced to Machine B's clipboard. Machine B's clipboard change is detected by Mysti, which re-sends the data to Machine A. Machine A then detects a clipboard change and sends it back to Machine B.

The cycle continues forever.

This seems to happen always when copying images. Sometime for text.

xarantolus commented 2 months ago

Hmm, you are right. I remember testing it with BMP images, and that worked because it could recognize that the image in the clipboard has already been set. However, I seem to have changed the format to jpeg at some point, and that essentially loops between the two machines until the compression reaches its worst point (because the image gets reencoded from the clipboard format to the transmission format every time, which for jpeg often changes the bytes due to its lossy nature):

Received action message: Clipboard(Image(len=40004))
Clipboard content changed
Received action message: Clipboard(Image(len=40004))
Clipboard content changed
Received action message: Clipboard(Image(len=40004))
Clipboard content changed
Received action message: Clipboard(Image(len=39967))
Clipboard content changed
Received action message: Clipboard(Image(len=39975))
...
Received action message: Clipboard(Image(len=39968))
Clipboard content changed

In general the problem is that we can't (I think) "tag" certain clipboard content with an ID we can recognize, so the detection if something has already been set is a bit weird. For text, I'm not quite sure why it would loop between machines forever (however, I only really have two devices I use mysti with, maybe there are problems with more).

xarantolus commented 2 months ago

Using BMP it seems to be better, but the general problem with many messages being exchanged (most of them essentially unnecessarily) remains.