Xpra: Ticket #2019: macos client, server-to-client clipboard no longer works

Connecting to xfce4 desktop on centos-6.6, xpra v1.0.12-r19800, from macos 10.13.6.

When I upgraded macos cilent to 2.4 from 2.2.4, clipboard server-to-client no longer worked. Then I went backwards to find latest release where it does work. Observations:

client versions (all non-python3, all installed from .pkg) vs clipboard:

works: xpra v2.2.6-r18959   both dirs work
FAILS: xpra v2.3.1-r19532   both dirs FAIL
FAILS: xpra v2.3.2-r19729   both dirs FAIL
(ssh connect FAIL: xpra v2.3.3-r20112)
FAILS: xpra v2.3.4-r20510   server to client FAIL
FAILS: xpra v2.4-r20679     server to client FAIL

Test sequence for server-to-client:

I start the macos client like this (usually use the launcher form, taking these options from a file):

xpra attach ssh/me@joe.example.com/3 --desktop-fullscreen=yes --desktop-scaling=no --speed=100 --quality=100 --dpi=96 --swap-keys=no  --opengl=yes

In remote desktop I start Terminal from this centos package:

Terminal-0.4.7-2.el6.x86_64 : X Terminal Emulator for the Xfce Desktop environment

In remote desktop Terminal, type text "xyz123", select it with mouse, and use Terminal's menu item: Edit/Copy?. I hide the xpra-client (cmd-H). I try to paste (cmd-V) in a macos terminal. When it fails, the macos terminal's Edit/Paste? is also greyed-out (not clickable) indicating nothing to paste.

When I run client with "--debug clipboard" I do see the selected text "xyz123" referenced in the logs. But from what I can tell, neither 2.2.6 nor 2.4 logs anything regarding the clipboard or that text at the moment of macos cmd-V to paste in macos.

I haven't used 2.4 enough yet, but it seems a bit worse on macos than 2.3.4 (features and possibly non-opengl performance). And 2.3.4 at least works half-way; so I'd be interested in a way to get 2.3.4 working. Otherwise 2.2.6 is acceptable for me.

I read the wiki on clipboard, nothing jumps out at me. Don't think I have another clipboard manager. And I'm always testing using the CLIPBOARD clipboard (not the primary). In 2.3.4 where the client-menu works for me, I tried changing clipboard-menu to disabled and back to clipboard, but was no help.

Tue, 30 Oct 2018 08:40:57 GMT - Antoine Martin: status changed; resolution set

The clipboard issue is a duplicate of #2009 (already fixed)

but it seems a bit worse on macos than 2.3.4 (features and possibly non-opengl performance)

What "features"? Non-opengl performance is unchanged. Please file a separate ticket for those, if any.

Tue, 30 Oct 2018 09:22:48 GMT - sto6:

Found a traceback in only the v2.4-r20679 client log, perhaps not relevant? Here it is with some context:

2018-10-29 23:14:48,452 DISCARD_TARGETS=^SAVE_TARGETS$, ^COMPOUND_TEXT, ^NeXT, ^com\.apple\., ^CorePasteboardFlavorType, ^dyn\.
2018-10-29 23:14:48,454 server clipboard: supported=True, direction=both, supports enable selection=True
2018-10-29 23:14:48,454 client clipboard: supported=True, direction=both
2018-10-29 23:14:48,454 parse_clipboard_caps() clipboard enabled=True
2018-10-29 23:14:48,455 enabled remote logging
2018-10-29 23:14:48,455 Xpra X11 desktop server version 1.0.12-r19800 64-bit
2018-10-29 23:14:48,456  running on Linux CentOS 6.6 Final
2018-10-29 23:14:48,458 process_ui_capabilities() clipboard_enabled=True
2018-10-29 23:14:48,458 get_clipboard_helper_classes() unfiltered list=['xpra.platform.darwin.osx_clipboard.OSXClipboardProtocolHelper', 'xpra.clipboard.gdk_clipboard.GDKClipboardProtocolHelper', 'xpra.clipboard.clipboard_base.DefaultClipboardProtocolHelper', 'xpra.clipboard.translated_clipboard.TranslatedClipboardProtocolHelper']
2018-10-29 23:14:48,460 get_clipboard_helper_classes() options=['xpra.platform.darwin.osx_clipboard.OSXClipboardProtocolHelper', 'xpra.clipboard.gdk_clipboard.GDKClipboardProtocolHelper', 'xpra.clipboard.clipboard_base.DefaultClipboardProtocolHelper', 'xpra.clipboard.translated_clipboard.TranslatedClipboardProtocolHelper']
2018-10-29 23:14:48,490 get_clipboard_helper_classes()=[<class 'xpra.platform.darwin.osx_clipboard.OSXClipboardProtocolHelper'>, <class 'xpra.clipboard.gdk_clipboard.GDKClipboardProtocolHelper'>, <class 'xpra.clipboard.clipboard_base.DefaultClipboardProtocolHelper'>, <class 'xpra.clipboard.translated_clipboard.TranslatedClipboardProtocolHelper'>]
2018-10-29 23:14:48,491 make_clipboard_helper() options=[<class 'xpra.platform.darwin.osx_clipboard.OSXClipboardProtocolHelper'>, <class 'xpra.clipboard.gdk_clipboard.GDKClipboardProtocolHelper'>, <class 'xpra.clipboard.clipboard_base.DefaultClipboardProtocolHelper'>, <class 'xpra.clipboard.translated_clipboard.TranslatedClipboardProtocolHelper'>]
2018-10-29 23:14:48,491 setup_clipboard_helper(<class 'xpra.platform.darwin.osx_clipboard.OSXClipboardProtocolHelper'>)
2018-10-29 23:14:48,491 setup_clipboard_helper() kwargs={'clipboard.remote': 'CLIPBOARD', 'can-send': True, 'clipboard.local': 'CLIPBOARD', 'clipboards.remote': ['CLIPBOARD', 'PRIMARY', 'SECONDARY'], 'remote-loop-uuids': {}, 'clipboards.local': ['CLIPBOARD'], 'can-receive': True}
2018-10-29 23:14:48,518 NSPasteboard.changeCount() access success, current value=282, setting up timer to watch for changes
2018-10-29 23:14:48,520 UI watcher=<xpra.platform.ui_thread_watcher.UI_thread_watcher object at 0x10f0214d0>
2018-10-29 23:14:48,520 TranslatedClipboardProtocolHelper local=CLIPBOARD, remote=CLIPBOARD
2018-10-29 23:14:48,529 OSXClipboardProtocolHelper.init_proxies : {'CLIPBOARD': ClipboardProxy(CLIPBOARD)}
2018-10-29 23:14:48,530 verify_remote_loop_uuids({})
2018-10-29 23:14:48,530 clipboard helper=OSXClipboardProtocolHelper
2018-10-29 23:14:48,530 send_clipboard_selections(['CLIPBOARD']) server_clipboard_enable_selections=True
2018-10-29 23:14:48,531 send clipboard token: CLIPBOARD
2018-10-29 23:14:48,531 local_to_remote(CLIPBOARD) local_clipboard=CLIPBOARD, remote_clipboard=CLIPBOARD
Traceback (most recent call last):
  File "/Applications/Xpra.app/Contents/Resources/lib/python/xpra/client/gtk_base/gtk_client_base.py", line 864, in process_ui_capabilities
  File "/Applications/Xpra.app/Contents/Resources/lib/python/xpra/client/ui_client_base.py", line 409, in process_ui_capabilities
  File "/Applications/Xpra.app/Contents/Resources/lib/python/xpra/client/keyboard_helper.py", line 46, in set_modifier_mappings
  File "/Applications/Xpra.app/Contents/Resources/lib/python/xpra/platform/darwin/keyboard.py", line 141, in set_modifier_mappings
    KeyboardBase.set_modifier_mappings(self, mappings)
  File "/Applications/Xpra.app/Contents/Resources/lib/python/xpra/platform/keyboard_base.py", line 45, in set_modifier_mappings
    self.modifier_keys[bytestostr(keyname)] = bytestostr(modifier)
UnboundLocalError: local variable 'keyname' referenced before assignment
2018-10-29 23:14:48,536 timer_clipboard_check() was 0, now 282
2018-10-29 23:14:48,536 local_clipboard_changed()
2018-10-29 23:14:48,536 clipboard: CLIPBOARD owner_changed, enabled=True, can-send=True, can-receive=True, have_token=False, greedy_client=False, block_owner_change=False
2018-10-29 23:14:49,037 timer_clipboard_check() was 282, now 282
2018-10-29 23:14:49,297 process_clipboard_packet: clipboard-pending-requests, helper=OSXClipboardProtocolHelper
2018-10-29 23:14:49,297 process clipboard handler(clipboard-pending-requests)=<bound method OSXClipboardProtocolHelper._process_clipboard_pending_requests of OSXClipboardProtocolHelper>
2018-10-29 23:14:49,297 clipboard_progress(None, 1)
2018-10-29 23:14:49,297 clipboard_notify(1)
2018-10-29 23:14:49,298 process_clipboard_packet: clipboard-request, helper=OSXClipboardProtocolHelper
2018-10-29 23:14:49,298 process clipboard handler(clipboard-request)=<bound method OSXClipboardProtocolHelper._process_clipboard_request of OSXClipboardProtocolHelper>
2018-10-29 23:14:49,298 remote_to_local(CLIPBOARD) local_clipboard=CLIPBOARD, remote_clipboard=CLIPBOARD
2018-10-29 23:14:49,298 process clipboard request, request_id=0, selection=CLIPBOARD, local name=CLIPBOARD, target=TARGETS
2018-10-29 23:14:49,298 get_contents(TARGETS, <function got_contents at 0x11f0f3cf8>) selection=CLIPBOARD, enabled=True, can-send=True
2018-10-29 23:14:49,369 got_targets(<gtk.Clipboard object at 0x10d50b230 (GtkClipboard at 0x7fd5621390b0)>, ('UTF8_STRING', 'public.utf8-plain-text'), (None,))
2018-10-29 23:14:49,369 got_contents(ATOM, 32, <type 'tuple'>:2) data=0x2827555446385f535452494e47272c20277075626c69632e757466382d706c61696e2d746578742729..
2018-10-29 23:14:49,370 _munge_raw_selection_to_wire('TARGETS', 'ATOM', 32, ('UTF8_STRING', 'public.utf8-plain-text'))
2018-10-29 23:14:49,371 _filter_targets(('UTF8_STRING', 'public.utf8-plain-text'))=['UTF8_STRING', 'public.utf8-plain-text']
2018-10-29 23:14:49,371 clipboard raw -> wire: ('ATOM', 32, ('UTF8_STRING', 'public.utf8-plain-text')) -> ('atoms', ['UTF8_STRING', 'public.utf8-plain-text'])
2018-10-29 23:14:49,426 process_clipboard_packet: clipboard-pending-requests, helper=OSXClipboardProtocolHelper
2018-10-29 23:14:49,426 process clipboard handler(clipboard-pending-requests)=<bound method OSXClipboardProtocolHelper._process_clipboard_pending_requests of OSXClipboardProtocolHelper>
2018-10-29 23:14:49,426 clipboard_progress(None, 0)
2018-10-29 23:14:49,427 clipboard_notify(0)
2018-10-29 23:14:49,539 timer_clipboard_check() was 282, now 282
2018-10-29 23:14:50,044 timer_clipboard_check() was 282, now 282
2018-10-29 23:15:10,140 timer_clipboard_check() was 282, now 282
2018-10-29 23:15:10,239 process_clipboard_packet: clipboard-token, helper=OSXClipboardProtocolHelper
2018-10-29 23:15:10,239 process clipboard handler(clipboard-token)=<bound method OSXClipboardProtocolHelper._process_clipboard_token of OSXClipboardProtocolHelper>
2018-10-29 23:15:10,239 remote_to_local(CLIPBOARD) local_clipboard=CLIPBOARD, remote_clipboard=CLIPBOARD
2018-10-29 23:15:10,240 process clipboard token selection=CLIPBOARD, local clipboard name=CLIPBOARD, proxy=ClipboardProxy(CLIPBOARD)
2018-10-29 23:15:10,240 wire selection to raw, encoding=bytes, type=UTF8_STRING, format=8, len(data)=6
2018-10-29 23:15:10,241 got token, selection=CLIPBOARD, targets=('TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS', 'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING', 'text/plain;charset=utf-8', 'text/plain;charset=ANSI_X3.4-1968', 'text/plain'), target data={'UTF8_STRING': 'xyz123'}, claim=True, can-receive=True
2018-10-29 23:15:10,261 clipboard CLIPBOARD set to ''xyz123''
2018-10-29 23:15:10,262 claim() selection=CLIPBOARD, enabled=True
2018-10-29 23:15:10,262 change count now at 283
2018-10-29 23:15:10,263 remove_block: CLIPBOARD
2018-10-29 23:15:10,642 timer_clipboard_check() was 283, now 283

Tue, 30 Oct 2018 09:39:28 GMT - Antoine Martin:

Found a traceback ... UnboundLocalError: local variable 'keyname' referenced before assignment

This keyboard mapping error only affected newer clients with older servers (ie: 1.x) and is already fixed in r20817.

Thu, 01 Nov 2018 21:07:43 GMT - sto6:

Tried macos client version: Xpra-x86_64-2.4.1-r20898.pkg, still server-to-client clipboard failed for me.

#2009 was about reverse direction: client -> server. In my case, I couldn't find a similar message as: Warning: sanitizing invalid gtk selection.

Fri, 02 Nov 2018 00:59:43 GMT - Antoine Martin:

Tried macos client version: Xpra-x86_64-2.4.1-r20898.pkg, still server-to-client clipboard failed for me.

What is your server version?

Fri, 02 Nov 2018 01:36:53 GMT - sto6:

Server: centos-6.6, xpra v1.0.12-r19800

# yum list installed | g xpra
ffmpeg-xpra.x86_64                      4.0.2-1.el6_6            @winswitch
libvpx-xpra.x86_64                      1.7.0-1.el6_6            @winswitch
python-pyopengl.x86_64                  3.1.1a1-4.1xpra3.el6_6   @winswitch
x264-xpra.x86_64                        20170301-1.el6_6         @winswitch
xpra.x86_64                             1.0.12-2.r19800.el6_6    @winswitch
xpra-common.noarch                      1.0.12-2.r19800.el6_6    @winswitch

Fri, 02 Nov 2018 01:38:49 GMT - Antoine Martin: status changed; resolution deleted

Wed, 28 Nov 2018 12:10:17 GMT - Antoine Martin: priority changed

I can reproduce. Odd this one. As per the log, we do set the clipboard:

clipboard CLIPBOARD set to ''xyz123''

But somehow the value doesn't stick. Maybe we overwrite it when we claim() the clipboard, or maybe a GTK update changed the clipboard behaviour.

Wed, 28 Nov 2018 15:38:25 GMT - Antoine Martin: status changed; resolution set

This was caused by r18248 (GTK3 compatibility code) and only affects GTK2 on macos where it seems that the clipboard.set_with_data function doesn't do anything. Fix is in r21135. (tiny backport in r21136)

There are beta 2.5 and 2.4.2+ packages with these fixes here: https://xpra.org/beta/osx/

Sat, 23 Jan 2021 05:39:58 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2019