Subject: bug#45628: 28.0.50; Scrolling on echo area with pixel-scroll-mode enabled locks up Emacs

From: Tak Kunihiro <[email-masked]>
Date: Mon, 4 Jan 2021 17:57:48 +0900

>> As the Subject says, scrolling using the mouse wheel on the echo area
>> causes Emacs to freeze/lock up (cursor is changed to spinning circle),
>> when pixel-scroll-mode is enabled.
> 
> Tak, can you please look into this?  The code infloops inside
> pixel-scroll-down, here:
> 
>        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
>          (vertical-motion -1))              ; move point upward
> 
> because the mini-window is normally just one screen line high, so its
> top and bottom coincide.
> 
> Shouldn't we exit the loop when vertical-motion returns zero, which
> means it didn't move?
> 
> A similar loop exists in pixel-scroll-up, AFAICS.

Thank you to shoot the problem. 
I confirmed the problem and Eli's suggestion solves it.

I think that following patch would work but usage of `while’
does not look cool.  If there can is better style, please
suggest me.

diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index cc0e159fae..c266c54a06 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -132,8 +132,8 @@ pixel-scroll-up
                    (pixel-line-height))))
         (if (pixel-eob-at-top-p)      ; when end-of-the-buffer is close
             (scroll-up 1)             ; relay on robust method
-          (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
-            (vertical-motion 1))            ; move point downward
+          (while (and (pixel-point-at-top-p amt) ; prevent too late (multi tries)
+                      (equal (vertical-motion 1) 1))) ; move point downward
           (pixel-scroll-pixel-up amt))))))  ; move scope downward
 
 (defun pixel-scroll-down (&optional arg)
@@ -149,8 +149,8 @@ pixel-scroll-down
                          pixel-resolution-fine-flag
                        (frame-char-height))
                    (pixel-line-height -1))))
-        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
-          (vertical-motion -1))              ; move point upward
+        (while (and (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
+                    (equal (vertical-motion -1) -1))) ; move point upward
         (if (or (pixel-bob-at-top-p amt) ; when beginning-of-the-buffer is seen
                 (pixel-eob-at-top-p))    ; for file with a long line
             (scroll-down 1)              ; relay on robust method