Xpra: Ticket #2727: corrupted/missing window icons in Ubuntu launcher

Client version: Ubuntu 18.04.4 LTS with Unity, Xpra GTK3 X11 client version 3.0.8-r25889 64-bit

It happens quite often (once in a few times), usually when starting Eclipse IDE on server, that window icon shown in launcher is either empty or sometimes corrupted. It even happened that one application (mate-terminal) got an icon of another application, with some corrupted pixels visible. I captured it on screenshots - see attachments.

I've been able to debug it. Here is how I started the client, with a few log lines:

krzysztof@krzysztof-HP-ProBook-4720s:~$ XPRA_SAVE_WINDOW_ICONS=1 xpra attach -d icon ssh/tad-34/2 --ssh=ssh
2020-04-14 10:19:31,200 Xpra GTK3 X11 client version 3.0.8-r25889 64-bit
2020-04-14 10:19:31,455  running on Linux Ubuntu 18.04 bionic
2020-04-14 10:19:31,457  window manager is 'GNOME Shell'
2020-04-14 10:19:34,738 GStreamer version 1.14.5 for Python 3.6.9 64-bit
2020-04-14 10:19:36,789  keyboard settings: rules=evdev, model=pc105, layout=pl,us,pl
2020-04-14 10:19:36,805  desktop size is 1600x900 with 1 screen:
2020-04-14 10:19:36,806   :0.0 (423x238 mm - DPI: 96x96) workarea: 1533x873 at 67x27
2020-04-14 10:19:36,806     LVDS (367x230 mm - DPI: 110x99)
Verification code:
Password:
2020-04-14 10:19:59,775 enabled remote logging
2020-04-14 10:19:59,777 Xpra GTK3 X11 server version 3.0.6-r25195 64-bit
2020-04-14 10:19:59,778  running on Linux LinuxMint 19.2 tina
2020-04-14 10:19:59,805 Attached to tad-34:22
2020-04-14 10:19:59,805  (press Control-C to detach)

Using XPRA_SAVE_WINDOW_ICONS=1 I noticed that saved icons were correct, so it was not a problem with server sending invalid icons. I realized that when window title changes, the icon usually gets fixed (but not always). I saw in logs that reset_icon() is called.

I checked affected windows using xprop, to see _NET_WM_ICON. Indeed, icons were invalid. Before that I thought Unity might have a bug - I think xprop proves it is not the case.

After some time of debugging, I focused my attention on get_pixbuf_from_data() in gtk_common/gtk_util.py. It calls function GdkPixbuf.Pixbuf.new_from_data(). It seems this function is not safe to be called from python. See these bug reports:

It is recommended to use new_from_bytes() instead. So I tested the following fix:

diff -ru gtk_common/gtk_util.py gtk_common/gtk_util.py
--- gtk_common/gtk_util.py  2019-11-30 13:33:28.000000000 +0100
+++ gtk_common/gtk_util.py  2020-04-08 17:45:16.410738189 +0200
@@ -171,10 +171,10 @@
     def get_pixbuf_from_data(rgb_data, has_alpha, w, h, rowstride):
-        data = array.array('B', strtobytes(rgb_data))
-        return GdkPixbuf.Pixbuf.new_from_data(data, GdkPixbuf.Colorspace.RGB,
-                                         has_alpha, 8, w, h, rowstride,
-                                         None, None)
+        log("get_pixbuf_from_data: using new_from_bytes, w=%s h=%s", w, h)
+        data = glib.Bytes(rgb_data)
+        return GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
+                                         has_alpha, 8, w, h, rowstride)
     get_pixbuf_from_window = gdk.pixbuf_get_from_window

With this fix, the problem no longer appeared. Every icon is now displayed correctly.



Tue, 14 Apr 2020 11:15:01 GMT - Krzysztof Sachanowicz: attachment set


Tue, 14 Apr 2020 11:15:13 GMT - Krzysztof Sachanowicz: attachment set


Tue, 14 Apr 2020 11:15:27 GMT - Krzysztof Sachanowicz: attachment set


Tue, 14 Apr 2020 11:15:51 GMT - Krzysztof Sachanowicz: attachment set


Tue, 14 Apr 2020 11:24:34 GMT - Krzysztof Sachanowicz:

Window with blank icon:

krzysztof@krzysztof-HP-ProBook-4720s:~$ xprop
_NET_WM_ICON(CARDINAL) = 	Icon (48 x 48):
_XPRA_WID(CARDINAL) = 1500
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 0
_GTK_EDGE_CONSTRAINTS(CARDINAL) = 85
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_RESIZE, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_SHADE, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_CLOSE, _NET_WM_ACTION_ABOVE, _NET_WM_ACTION_BELOW
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_FOCUSED
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		bitmap id # to use for icon: 0x2014ccf
		bitmap id # of mask for icon: 0x2014cd5
		window id # of group leader: 0x2000103
_GTK_THEME_VARIANT(UTF8_STRING) =
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 28, 0
XID(CARDINAL) = 12585242
XdndAware(ATOM) = BITMAP
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 33639168, 33639169
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2014aff
WM_CLIENT_LEADER(WINDOW): window id # 0x2000001
_NET_WM_PID(CARDINAL) = 820
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "krzysztof-HP-ProBook-4720s"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified minimum size: 581 by 25
		program specified maximum size: 32767 by 32767
		program specified base size: 581 by 25
		window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Eclipse", "Eclipse"
WM_ICON_NAME(STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"
_NET_WM_ICON_NAME(UTF8_STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"
WM_NAME(STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"
_NET_WM_NAME(UTF8_STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"

The same window, with fixed icon after changing window title a few times:

krzysztof@krzysztof-HP-ProBook-4720s:~$ xprop
_NET_WM_ICON(CARDINAL) = 	Icon (48 x 48):
	           ░░░░░▒▒▒▒▒▒▒░
	         ░░░░░▓▓▓▓▓▓▓▓▓▓▓▒░
	       ░░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░
	      ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
	     ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	    ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	   ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	  ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
	  ░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	 ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
	 ░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░
	░░░░▒                             ░▒
	░░░░▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
	░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	░░░░▒                              ▒
	░░░░▒                              ▒
	░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	░░░░▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░▒▒▒▒▒▒▓
	░░░░▒                             ░▒
	░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒░
	 ░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
	 ░░░░▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒
	  ░░░░▓▓▓▓▓▓▓▒▓▓▓▓▓▓▓▓▓▓▓▓▒▓▓▓▓▓▓▓
	  ░░░░▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▒
	   ░░░░▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒          ░
	    ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▒         ▓░
	     ░░░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░       ▓▒
	      ░░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▓▓▓▓      ▒▓
	       ░░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░ ░▓▓█▒    ░▓
	         ░░░░░▓▓▓▓▓▓▓▓▓▓▓▒░  ░░▒█▓█▒   ▓░
	           ░░░░░░▒▒▒▒▒░░    ░░  ▓█▓▓░ ▓░   ░
	                           ░░    ▓▓█▒▒▒ ▒░ ░░░▒
	                           ░     ░▓▓▒▓ ░  ░░ ▒░░
	                          ░░      ▓▒▓▓░░▒░ ░ ▒░░
	                          ░░     ▒▒▒█▓▓░     ░
	                          ░░    ░▓ ░▓▓█▓     ░
	                           ░░  ░▓   ░█▓█▒   ░░
	                           ░░░ ▓░    ▒▓▓▓░ ░▒
	                            ░░░▒      ▓▓▓▓░░
	                             ▒░░░     ░▓▒▒▒
	                            ░▓   ░░░ ░ ░▒▓█▒
	                            ░           ░░░░
_XPRA_WID(CARDINAL) = 1500
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 0
_GTK_EDGE_CONSTRAINTS(CARDINAL) = 85
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_RESIZE, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_SHADE, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_CLOSE, _NET_WM_ACTION_ABOVE, _NET_WM_ACTION_BELOW
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_FOCUSED
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		bitmap id # to use for icon: 0x2015608
		bitmap id # of mask for icon: 0x201560e
		window id # of group leader: 0x2000103
_GTK_THEME_VARIANT(UTF8_STRING) =
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 28, 0
XID(CARDINAL) = 12585242
XdndAware(ATOM) = BITMAP
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 33639168, 33639169
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2014aff
WM_CLIENT_LEADER(WINDOW): window id # 0x2000001
_NET_WM_PID(CARDINAL) = 820
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "krzysztof-HP-ProBook-4720s"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified minimum size: 581 by 25
		program specified maximum size: 32767 by 32767
		program specified base size: 581 by 25
		window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Eclipse", "Eclipse"
WM_ICON_NAME(STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"
_NET_WM_ICON_NAME(UTF8_STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"
WM_NAME(STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"
_NET_WM_NAME(UTF8_STRING) = "eclipse-workspace2 - repo2/coolkit/src/include/cool/debug.h - Eclipse IDE  on tad-34"

Tue, 14 Apr 2020 11:34:41 GMT - Antoine Martin: status changed; resolution set

Awesome work, thank you so much!

Applied in r26118. (will backport)


Tue, 14 Apr 2020 12:06:34 GMT - Antoine Martin:

Found more places where we were using GdkPixbuf.Pixbuf.new_from_data and switched them over: r26121.


Sat, 23 Jan 2021 05:59:08 GMT - migration script:

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