bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29325: 26.0.90: Info scrolling stuck


From: Charles A. Roelli
Subject: bug#29325: 26.0.90: Info scrolling stuck
Date: Tue, 21 Nov 2017 20:24:05 +0100

> Date: Mon, 20 Nov 2017 22:25:33 +0200
> From: Eli Zaretskii <address@hidden>
> 
> > Date: Mon, 20 Nov 2017 20:52:39 +0100
> > From: address@hidden (Charles A. Roelli)
> > CC: address@hidden
> > 
> > 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 <address@hidden>
> 
> 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 <address@hidden>
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 via email to

[Prev in Thread] Current Thread [Next in Thread]