all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: charles@aurox.ch (Charles A. Roelli)
To: Eli Zaretskii <eliz@gnu.org>
Cc: 29325@debbugs.gnu.org
Subject: bug#29325: 26.0.90: Info scrolling stuck
Date: Tue, 21 Nov 2017 20:24:05 +0100	[thread overview]
Message-ID: <m23757wi3u.fsf@aurox.ch> (raw)
In-Reply-To: <83r2ssd7eq.fsf@gnu.org> (message from Eli Zaretskii on Mon, 20 Nov 2017 22:25:33 +0200)

> Date: Mon, 20 Nov 2017 22:25:33 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > Date: Mon, 20 Nov 2017 20:52:39 +0100
> > From: charles@aurox.ch (Charles A. Roelli)
> > CC: 29325@debbugs.gnu.org
> > 
> > I don't have access to a GNU/Linux system at the moment, but if I
> > recall correctly, it would be 5 lines at a time, when scrolling
> > slowly.
> 
> Then I'd expect the same behavior to happen if you do "M-5 M-v"
> instead of turning the wheel.  Does it?

It does.

> Just to make sure we are not barking up the wrong tree: this is in
> "emacs -Q" with no customizations of any scroll-related variables,
> like scroll-margin, scroll-conservatively, etc., right?

Yes, always from emacs -q.

> Date: Sun, 19 Nov 2017 19:12:00 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> If you build with --enable-checking='yes,glyphs', and then turn on
> redisplay tracing with "M-x trace-redisplay" before scrolling with the
> wheel, what do you see?  And how does that trace differ from when you
> scroll with "M-1 M-v"?
> 
> (I find it useful to disable blink-cursor-mode and global-eldoc-mode
> before such experiments, because they tend to trigger extra redisplay
> cycles that conceal the interesting parts.)

Thanks again for this useful advice.  What follows is the annotated
output, according to the following recipe:

> The behavior is different depending on how fast the mouse wheel is
> turned.  If it is turned slowly several times in a row, it is possible
> to make window-start reach as far as the second or third line of the
> buffer.  If you turn it once more, then window-start jerks down a few
> lines instead of reaching the start of the buffer.  This can be
> repeated ad infinitum.

redisplay_internal 0 <= START FIRST SCROLL
0x1360330 (*info*): forced window start
redisplay_preserve_echo_area (8)
redisplay_internal 0
redisplay_preserve_echo_area (8)
redisplay_internal 0
redisplay_internal 0
redisplay_internal 0 <= START SECOND SCROLL
0x1360330 (*info*): forced window start
redisplay_preserve_echo_area (8)
redisplay_internal 0
redisplay_preserve_echo_area (8)
redisplay_internal 0
redisplay_internal 0 <= START THIRD SCROLL (BROKEN)
redisplay_internal 0
0x1360330 (*info*): recenter
redisplay_preserve_echo_area (8)
redisplay_internal 0
redisplay_preserve_echo_area (8)
redisplay_internal 0
redisplay_internal 0

The third scroll should have reached the start of the buffer, but
recenters instead of doing so.

Furthermore, I found that reverting the following commit fixes the
issue locally, in a build of emacs-25:

* 9135bd7..: Paul Eggert 2016-05-13 Improve display of tex-verbatim and Info quoted
commit 9135bd7af7bdf9f805b185a77fe4e6d33dec4009
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Fri May 13 13:30:33 2016 -0700

   Improve display of tex-verbatim and Info quoted

   Problem reported by Glenn Morris (Bug#19889).
   * doc/emacs/display.texi (Standard Faces):
   * doc/lispref/display.texi (Basic Faces):
   * etc/NEWS: Mention fixed-pitch-serif.
   * lisp/faces.el (face-font-family-alternatives):
   New family alias Monospace Serif.
   (fixed-pitch-serif): New face, which uses the new family.
   * lisp/info.el (Info-quoted):
   * lisp/textmodes/tex-mode.el (tex-verbatim): Use the new face.
   * test/lisp/legacy/font-parse-tests.el (font-parse-tests--data):
   Add test case for Monospace Serif.

   This is backport from master
   (cherry picked from commit 36906806ccfc0e53f1d8c365ab0d7151288b7833)

  doc/emacs/display.texi             |    3 +++
  doc/lispref/display.texi           |    1 +
  etc/NEWS                           |    5 +++++
  lisp/faces.el                      |   29 +++++++++++++++++++++++++++++
  lisp/info.el                       |    2 +-
  lisp/textmodes/tex-mode.el         |    3 +--
  test/automated/font-parse-tests.el |    1 +
  7 files changed, 41 insertions(+), 3 deletions(-)

So it may be that the new choice of fonts exposes a bug in the
scrolling mechanism.

Finally, I tried to make some analysis (by setting a breakpoint on
function "redisplay_window" in GDB) of why the recentering happens
while scrolling.  I then did the same analysis after having checked
out the commit prior to the problematic one, and compared the code
path.  It may well be of no use, but I include it here in case:

When causing the problematic behavior, redisplay_window reaches
try_to_scroll via this if statement:

       if (!cursor_row_fully_visible_p (w, false, false))
	{
	  /* Point does appear, but on a line partly visible at end of window.
	     Move it back to a fully-visible line.  */
	  new_vpos = window_box_height (w);
	  /* But if window_box_height suggests a Y coordinate that is
	     not less than we already have, that line will clearly not
	     be fully visible, so give up and scroll the display.
	     This can happen when the default face uses a font whose
	     dimensions are different from the frame's default
	     font.  */
	  if (new_vpos >= w->cursor.y)
	    {
	      w->cursor.vpos = -1;
	      clear_glyph_matrix (w->desired_matrix);
	      goto try_to_scroll;
	    }
	}

That is, (!cursor_row_fully_visible_p (w, false, false)) and
(new_vpos >= w->cursor.y) evaluate to true.

try_to_scroll looks like this:

  try_to_scroll:

   /* Redisplay the mode line.  Select the buffer properly for that.  */
   if (!update_mode_line)
     {
       update_mode_line = true;
       w->update_mode_line = true;
     }

   if ((scroll_conservatively
        || emacs_scroll_step
        || temp_scroll_step
        || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))
        || NUMBERP (BVAR (current_buffer, scroll_down_aggressively)))
       && CHARPOS (startp) >= BEGV
       && CHARPOS (startp) <= ZV)
     {
       /* The function returns -1 if new fonts were loaded, 1 if
	 successful, 0 if not successful.  */
       int ss = try_scrolling (window, just_this_one_p,
			      scroll_conservatively,
			      emacs_scroll_step,
			      temp_scroll_step, last_line_misfit);
       switch (ss)
	{
	case SCROLLING_SUCCESS:
	  goto done;

	case SCROLLING_NEED_LARGER_MATRICES:
	  goto need_larger_matrices;

	case SCROLLING_FAILED:
	  break;

	default:
	  emacs_abort ();
	}
     }

   /* Finally, just choose a place to start which positions point
      according to user preferences.  */

  recenter:

#ifdef GLYPH_DEBUG
   debug_method_add (w, "recenter");
#endif

   ...

However, these checks are all false during the scroll:

        (scroll_conservatively
        || emacs_scroll_step
        || temp_scroll_step
        || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))
        || NUMBERP (BVAR (current_buffer, scroll_down_aggressively)))

so control falls through to the "recenter" label.

When I execute the same scroll command (from the same point and window
scroll state) in the commit prior to the problematic one, then the if
expression,

if (!cursor_row_fully_visible_p (w, false, false))

evaluates to false instead, control flow leads elsewhere, and the bug
does not happen.






  reply	other threads:[~2017-11-21 19:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 19:41 bug#29325: 26.0.90: Info scrolling stuck Charles A. Roelli
2017-11-16 19:47 ` Eli Zaretskii
2017-11-16 20:45   ` Charles A. Roelli
2017-11-17  7:11     ` Eli Zaretskii
2017-11-19 16:49       ` Charles A. Roelli
2017-11-19 17:12         ` Eli Zaretskii
2017-11-20 19:52           ` Charles A. Roelli
2017-11-20 20:25             ` Eli Zaretskii
2017-11-21 19:24               ` Charles A. Roelli [this message]
2017-11-21 19:42                 ` Eli Zaretskii
2017-11-21 19:58                   ` Eli Zaretskii
2017-11-22 15:38                   ` Eli Zaretskii
2017-11-22 19:04                     ` Charles A. Roelli
2017-11-23 20:08                     ` Charles A. Roelli
2017-11-23 20:31                       ` Eli Zaretskii
2017-11-22 18:56                   ` Charles A. Roelli
     [not found] <<m2efoyvwoa.fsf@aurox.ch>
2017-11-16 22:35 ` Drew Adams

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=m23757wi3u.fsf@aurox.ch \
    --to=charles@aurox.ch \
    --cc=29325@debbugs.gnu.org \
    --cc=eliz@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.