all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@permabit.com>
To: 11822@debbugs.gnu.org
Subject: bug#11822: 24.1; emacsclient terminal mode captures escape characters as text
Date: Thu, 09 Aug 2012 17:12:50 -0400	[thread overview]
Message-ID: <502427D2.3080003@permabit.com> (raw)
In-Reply-To: <415962DC-9BF5-4595-8180-7BE8DB545206@permabit.com>

I've chased the sluggishness down a little further.

I'm using

   emacsclient -c -a "" -n

to pop up a new frame.

If I attach the Emacs process under GDB during the delay while I wait 
for the new frame to be fully displayed, the call stack tends to look 
like this:

#0  0x00007fa626cc18d8 in poll () from /lib/libc.so.6
#1  0x00007fa6265d98ca in ?? () from /usr/lib/libxcb.so.1
#2  0x00007fa6265dbc0c in xcb_wait_for_reply () from /usr/lib/libxcb.so.1
#3  0x00007fa62a0a7613 in _XReply () from /usr/lib/libX11.so.6
#4  0x00007fa62a0831a5 in XAllocColor () from /usr/lib/libX11.so.6
#5  0x00000000004b621c in x_alloc_nearest_color_1 (dpy=0x7fff726fdc40, 
cmap=1, color=0xffffffffffffffff) at xterm.c:1730
#6  0x00000000004cb023 in x_defined_color (f=0x52fff50, 
color_name=<optimized out>, color=0x7fff726fde70, alloc_p=1) at xfns.c:613
#7  0x00000000004a9adc in load_color (f=0x7fff726fdc40, face=0x53e7b70, 
name=102599361, target_index=LFACE_FOREGROUND_INDEX) at xfaces.c:1336
#8  0x00000000004abc53 in load_face_colors (attrs=<optimized out>, 
face=<optimized out>, f=<optimized out>) at xfaces.c:1422
#9  realize_x_face (attrs=<optimized out>, cache=<optimized out>) at 
xfaces.c:5629
#10 realize_face (cache=0x3e3ec30, attrs=0x7fff726fdfe0, 
former_face_id=<optimized out>) at xfaces.c:5501
#11 0x00000000004b0eed in realize_named_face (f=<optimized out>, 
symbol=<optimized out>, id=7) at xfaces.c:5473
#12 0x00000000004b1145 in realize_basic_faces (f=0x52fff50) at xfaces.c:5295
#13 0x00000000004b17cd in recompute_basic_faces (f=0x52fff50) at 
xfaces.c:839
#14 0x000000000043938d in init_iterator (it=0x7fff726fe1e0, w=0x56d0850, 
charpos=-1, bytepos=-1, row=0x0, base_face_id=DEFAULT_FACE_ID) at 
xdisp.c:2618
#15 0x000000000044962b in x_consider_frame_title (frame=<optimized out>) 
at xdisp.c:10972
#16 0x0000000000449774 in prepare_menu_bars () at xdisp.c:11031
#17 0x0000000000455b95 in redisplay_internal () at xdisp.c:12944
#18 0x0000000000456575 in redisplay_preserve_echo_area 
(from_where=1919933504) at xdisp.c:13560
#19 0x00000000005b3288 in Fdelete_process (process=69478117) at 
process.c:796
#20 0x000000000056c9fc in Ffuncall (nargs=<optimized out>, 
args=<optimized out>) at eval.c:3002
#21 0x00000000005a6ef5 in exec_byte_code (bytestr=<optimized out>, 
vector=<optimized out>, maxdepth=<optimized out>, 
args_template=<optimized out>, nargs=104812360, args=0x33a5) at 
bytecode.c:785
...

Lisp Backtrace:
"delete-process" (0x72700b50)
"server-delete-client" (0x72700ce0)
0x4c33b60 PVEC_COMPILED
"funcall" (0x72700e40)
0x4bde3c0 PVEC_COMPILED
"funcall" (0x72701260)
"server-execute" (0x727016b8)
0x4e59700 PVEC_COMPILED
0x4a72ac0 PVEC_COMPILED
"funcall" (0x72701970)
"server-execute-continuation" (0x72701de8)
...

Sometimes it's XParseColor instead of XAllocColor.

When I pop up a new frame, it appears that recompute_basic_faces is 
called three times for the new frame, and once for each existing one:

Breakpoint 3, recompute_basic_faces (f=0x4d75e00) at xfaces.c:835
835    {
(gdb) c
Continuing.

Breakpoint 3, recompute_basic_faces (f=0x4d75e00) at xfaces.c:835
835    {
(gdb)
Continuing.

Breakpoint 3, recompute_basic_faces (f=0x4d75e00) at xfaces.c:835
835    {
(gdb)
Continuing.

Breakpoint 3, recompute_basic_faces (f=0x61a7090) at xfaces.c:835
835    {
(gdb)
Continuing.

Breakpoint 3, recompute_basic_faces (f=0x698a7c0) at xfaces.c:835
835    {
(gdb)
Continuing.

...

I also noticed that the remote frame (in this case, 0x52fff50, which 
happens to be the one shown in the C stack trace above, is displayed 
over SSH + VPN + a slow net connection) takes quite a bit longer to 
process before moving on to the next recompute_basic_faces call.  I've 
been using this Emacs process actively today, including creating a few 
new frames, but haven't touched the frame displayed remotely since at 
least last night, possibly longer.  Yet this recompute_basic_faces work 
still gets done each time.


If I try creating a new tty frame, the stack trace is a bit different:

#0  0x00007fa626cc18d8 in poll () from /lib/libc.so.6
#1  0x00007fa6265d98ca in ?? () from /usr/lib/libxcb.so.1
#2  0x00007fa6265dbc0c in xcb_wait_for_reply () from /usr/lib/libxcb.so.1
#3  0x00007fa62a0a7613 in _XReply () from /usr/lib/libX11.so.6
#4  0x00007fa62a08fb11 in XParseColor () from /usr/lib/libX11.so.6
#5  0x00000000004cafa4 in x_defined_color (f=0x52fff50, 
color_name=<optimized out>, color=0x7fff726fe430, alloc_p=1) at xfns.c:611
#6  0x00000000004a9adc in load_color (f=0x7fff726fe210, face=0x4b738f0, 
name=102599489, target_index=LFACE_BACKGROUND_INDEX) at xfaces.c:1336
#7  0x00000000004abc38 in load_face_colors (attrs=<optimized out>, 
face=<optimized out>, f=<optimized out>) at xfaces.c:1421
#8  realize_x_face (attrs=<optimized out>, cache=<optimized out>) at 
xfaces.c:5629
#9  realize_face (cache=0x3e3ec30, attrs=0x7fff726fe5a0, 
former_face_id=<optimized out>) at xfaces.c:5501
#10 0x00000000004b0eed in realize_named_face (f=<optimized out>, 
symbol=<optimized out>, id=10) at xfaces.c:5473
#11 0x00000000004b1181 in realize_basic_faces (f=0x52fff50) at xfaces.c:5298
#12 0x00000000004b17cd in recompute_basic_faces (f=0x52fff50) at 
xfaces.c:839
#13 0x000000000043938d in init_iterator (it=0x7fff726fe7a0, w=0x56d0850, 
charpos=-1, bytepos=-1, row=0x0, base_face_id=DEFAULT_FACE_ID) at 
xdisp.c:2618
#14 0x000000000044962b in x_consider_frame_title (frame=<optimized out>) 
at xdisp.c:10972
#15 0x0000000000449774 in prepare_menu_bars () at xdisp.c:11031
#16 0x0000000000455b95 in redisplay_internal () at xdisp.c:12944
#17 0x0000000000503359 in read_char (commandflag=<optimized out>, 
nmaps=<optimized out>, maps=0x0, prev_event=<optimized out>, 
used_mouse_menu=<optimized out>, end_time=<optimized out>) at 
keyboard.c:2448
#18 0x000000000059416c in read_filtered_event (no_switch_frame=0, 
ascii_required=0, error_nonascii=0, input_method=0, seconds=<optimized 
out>) at lread.c:621
#19 0x000000000056c9d9 in Ffuncall (nargs=<optimized out>, 
args=<optimized out>) at eval.c:3009
#20 0x00000000005a6ef5 in exec_byte_code (bytestr=<optimized out>, 
vector=<optimized out>, maxdepth=<optimized out>, 
args_template=<optimized out>, nargs=104812360, args=0x33a5) at 
bytecode.c:785
...

Lisp Backtrace:
"read-event" (0x727014a8)
"terminal-init-xterm" (0x72701688)
"tty-run-terminal-initialization" (0x72701848)
"tty-create-frame-with-faces" (0x72701a08)
"make-frame" (0x72701bf0)
"server-create-tty-frame" (0x72701df0)
0x5f64d20 PVEC_COMPILED
...

But either way, we get into the display code and it thinks it's got to 
do the color/face setup all over again for the remote display.

That seems to be where the delay is coming from.  If, in fact, the Lisp 
code supporting the xterm type is sending its escape sequence before all 
of this is triggered, that would certainly explain why it times out and 
the response sequence winds up added to the buffer content.

Ken





  reply	other threads:[~2012-08-09 21:12 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-30  0:08 bug#11822: 24.1; emacsclient terminal mode captures escape characters as text Ken Raeburn
2012-06-30  5:55 ` Eli Zaretskii
2012-07-31 21:06   ` Ken Raeburn
2012-08-08  3:13     ` Ken Raeburn
2012-08-08  4:52       ` Dan Nicolaescu
2012-08-08  9:26         ` Ken Raeburn
2012-08-09 21:12           ` Ken Raeburn [this message]
2012-08-10  6:16             ` Eli Zaretskii
2012-08-10  7:27               ` Ken Raeburn
2012-08-10  7:46                 ` Eli Zaretskii
2012-08-10  8:08                   ` Eli Zaretskii
2015-09-07 21:09                     ` Ken Raeburn
2015-09-08  1:29                       ` Stefan Monnier
2015-09-08  4:29                         ` Eli Zaretskii
2015-09-08  6:53                         ` Ken Raeburn
2015-09-08 13:03                           ` Stefan Monnier
2015-09-08 13:11                           ` Stefan Monnier
2015-09-08 17:21                             ` Eli Zaretskii
2015-09-08  4:48                       ` Eli Zaretskii
2015-09-08 10:15                         ` Ken Raeburn
2015-09-08 13:35                           ` Stefan Monnier
2015-09-08 17:33                           ` Eli Zaretskii
2015-09-08 19:54                             ` Ken Raeburn
2015-09-09 14:16                               ` Eli Zaretskii
2015-09-10  6:59                                 ` Ken Raeburn
2015-09-10 15:36                                   ` Eli Zaretskii
2015-09-10 17:56                                     ` Stefan Monnier
2015-09-10 18:06                                       ` Eli Zaretskii
2015-09-11 12:56                                         ` Stefan Monnier
2015-09-11 13:53                                           ` Eli Zaretskii
2015-09-11 16:53                                             ` Stefan Monnier
2015-09-11  6:54                                     ` Ken Raeburn
2015-09-11  7:22                                       ` Eli Zaretskii
2015-09-11 23:11                                         ` Ken Raeburn
2015-09-12  0:51                                           ` Stefan Monnier
2015-09-12  1:34                                             ` Ken Raeburn
2015-09-15 14:29                                             ` Eli Zaretskii
2015-09-15 16:14                                               ` Stefan Monnier
2015-09-18 14:19                                                 ` Eli Zaretskii
2015-09-21  9:23                                                   ` Ken Raeburn
2015-09-21  9:44                                                     ` Eli Zaretskii
2015-09-23 17:27                                                       ` Ken Raeburn
2015-09-23 18:04                                                         ` martin rudalics
2015-09-23 20:59                                                           ` Ken Raeburn
2015-09-23 19:17                                                         ` Eli Zaretskii
2015-09-24  8:52                                                           ` Ken Raeburn
2015-09-24 18:46                                                             ` Eli Zaretskii
2015-09-24 20:08                                                               ` Ken Raeburn
2015-09-25  6:49                                                                 ` Eli Zaretskii
2015-09-25 12:07                                                                   ` Stefan Monnier
2015-09-26  7:01                                                                   ` Eli Zaretskii
2015-09-25  6:50                                                             ` Eli Zaretskii
2015-09-25 12:09                                                               ` Stefan Monnier
2015-09-25 13:29                                                                 ` Eli Zaretskii
2015-09-25 15:18                                                                   ` Stefan Monnier
2015-09-12  7:30                                           ` Eli Zaretskii
2015-09-11 13:39                                       ` Stefan Monnier
2015-09-11 14:01                                         ` Eli Zaretskii
2015-09-08 13:22                         ` Stefan Monnier
2015-09-08 17:25                           ` Eli Zaretskii
2015-09-08 18:52                             ` Stefan Monnier
2015-09-08 19:08                               ` Eli Zaretskii
2015-09-08 20:37                                 ` Stefan Monnier
2015-09-08 17:36                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=502427D2.3080003@permabit.com \
    --to=raeburn@permabit.com \
    --cc=11822@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.