Subject: bug#61667: 29.0.60; Failure to redisplay

From: Po Lu <[email-masked]>
Date: Wed, 01 Mar 2023 12:50:33 +0800

Dmitry Gutov <[email-masked]> writes:

> On 01/03/2023 03:11, Po Lu wrote:
>> Dmitry Gutov <[email-masked]> writes:
>> 
>>> Why does constant frame-title-format fix this, though?
>> Because presumably Mutter has no need to damage the title bar, which
>> you
>> do see changing.
>> 
>>> I have tried this with default config (double buffering on,
>>> undecorated off), and I don't see any delay between text insertion and
>>> frame title changes. 1 second pause, "Test 1" is inserted, the title
>>> changes (*), 1 second pause, "Test 2" is inserted, the title changes.
>>>
>>> That probably means I don't need to test the alternative configs,
>>> right?
>> Yes, but that's odd.  What if you run the entire test in an infinite
>> loop?
>> Do you eventually notice a delay?
>
> Originally I ran the test a couple of dozen times (restating Emacs
> every try), like I do with the MRE scenario when testing different
> settings.
>
> Now I re-ran it with (dotimes (i 20) ...) twice, and didn't see the
> problem either.
>
> Not sure how infinite you want this loop to be, but the original
> scenarios would almost certainly have showed the problem several times
> over this many tries.

OK, I have to be 100% sure we're not missing something here.  With
stderr redirected to a file, and the following instrumentation applied::

diff --git a/src/xfns.c b/src/xfns.c
index 9e004f6a678..b4bef7f38fd 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2232,6 +2232,18 @@ x_set_name_internal (struct frame *f, Lisp_Object name)
 			 SDATA (encoded_icon_name),
 			 SBYTES (encoded_icon_name));
 
+	long long
+        current_ust (void)
+	{
+	  struct timespec ts;
+
+	  clock_gettime (CLOCK_MONOTONIC, &ts);
+	  return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+	}
+
+	fprintf (stderr, "x_set_title: %s, %lld\n",
+		 SSDATA (name), current_ust ());
+
 	if (do_free_icon_value)
 	  xfree (icon.value);
 	if (do_free_text_value)
diff --git a/src/xterm.c b/src/xterm.c
index 70bcb67d80d..c7ad1bbb722 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7439,6 +7439,18 @@ show_back_buffer (struct frame *f)
       swap_info.swap_action = XdbeCopied;
       XdbeSwapBuffers (FRAME_X_DISPLAY (f), &swap_info, 1);
 
+	long long
+        current_ust (void)
+	{
+	  struct timespec ts;
+
+	  clock_gettime (CLOCK_MONOTONIC, &ts);
+	  return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+	}
+
+	fprintf (stderr, "show_back_buffer: %lld\n",
+		 current_ust ());
+
 #if defined HAVE_XSYNC && !defined USE_GTK && defined HAVE_CLOCK_GETTIME
       /* Finish the frame here.  */
       x_sync_update_finish (f);

do you see a significant amount of time taken between setting the title
and swapping buffers?