Xpra: Ticket #2049: vi in gnome-terminal suffers unnecessary whole-window redraw

Vi has a "ruler" at the bottom of the window. This ruler shows, among other things, the relative position of the cursor.

When running vi in xterm in XPRA, the server send updates for individual characters in both the ruler and in cursor position for a log that looks like: (very fast!)

2018-11-19 15:31:13,039 compress:   0.1ms for   10x20   pixels at  187,2    for wid=18    using     rgb24 with ratio  20.4%  (    0KB to     0KB), sequence    88, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:13,933 compress:   0.1ms for   10x20   pixels at  187,2    for wid=18    using     rgb24 with ratio   9.9%  (    0KB to     0KB), sequence    89, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:14,020 compress:   0.1ms for   10x20   pixels at  187,2    for wid=18    using     rgb24 with ratio  20.4%  (    0KB to     0KB), sequence    90, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:16,882 compress:   0.1ms for   10x20   pixels at  197,2    for wid=18    using     rgb24 with ratio  12.2%  (    0KB to     0KB), sequence    91, client_options={'flush': 2, 'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:16,883 compress:   0.1ms for   10x20   pixels at 1177,722  for wid=18    using     rgb24 with ratio  16.8%  (    0KB to     0KB), sequence    92, client_options={'flush': 1, 'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:16,884 compress:   0.1ms for   10x20   pixels at  187,2    for wid=18    using     rgb24 with ratio   9.9%  (    0KB to     0KB), sequence    93, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:17,639 compress:   0.1ms for   10x20   pixels at  207,2    for wid=18    using     rgb24 with ratio  11.8%  (    0KB to     0KB), sequence    94, client_options={'flush': 2, 'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:17,641 compress:   0.1ms for   20x20   pixels at 1167,722  for wid=18    using     rgb24 with ratio  19.4%  (    1KB to     0KB), sequence    95, client_options={'flush': 1, 'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:17,642 compress:   0.1ms for   10x20   pixels at  197,2    for wid=18    using     rgb24 with ratio   8.4%  (    0KB to     0KB), sequence    96, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:31:18,903 compress:   0.1ms for   10x20   pixels at  207,2    for wid=18    using     rgb24 with ratio  18.1%  (    0KB to     0KB), sequence    97, client_options={'lz4': 1, 'rgb_format': 'BGRX'}

In gnome terminal I get this, which is much slower, especially over slow links, especially given that people tend to move the cursor a lot. In some cases it'll trigger a video encoder:

2018-11-19 15:35:36,915 compress:   0.1ms for   13x24   pixels at    0,23   for wid=1     using     rgb24 with ratio  20.1%  (    1KB to     0KB), sequence   731, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:37,515 compress:   0.1ms for   13x24   pixels at    0,23   for wid=1     using     rgb24 with ratio  20.1%  (    1KB to     0KB), sequence   732, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:37,821 compress:   0.1ms for   13x24   pixels at    0,23   for wid=1     using     rgb24 with ratio  20.1%  (    1KB to     0KB), sequence   733, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:38,532 compress:   2.7ms for 1288x838  pixels at    0,0    for wid=1     using     rgb24 with ratio   1.0%  ( 4216KB to    41KB), sequence   734, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:39,065 compress:   2.7ms for 1288x838  pixels at    0,0    for wid=1     using     rgb24 with ratio   1.0%  ( 4216KB to    41KB), sequence   735, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:39,278 compress:   2.7ms for 1288x838  pixels at    0,0    for wid=1     using     rgb24 with ratio   1.0%  ( 4216KB to    41KB), sequence   736, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:39,467 compress:   2.7ms for 1288x838  pixels at    0,0    for wid=1     using     rgb24 with ratio   1.0%  ( 4216KB to    41KB), sequence   737, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:39,642 compress:   2.7ms for 1288x838  pixels at    0,0    for wid=1     using     rgb24 with ratio   1.0%  ( 4216KB to    41KB), sequence   738, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:39,808 compress:   2.7ms for 1288x838  pixels at    0,0    for wid=1     using     rgb24 with ratio   1.0%  ( 4216KB to    42KB), sequence   739, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:40,379 compress:   0.2ms for   14x24   pixels at   54,45   for wid=1     using     rgb24 with ratio   1.5%  (    1KB to     0KB), sequence   740, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:40,979 compress:   0.1ms for   14x24   pixels at   54,45   for wid=1     using     rgb24 with ratio   3.3%  (    1KB to     0KB), sequence   741, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:35:41,157 compress:   0.1ms for   14x24   pixels at   54,45   for wid=1     using     rgb24 with ratio  18.9%  (    1KB to     0KB), sequence   742, client_options={'lz4': 1, 'rgb_format': 'BGRX'}

When I "set noruler" in vi in gnome-terminal in XPRA and move the cursor:

2018-11-19 15:37:13,222 compress:   0.1ms for   25x24   pixels at  120,45   for wid=1     using     rgb24 with ratio  11.8%  (    2KB to     0KB), sequence   803, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,253 compress:   0.1ms for   25x24   pixels at  131,45   for wid=1     using     rgb24 with ratio  23.6%  (    2KB to     0KB), sequence   804, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,333 compress:   0.3ms for   25x24   pixels at  142,45   for wid=1     using     rgb24 with ratio  26.2%  (    2KB to     0KB), sequence   805, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,359 compress:   0.1ms for   25x24   pixels at  153,45   for wid=1     using     rgb24 with ratio  28.0%  (    2KB to     0KB), sequence   806, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,391 compress:   0.1ms for   25x24   pixels at  164,45   for wid=1     using     rgb24 with ratio  23.8%  (    2KB to     0KB), sequence   807, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,423 compress:   0.1ms for   25x24   pixels at  175,45   for wid=1     using     rgb24 with ratio  21.8%  (    2KB to     0KB), sequence   808, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,454 compress:   0.1ms for   25x24   pixels at  186,45   for wid=1     using     rgb24 with ratio  33.0%  (    2KB to     0KB), sequence   809, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,529 compress:   0.1ms for   25x24   pixels at  197,45   for wid=1     using     rgb24 with ratio  28.5%  (    2KB to     0KB), sequence   810, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,560 compress:   0.1ms for   25x24   pixels at  208,45   for wid=1     using     rgb24 with ratio  25.2%  (    2KB to     0KB), sequence   811, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,591 compress:   0.1ms for   25x24   pixels at  219,45   for wid=1     using     rgb24 with ratio  17.2%  (    2KB to     0KB), sequence   812, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,623 compress:   0.1ms for   25x24   pixels at  230,45   for wid=1     using     rgb24 with ratio  11.8%  (    2KB to     0KB), sequence   813, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,655 compress:   0.1ms for   25x24   pixels at  241,45   for wid=1     using     rgb24 with ratio  23.6%  (    2KB to     0KB), sequence   814, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:13,728 compress:   0.1ms for   25x24   pixels at  252,45   for wid=1     using     rgb24 with ratio  26.2%  (    2KB to     0KB), sequence   815, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:14,301 compress:   0.1ms for   14x24   pixels at  263,45   for wid=1     using     rgb24 with ratio  19.1%  (    1KB to     0KB), sequence   816, client_options={'lz4': 1, 'rgb_format': 'BGRX'}
2018-11-19 15:37:14,483 compress:   0.1ms for   14x24   pixels at  263,45   for wid=1     using     rgb24 with ratio  32.5%  (    1KB to     0KB), sequence   817, client_options={'lz4': 1, 'rgb_format': 'BGRX'}

For testing I had the encoder setting set to "raw" otherwise gnome-terminal will trigger video encoders and the problem is slightly less obvious.



Tue, 20 Nov 2018 09:56:28 GMT - Antoine Martin: owner changed

The damage handling code can decide to send a full frame when:

If that is the cause of the problem, you really don't want to turn it off permanently so you need to figure out why it gets it wrong.

Hopefully this will fix it:

If you still have problems, please include the OS and software version information (xpra, gnome-terminal, etc), command lines and the -d damage,compress log so we can see what areas of the window gnome-terminal is repainting. Also xpra info.

Another useful tool for visualizing repaints is "paint boxes" (#760), which can be activated using the keyboard shortcut #+F12:toggle_debug.


Wed, 21 Nov 2018 14:45:24 GMT - Antoine Martin: component changed


Wed, 21 Nov 2018 18:42:04 GMT - Nathan Hallquist:

I'm running r21055 on Centos7. The gnome-terminal version is from stock centos 7.5:

[nathan@bobross ~]$ rpm -qf /usr/bin/gnome-terminal
gnome-terminal-3.22.1-2.el7.x86_64
[nathan@bobross ~]$

My environment

[nathan@bobross ~]$ env |grep XPRA
XPRA_MERGE_REGIONS=0
[nathan@bobross ~]$

This variable did not make the problem go away.

At 10:16:30 I start moving the cursor to the right in vi. This is from gt1.txt

2018-11-21 10:16:30,803 do_damage(0, 91, 717, 461, {})    wid=1, using existing delayed {} regions created 0.0ms ago
2018-11-21 10:16:30,803 send_delayed for wid 1, batch delay is 27ms, elapsed time is 27ms
2018-11-21 10:16:30,803 acknowledge_changes() xshm handle=XShmWrapper(0xa00006 - 892x552), damage handle=4194348
2018-11-21 10:16:30,805 send_delayed_regions: sent 3 regions using ['rgb24', 'auto', 'webp']
2018-11-21 10:16:30,806 make_data_packet: image=XShmImageWrapper(BGRA: 0, 91, 717, 461), damage data: (1, 0, 91, 717, 46
1, 'webp')
2018-11-21 10:16:30,824 compress:  18.6ms for  717x461  pixels at    0,91   for wid=1     using      webp with ratio   0
.9%  ( 1291KB to    11KB), sequence    35, client_options={'flush': 2, u'quality': 100, u'rgb_format': 'RGBA'}
2018-11-21 10:16:30,826 auto refresh:  webp screen update (actual quality=100, lossy=False), nothing to do (region=recta
ngle(0, 91, 717, 461), refresh regions=[])

At 10:16:45 I do the same but with ":set noruler," which disables the column number from displaying in the lower rightof the window. Xterm updates both items in small boxes.

2018-11-21 10:16:45,539 do_damage(299, 23, 11, 24, {})    wid=1, using existing delayed {} regions created 0.0ms ago
2018-11-21 10:16:45,565 send_delayed for wid 1, batch delay is 51ms, elapsed time is 51ms
2018-11-21 10:16:45,565 acknowledge_changes() xshm handle=XShmWrapper(0xa00006 - 892x552), damage handle=4194348
2018-11-21 10:16:45,567 send_delayed_regions: sent 2 regions using ['rgb24', 'rgb24']
2018-11-21 10:16:45,567 make_data_packet: image=XShmImageWrapper(BGRA: 299, 23, 11, 24), damage data: (1, 299, 23, 11, 24, 'rgb24')
2018-11-21 10:16:45,567 rgb_encode reformatting because BGRA not in ['RGB', 'RGBX']
2018-11-21 10:16:45,568 rgb_encode using level=1 for   792 bytes at  65 speed, lz4 compressed   11x24   in rgb24/RGB:   792 bytes down to   258
2018-11-21 10:16:45,568 compress:   0.6ms for   11x24   pixels at  299,23   for wid=1     using     rgb24 with ratio  24.4%  (    1KB to     0KB), sequence   104, client_options={'flush': 1, 'lz4': 1, 'rgb_format': 'RGB'}

Wed, 21 Nov 2018 18:42:38 GMT - Nathan Hallquist: attachment set


Thu, 22 Nov 2018 04:16:51 GMT - Antoine Martin: status changed; resolution set

I can reproduce with vim running in gnome-terminal. This is not an xpra bug: gnome-terminal is just repainting most of the window everytime you move left or right. You can see that quite clearly with -d damage: the size of the repaints is huge and bears no relation to what actually needs repainting. That's a "feature" of gnome-terminal, you may want to report it there.

The only way we could deal with this better: #2056

Alternatively, just use a better terminal application.


Thu, 22 Nov 2018 04:41:28 GMT - Nathan Hallquist:

I just learned a lot about the "damage" extension today...

Thanks for looking into it.

People at my company were complaining to me that "gnome-terminal" was unusable (and that, of course, is what they are used to using). I've since set up some .Xdefaults for xterm that they can live with. By the way, this seems to be, unfortunately, a characteristic of anything using the VTE widget.

Is there a place to advertise a list of apps that don't (or do) work well with XPRA so potential users know to steer clear?

#2056 sounds like a really good idea.


Thu, 22 Nov 2018 04:54:24 GMT - Antoine Martin:

Is there a place to advertise a list of apps that don't (or do) work well with XPRA so potential users know to steer clear?

It is well out of date, but we have wiki/ApplicationQuirks.


Thu, 22 Nov 2018 21:55:22 GMT - Nathan Hallquist:

This made me think, "wow gnome-terminal could potentially give somebody an unfair first impression of xpra." If it is as easy to add as I am imagining it is, I propose to add 3 things to the tray: (if it is easy, I volunteer to do the work)

(1) an item firing up the best possible terminal session that the server can find in the path.

(2) an item to run the "xprop" command that will bring up crosshairs for selecting a window to tag as "video"

(3) an item to run the "xprop" command that will bring up crosshairs for selecting a window to tag as "text"


Fri, 23 Nov 2018 08:13:32 GMT - Antoine Martin:

(1) an item firing up the best possible terminal session that the server can find in the path.

That's going to be subjective: some people have bandwidth to spare and care about other features. I'd rather not get into the business of ranking other people's code.

(2) an item to run the "xprop" command that will bring up crosshairs for selecting a window to tag as "video" (3) an item to run the "xprop" command that will bring up crosshairs for selecting a window to tag as "text"

This should be easy enough to implement. Since there may be more than just the "content-type hint" to tune (ie: av-sync, auto-refresh, bandwidth limit, speed, quality, etc), we could let the user select a window then bring up a dialog with those options. Please create a new ticket for that.


Sat, 23 Jan 2021 05:40:48 GMT - migration script:

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