Xpra: Ticket #2257: BGRA icons garbled

I have had issues with the window icon from day one of using Xpra (about two weeks ago), it would always look garbled. At first I thought it could not extract window icons from KDE programs (e.g. xterm worked fine) and that it just took a screenshot and scaled that, but that didn't look logical with different programs. I fired up some debugging stuff, and the logs showed that it did, in fact, find a lot of icons.

Log excerpt for konsole:

2019-04-06 06:00:01,546 _NET_WM_ICON_NAME=
2019-04-06 06:00:01,547 _NET_WM_ICON changed on 0x600007, re-reading
2019-04-06 06:00:01,587 WindowIconSource(['premult_argb32', 'default', 'png'], {'default.icons': (), 'max_size': (128, 128), 'greedy': True, 'size': (64, 64)}) has_png=True, has_premult=True
2019-04-06 06:00:01,588 client icon settings: size=(64, 64), max_size=(128, 128)
2019-04-06 06:00:01,595 send_window_icon window WindowModel(0x600007) found 7 icons
2019-04-06 06:00:01,596 send_window_icon() window=WindowModel(0x600007), wid=1, compression scheduled in 50ms for batch delay=-1
2019-04-06 06:00:01,648 compress_and_send_window_icon() 64x64 in BGRA format, 16384 bytes
2019-04-06 06:00:01,648 compress_and_send_window_icon: 64x64 (max-size=(128, 128), standard-size=(64, 64)), sending as png=True, pixel_format=BGRA
2019-04-06 06:00:01,648  must convert=True, must scale=False
2019-04-06 06:00:01,650 server window icon saved to server-window-1-icon-433769.png
2019-04-06 06:00:01,651 queuing window icon update: ('window-icon', 1, 64, 64, 'png', Compressed(png: 2395 bytes))

I saved them and found a rather interesting result, it seems that the application icon is repeated 4 times in the top quarter of the resulting image with little to no color (or high transparency), the remainder filled with some garbage. After a lot of digging I converged on a part I ignored at first, but which had to be the problem. The key here is that the icon is in BGRA format. This causes a premultiplication and that seems to screw it up. If I comment out line 190 of windowicon_source.py, I get the proper icons in all of the applications I'm using: #pixel_data = premultiply_argb(pixel_data)

I have little to no knowledge of the inner workings of Xpra so I assume this isn't a catch-all solution.

The server is running Kubuntu 18.10 with Xpra 2.5-r22135-1, as a guest in VMWare.

xpra start --daemon=no --bind-tcp= --mdns=yes --pulseaudio=no --speaker=disabled --microphone=disabled --printing=no --tcp-auth=password,value=xxx
start-env = XDG_CONFIG_DIRS=/etc/xdg/xdg-plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings
start-env = XDG_DATA_DIRS=/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop
start-env = XDG_RUNTIME_DIR=/run/user/1000
start-env = XDG_SESSION_TYPE=x11

I'm connecting to it from the host using Xpra 3.0-22235 64-bit on Windows 10 Pro 1803. "C:\Program Files\Xpra\Xpra.exe" attach --encoding=rgb --compressors=lz4 tcp://uuu:xxx@

Fri, 05 Apr 2019 18:04:10 GMT - Vincent Huisman: attachment set

Garbled icon

Fri, 05 Apr 2019 18:04:38 GMT - Vincent Huisman: attachment set

Icon after disabling BGRA premult

Sat, 06 Apr 2019 03:52:37 GMT - Antoine Martin: status changed; resolution set

See #2252

Sat, 23 Jan 2021 05:46:22 GMT - migration script:

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