VM→host clipboard silently drops the 2nd VM when running multiple VMs simultaneously (shared dedup in singleton WHSharedClipboardService) #695
marcel-veselka
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
When two macOS VMs run at the same time (both with VirtualBuddyGuest installed), VM→host clipboard works for only one of them.
host→VMworks for both. The VM started first keeps working; the second VM's clipboard is silently dropped — the guest reads/exports it fine, but the host never applies it toNSPasteboard.general.Environment
Repro
host→VMworks for both. Frontmost/focused VM makes no difference; restarting the guest doesn't help.Root cause (from source, current HEAD)
The host clipboard receiver is a process-wide singleton with a single shared dedup field, fed by all VMs at once:
WormholeManager.sharedHostis a singleton; its services are built once on firstactivate()(WormholeManager.swift:36-37, 77-93), so there is exactly oneWHSharedClipboardServicefor every VM.handle()dedups against a single sharedpreviousMessage:That same
previousMessageis also written by thehost→VMpoll (updateIfNeeded, :73-89) and by guest↔guest propagation (propagateBetweenGuests = true). With two VMs, whichever VM owns the shared baseline (the first-started one in steady state) keeps working; the other VM's distinct copies are classified as duplicates at:52and dropped — "guest exports fine, host never applies it."Transport is not the problem: each VM gets its own serial pipe pair and a distinct peer ID (
VMInstance.swift:167-191), so there's no port/service-name collision. The issue is the sharedpreviousMessage+ singleNSPasteboardin the singleton service.Suggested fix
Make the dedup per-peer and stop dropping the second VM:
message.senderID(already available at:42) and pass it intohandle().previousMessagewith a[WHPeerID: ClipboardMessage]keyed by sender, and track the host's last-applied content separately so an inbound copy that merely equals what the host just broadcast to that peer isn't mistaken for a duplicate from another peer.NSPasteboard.general.changeCountfor host-side change detection instead of value-comparing on a 0.5s timer.Happy to test a patch. Thanks for VirtualBuddy — it's excellent.
Beta Was this translation helpful? Give feedback.
All reactions