Xpra: Ticket #2211: gtkperf hangs gtk3 server

Running gtkperf -a in a loop, and running xpra info in another loop in parallel eventually causes the server to hang. It shows new connection but times them all out.

Running gtkperf -a in a loop alone does not crash.

Running xpra info alone in a loop does not crash or leak any memory.



Wed, 13 Mar 2019 12:58:53 GMT - Antoine Martin: status, description changed


Mon, 18 Mar 2019 15:11:35 GMT - Antoine Martin:

The server goes AWOL following this message in the server log:

(Xpra:7593): Gdk-WARNING **: 21:51:39.364: GdkWindow 0x400d81 unexpectedly destroyed
/usr/lib64/python3.7/site-packages/xpra/x11/models/window.py:327: Warning: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed
  self.corral_window = None
/usr/lib64/python3.7/site-packages/xpra/x11/models/window.py:327: Warning: g_object_set_qdata_full: assertion 'G_IS_OBJECT (object)' failed
  self.corral_window = None
/usr/lib64/python3.7/site-packages/xpra/x11/models/window.py:327: Warning: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
  self.corral_window = None
2019-03-18 21:51:48,306 Warning: timeout on screen updates for window 1,
2019-03-18 21:51:48,306  already delayed for more than 15 seconds
(Xpra:7593): Gdk-WARNING **: 21:51:53.976: GdkWindow 0x400def unexpectedly destroyed
2019-03-18 21:51:55,098 Error: connection timed out: unix-domain socket:/run/user/1000/xpra/desktop-20

Even with python2, things can degenerate, though not as fast and not as badly.


Mon, 18 Mar 2019 15:12:17 GMT - Antoine Martin: attachment set

xpra info of a hung python2 server after ~10000 gtkperf windows are shown


Mon, 18 Mar 2019 15:30:44 GMT - Antoine Martin: attachment set

python3 server just before it hung


Mon, 18 Mar 2019 16:38:22 GMT - Antoine Martin: attachment set

verify that we are in the main thread in more places


Mon, 18 Mar 2019 16:39:47 GMT - Antoine Martin:

r22114 adds extra thread checking to the gtk X11 context manager code, and the patch above adds yet more checks. But none of those trigger any warnings.

Could it be a race condition that is made more likely by the extra delay introduced by the "xpra info" query?


Tue, 19 Mar 2019 02:10:41 GMT - Antoine Martin: priority changed

When the server seems stuck, it is consuming a lot of CPU time in the X11 event loop. Simply killing the gtkperf client loop and waiting for things to settle eventually brings it back to life, so I'm lowering the priority as it's not a crash, "just" an X11 DoS.

Is GTK3 that much slower? (New ticket: #2219) Less efficient? Gets more events?

The hang is often preceded by:

2019-03-18 23:56:53,637 Warning: timeout on screen updates for window 1,
2019-03-18 23:56:53,637  already delayed for more than 15 seconds

Which could happen if the main thread is too busy to answer.

How can we avoid getting in this situation, or detect it and deal with it? Maybe as part of the move to wayland, we can move away from GTK? We already have window models, do we really need those GDK windows to wrap the X11 window?


Tue, 20 Aug 2019 05:38:17 GMT - Antoine Martin: milestone changed

GTK3 is now slower: ticket:2219#comment:3


Thu, 05 Sep 2019 06:17:57 GMT - Antoine Martin: attachment set

last server info captured before it becomes unresponsive, without keyboard data


Thu, 05 Sep 2019 09:11:17 GMT - Antoine Martin:

Different symptoms this time:

And another one:

2019-09-05 13:19:13,201 New unix-domain connection received on /run/user/1000/xpra/localhost.localdomain-2
2019-09-05 13:19:13,204 New unix-domain connection received on /run/xpra/localhost.localdomain-2
2019-09-05 13:19:13,607 New unix-domain connection received on /run/user/1000/xpra/localhost.localdomain-2
(Xpra:21966): Gdk-WARNING **: 13:19:14.578: GdkWindow 0x400a59 unexpectedly destroyed
2019-09-05 13:19:14,607 New unix-domain connection received on /run/user/1000/xpra/localhost.localdomain-2
2019-09-05 13:19:14,608 New unix-domain connection received on /run/xpra/localhost.localdomain-2
/usr/lib64/python3.7/site-packages/xpra/x11/models/window.py:327: Warning: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed
  self.corral_window = None
/usr/lib64/python3.7/site-packages/xpra/x11/models/window.py:327: Warning: g_object_set_qdata_full: assertion 'G_IS_OBJECT (object)' failed
  self.corral_window = None
/usr/lib64/python3.7/site-packages/xpra/x11/models/window.py:327: Warning: g_object_remove_toggle_ref: assertion 'G_IS_OBJECT (object)' failed
  self.corral_window = None
2019-09-05 13:19:21,559 processed structured info request from unix-domain socket:/run/user/1000/xpra/localhost.localdomain-2 in 8ms
2019-09-05 13:19:22,041 New unix-domain connection received on /run/user/1000/xpra/localhost.localdomain-2
2019-09-05 13:19:23,042 New unix-domain connection received on /run/xpra/localhost.localdomain-2
2019-09-05 13:19:23,042 New unix-domain connection received on /run/user/1000/xpra/localhost.localdomain-2
(Xpra:21966): Gdk-WARNING **: 13:19:31.031: GdkWindow 0x400bda unexpectedly destroyed
(Xpra:21966): Gdk-WARNING **: 13:19:39.869: GdkWindow 0x400c5b unexpectedly destroyed
2019-09-05 13:19:43,062 Error: connection timed out: unix-domain socket:/run/user/1000/xpra/localhost.localdomain-2
2019-09-05 13:19:43,462 New unix-domain connection received on /run/user/1000/xpra/localhost.localdomain-2

This seems to happen when we reach around 2200 to 2500 windows.

r23718 allows us to see how busy the UI thread is, logging the time it takes to service a timer call with a zero delay. Normally, that's around 0.10ms on my system. When running this stress test, it creeps up and by the time the server stops responding, the delay is around 35ms. Roughly 350 times higher.. Meanwhile the info requests are still being processed around 7ms. That's until the server no longer processes socket connection attempts.

The one thing that always seems to happen before the server goes AWOL is this:

(Xpra:31569): Gdk-WARNING **: 16:07:11.444: GdkWindow 0x400bf7 unexpectedly destroyed

The GTK3 code looks like this:

if (!GDK_WINDOW_DESTROYED (window))
{
  if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
     g_warning ("GdkWindow %#lx unexpectedly destroyed", GDK_WINDOW_XID (window));
  _gdk_window_destroy (window, TRUE);
}

The window that is triggering this warning is not a foreign window, so it must be our corral window?


This should be fixed by r23712 and this is probably unrelated as the server problems occur even without having a client connected.


Thu, 05 Sep 2019 09:41:49 GMT - Antoine Martin: summary changed

This does not cause any problems with python2 / GTK3, where the UI thread service time remains constant and usually lower than 0.10ms. Something might be leaking in GTK3.


Thu, 05 Sep 2019 13:41:45 GMT - Antoine Martin: summary changed

xpra info shows us that the server has locked up, but it isn't required to trigger it.

The good news is that if the gtkperf loop is stopped quickly enough, the server does recover and can service new clients, including xpra info.


Sun, 08 Sep 2019 09:23:46 GMT - Antoine Martin: status changed; resolution set

I don't know how to debug this further. It really looks like a regression in GTK, so I'm closing this as 'upstream'.

Applications that have a behaviour similar to gtkperf should be considered pathological and are not going to be supported with the GTK3 server.


Sat, 23 Jan 2021 05:45:09 GMT - migration script:

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