Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.93k stars 165 forks source link

Connection lost seamless mode by using LibreOffice #3619

Closed louis-mulder closed 2 years ago

louis-mulder commented 2 years ago

Describe the bug Activating LibreOffice with for example soffice --calc crashes the connection. /run/xpra/0/server.log shows some Python errors. When running in a full desktop (XFCE4) LibreOffice works as expected.

To Reproduce Steps to reproduce the behavior:

  1. Run a seamless session
  2. In a terminal window soffice --calc
  3. When connection lost the following appears in server.log
2022-09-14 16:36:35,986 Error: error in network packet reading/parsing
2022-09-14 16:36:35,986  a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/net/protocol.py", line 825, in _read_parse_thread_loop
    self.do_read_parse_thread_loop()
  File "/usr/lib/python3/dist-packages/xpra/net/protocol.py", line 1059, in do_read_parse_thread_loop
    self._process_packet_cb(self, packet)
  File "/usr/lib/python3/dist-packages/xpra/server/proxy/proxy_instance.py", line 505, in process_server_packet
    self._packet_recompress(packet, 5, "icon")
  File "/usr/lib/python3/dist-packages/xpra/server/proxy/proxy_instance.py", line 375, in _packet_recompress
    packet[index] = compressed_wrapper(name, data, can_inline=False, **kw)
  File "/usr/lib/python3/dist-packages/xpra/net/compression.py", line 205, in compressed_wrapper
    cl, cdata = c.compress(data, level)
  File "/usr/lib/python3/dist-packages/xpra/net/compression.py", line 47, in lz4_compress
    return flag, block_compress(packet)
TypeError: a bytes-like object is required, not 'str'
2022-09-14 16:36:35,991 stopping threaded proxy instance
2022-09-14 16:36:35,991  server connection lost

System Information (please complete the following information):

totaam commented 2 years ago

The tiny commit above should fix this problem.

Note: this only occurs because your sessions are going through the proxy.

louis-mulder commented 2 years ago

Antoine, A return of flag and packet was not working in compress.py on line 47. I changed it in: return flag, block_compress(bytearray( map(ord, str(packet) )))

And in protocol.py becouse of assert complaining on the client site.

assert payload_size>0, "invalid payload size: %i" % payload_size in assert payload_size>-1, "invalid payload size: %i" % payload_size

Now it looks working as expected. Regards Louis

totaam commented 2 years ago

@louis-mulder Changing compress.py or protocol.py is not an option here, the fix belongs elsewhere and the commit above should be the correct fix. If it is not, please clarify the new problem you are seeing.

louis-mulder commented 2 years ago

Antoine, On the client side I see a message:

2022-09-15 13:35:39,864 running, 1 window
2022-09-15 13:35:45,188 Error: error in network packet reading/parsing
2022-09-15 13:35:45,197  invalid payload size: 0
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/net/protocol.py", line 825, in _read_parse_thread_loop
    self.do_read_parse_thread_loop()
  File "/usr/lib/python3/dist-packages/xpra/net/protocol.py", line 906, in do_read_parse_thread_loop
    assert payload_size>0, "invalid payload size: %i" % payload_size
AssertionError: invalid payload size: 0
2022-09-15 13:35:45,229 Connection lost

BTW. I am using the proxy-server as an ingress controller on Kubernetes with a modification in proxy_server.py to create or find a user-session. But it's a pity mdns is not working accross subnets. So it will not show all the sessions with for example xpra list-mdns. Any ideas ?

Regards Louis

louis-mulder commented 2 years ago

Antoine, This is weird. Running a seamless session and starting up soffice --calc for example the client crashes as earlier commented. When I do a reconnect to the session with running Libre-Office it works. However after shutting down Libre-Office and started again the client crashes. But when start soffice without arguments you get a menu with the applications (after a reconnect). If activate an application for example draw the client crashes.

I put a print statement above the assert on line 825: print( "payload_size-",payload_size,"--buffer-",read_buffers,"-") Output in the terminal:

payload_size- 16 --buffer- [b'\xc3\x10@\x00\xf4]\x1bA\x00\x00\x01\x83A\x0fG`'] -
payload_size- 338 --buffer- [b'\xc8\x1b+?\x02u?\x01\xb3?\x02\x95?\x00\xa9s\x83xid\x880xa00003\x8eclient-machine\x92testuser3-seamless\x83pid?\x08\xbc\x85title\x8fLibreOffice 6.4\x84role\x8csplashscreen\x8eclass-instance\xc2\x87soffice\x87Soffice\x8dopaque-region\xc1\xc4\x00\x00\x01\x01\x90group-leader-xid@\x00\xa0\x00\x01\x8bwindow-type\xc1\x86SPLASH\x8ccontent-type\x80\x90size-constraintsj\x89base-size\xc2?\x02\x95?\x00\xa9\x87gravity\n\x8cminimum-size\xc2?\x02\x95?\x00\xa9\x8cmaximum-size\xc2?\x02\x95?\x00\xa9\x8aicon-title\x8fLibreOffice 6.4\x86iconicDf'] -
payload_size- 0 --buffer- [b'P\x18\x00\x00\x00\x00\x00\x0f\xc6%+\x00\x00\x87default0/'] -
2022-09-15 14:11:04,418 Error: error in network packet reading/parsing
2022-09-15 14:11:04,425  invalid payload size: 0
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/net/protocol.py", line 825, in _read_parse_thread_loop
    self.do_read_parse_thread_loop()
  File "/usr/lib/python3/dist-packages/xpra/net/protocol.py", line 908, in do_read_parse_thread_loop
    assert payload_size>0, "invalid payload size: %i" % payload_size
AssertionError: invalid payload size: 0
2022-09-15 14:11:04,450 Connection lost
2022-09-15 14:11:04,455 removing unix domain socket '/run/user/1000/xpra/clients/lmulder-IdeaPad-3-15ALC6-22575'
CONNECTION_LOST, reconnecting
2022-09-15 14:11:05,183 Xpra GTK3 X11 client version 4.3.4-r0 64-bit

Regards Louis

totaam commented 2 years ago

But it's a pity mdns is not working across subnets. So it will not show all the sessions with for example xpra list-mdns. Any ideas ?

We need the server registration feature, but I really don't have time for it.

I put a print statement above the assert on line 825:

825!? Please use github links, like this one: https://github.com/Xpra-org/xpra/blob/2e2440b4ef1716df8e1b7332a21018eba6e9c421/xpra/net/protocol.py#L906 This is a more likely location too. 8a87275ea80d00b67e21dbe3bf187aa7fde3989a will give a more helpful exception message rather than relying on print statements and piecing it back together.

So the original bug has been fixed by commit b918ab1bcf73ad6170d5a49a76626fc2391d15e5, right? The TypeError: a bytes-like object is required, not 'str'.

The last payload printed is valid and contains 15 bytes of data:

$ python3 -c "payload = b'P\x18\x00\x00\x00\x00\x00\x0f\xc6%+\x00\x00\x87default0/';from xpra.net.header import unpack_header;print(unpack_header(payload[:8]))"
(b'P', 24, 0, 0, 15)

Perhaps it isn't this one then.

totaam commented 2 years ago

Not heard back, I assume that the original issue is fixed.