GNU bug report logs - #69972
29.1; Unexpected behavior when scrolling images

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> ushin.org>

Date: Sun, 24 Mar 2024 09:13:02 UTC

Severity: normal

Tags: moreinfo

Found in version 29.1

To reply to this bug, email your comments to 69972 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Sun, 24 Mar 2024 09:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Joseph Turner <joseph <at> ushin.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 24 Mar 2024 09:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> ushin.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.1; Unexpected behavior when scrolling images
Date: Sun, 24 Mar 2024 02:07:16 -0700
When the image at point is larger than the current window and there is
no content after the image, interactively scrolling down (with the
scroll-up command) unexpectedly scrolls past the image to blankness.

Test this by evaluating the following snippet then interactively running
`scroll-up' repeatedly:

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil
    ;; Scale the image more if it doesn't take up the whole window.
    :scale 5))
  (goto-char (point-max))
  (pop-to-buffer (current-buffer)))

Even more unexpectedly, when point is before the image, running
`scroll-up' repeatedly eventually scrolls back to the top of the image:

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil :scale 5))
  (goto-char (point-min))
  (pop-to-buffer (current-buffer)))

Non-interactively, scroll-up scrolls the page down to the very bottom of
the image.  IMO this is the expected behavior:

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil :scale 5))
  (pop-to-buffer (current-buffer))
  (scroll-up 999))

Thank you for your help!!

Joseph

Tested on emacs -Q:

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37,
cairo version 1.16.0)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/v9p25q9l5nnaixkhpap5rnymmwbhf9rp-bash-minimal-5.1.16/bin/bash
 SHELL=/gnu/store/v9p25q9l5nnaixkhpap5rnymmwbhf9rp-bash-minimal-5.1.16/bin/bash
 --prefix=/gnu/store/f4gxh8n3libmywq8d5jvxxkyqblgilxy-emacs-29.1
 --enable-fast-install --with-cairo --with-modules
 --with-native-compilation=aot --disable-build-details'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Sun, 24 Mar 2024 09:44:01 GMT) Full text and rfc822 format available.

Message #8 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> ushin.org>
Cc: 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Sun, 24 Mar 2024 11:42:56 +0200
> Date: Sun, 24 Mar 2024 02:07:16 -0700
> From:  Joseph Turner via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> When the image at point is larger than the current window and there is
> no content after the image, interactively scrolling down (with the
> scroll-up command) unexpectedly scrolls past the image to blankness.

I cannot reproduce this, I think.

> Test this by evaluating the following snippet then interactively running
> `scroll-up' repeatedly:
> 
> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>   (erase-buffer)
>   (insert-image (create-image "splash.png" nil nil
>     ;; Scale the image more if it doesn't take up the whole window.
>     :scale 5))
>   (goto-char (point-max))
>   (pop-to-buffer (current-buffer)))

This recipe doesn't include the call to scroll-up, so I'm unsure how
you did that and what you saw.  When I try "M-: (scroll-up) RET" or
"M-x scroll-up RET", I get several scrolls by window-size, and then
"End of buffer" error when I hit the end of the buffer.  If this is
unexpected, please tell why.

> Even more unexpectedly, when point is before the image, running
> `scroll-up' repeatedly eventually scrolls back to the top of the image:
> 
> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>   (erase-buffer)
>   (insert-image (create-image "splash.png" nil nil :scale 5))
>   (goto-char (point-min))
>   (pop-to-buffer (current-buffer)))

I do see this, but why is that a problem?  You supposed to use
scroll-up-command instead, which handles these marginal cases much
better.  scroll-up itself is not smart enough to avoid the perceived
"scroll back to top", which is actually caused by the fact that we
zero out window-vscroll (which is how we handle scrolling past large
images).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Mon, 25 Mar 2024 01:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> ushin.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Sun, 24 Mar 2024 18:06:44 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Sun, 24 Mar 2024 02:07:16 -0700
>> From:  Joseph Turner via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> When the image at point is larger than the current window and there is
>> no content after the image, interactively scrolling down (with the
>> scroll-up command) unexpectedly scrolls past the image to blankness.
>
> I cannot reproduce this, I think.
>
>> Test this by evaluating the following snippet then interactively running
>> `scroll-up' repeatedly:
>>
>> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>>   (erase-buffer)
>>   (insert-image (create-image "splash.png" nil nil
>>     ;; Scale the image more if it doesn't take up the whole window.
>>     :scale 5))
>>   (goto-char (point-max))
>>   (pop-to-buffer (current-buffer)))
>
> This recipe doesn't include the call to scroll-up, so I'm unsure how
> you did that and what you saw.  When I try "M-: (scroll-up) RET" or
> "M-x scroll-up RET", I get several scrolls by window-size, and then
> "End of buffer" error when I hit the end of the buffer.  If this is
> unexpected, please tell why.

On my machine, I don't get "End of buffer" error.  I tested three
different ways in the following snippet

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil
    ;; Scale the image more if it doesn't take up the whole window.
    :scale 5))
  (goto-char (point-max))
  (pixel-scroll-precision-mode -1)  ; Ensure mouse wheel scroll up and down works
  (pop-to-buffer (current-buffer)))

1. "M-: (scroll-up) RET" (repeatedly)
2. C-v (repeatedly)
3. <wheel-down> (repeatedly)

With all three methods, at first Emacs gradually scrolls the image, but
then when I reach the bottom of the image, the image disappears entirely
as Emacs scrolls past it all at once.

>> Even more unexpectedly, when point is before the image, running
>> `scroll-up' repeatedly eventually scrolls back to the top of the image:
>>
>> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>>   (erase-buffer)
>>   (insert-image (create-image "splash.png" nil nil :scale 5))
>>   (goto-char (point-min))
>>   (pop-to-buffer (current-buffer)))
>
> I do see this, but why is that a problem?  You supposed to use
> scroll-up-command instead, which handles these marginal cases much
> better.  scroll-up itself is not smart enough to avoid the perceived
> "scroll back to top", which is actually caused by the fact that we
> zero out window-vscroll (which is how we handle scrolling past large
> images).

You're right.  This is not a problem in practice.  When point is before
the image, both C-v and <wheel-down> produce the same behavior as above.

Joseph




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Mon, 25 Mar 2024 08:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> ushin.org>
To: Eli Zaretskii <eliz <at> gnu.org>, 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Mon, 25 Mar 2024 01:34:40 -0700
Joseph Turner <joseph <at> ushin.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> Date: Sun, 24 Mar 2024 02:07:16 -0700
>>> From:  Joseph Turner via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>>
>>> When the image at point is larger than the current window and there is
>>> no content after the image, interactively scrolling down (with the
>>> scroll-up command) unexpectedly scrolls past the image to blankness.
>>
>> I cannot reproduce this, I think.
>>
>>> Test this by evaluating the following snippet then interactively running
>>> `scroll-up' repeatedly:
>>>
>>> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>>>   (erase-buffer)
>>>   (insert-image (create-image "splash.png" nil nil
>>>     ;; Scale the image more if it doesn't take up the whole window.
>>>     :scale 5))
>>>   (goto-char (point-max))
>>>   (pop-to-buffer (current-buffer)))
>>
>> This recipe doesn't include the call to scroll-up, so I'm unsure how
>> you did that and what you saw.  When I try "M-: (scroll-up) RET" or
>> "M-x scroll-up RET", I get several scrolls by window-size, and then
>> "End of buffer" error when I hit the end of the buffer.  If this is
>> unexpected, please tell why.
>
> On my machine, I don't get "End of buffer" error.

Correction - I *do* get "End of buffer" error, but only after fully
scrolling past the image (which IMO is unexpected).

> I tested three different ways in the following snippet
>
> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>   (erase-buffer)
>   (insert-image (create-image "splash.png" nil nil
>     ;; Scale the image more if it doesn't take up the whole window.
>     :scale 5))
>   (goto-char (point-max))
>   (pixel-scroll-precision-mode -1)  ; Ensure mouse wheel scroll up and down works
>   (pop-to-buffer (current-buffer)))
>
> 1. "M-: (scroll-up) RET" (repeatedly)
> 2. C-v (repeatedly)
> 3. <wheel-down> (repeatedly)
>
> With all three methods, at first Emacs gradually scrolls the image, but
> then when I reach the bottom of the image, the image disappears entirely
> as Emacs scrolls past it all at once.
>
>>> Even more unexpectedly, when point is before the image, running
>>> `scroll-up' repeatedly eventually scrolls back to the top of the image:
>>>
>>> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>>>   (erase-buffer)
>>>   (insert-image (create-image "splash.png" nil nil :scale 5))
>>>   (goto-char (point-min))
>>>   (pop-to-buffer (current-buffer)))
>>
>> I do see this, but why is that a problem?  You supposed to use
>> scroll-up-command instead, which handles these marginal cases much
>> better.  scroll-up itself is not smart enough to avoid the perceived
>> "scroll back to top", which is actually caused by the fact that we
>> zero out window-vscroll (which is how we handle scrolling past large
>> images).
>
> You're right.  This is not a problem in practice.  When point is before
> the image, both C-v and <wheel-down> produce the same behavior as above.
>
> Joseph





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Mon, 25 Mar 2024 16:00:04 GMT) Full text and rfc822 format available.

Message #17 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> ushin.org>
Cc: 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Mon, 25 Mar 2024 14:23:28 +0200
> From: Joseph Turner <joseph <at> ushin.org>
> Cc: 69972 <at> debbugs.gnu.org
> Date: Sun, 24 Mar 2024 18:06:44 -0700
> 
> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>   (erase-buffer)
>   (insert-image (create-image "splash.png" nil nil
>     ;; Scale the image more if it doesn't take up the whole window.
>     :scale 5))
>   (goto-char (point-max))
>   (pixel-scroll-precision-mode -1)  ; Ensure mouse wheel scroll up and down works
>   (pop-to-buffer (current-buffer)))
> 
> 1. "M-: (scroll-up) RET" (repeatedly)
> 2. C-v (repeatedly)
> 3. <wheel-down> (repeatedly)
> 
> With all three methods, at first Emacs gradually scrolls the image, but
> then when I reach the bottom of the image, the image disappears entirely
> as Emacs scrolls past it all at once.

Why is that a problem?  The default Emacs scrolling commands don't
guarantee smooth constant-rate scrolling, they guarantee only that you
get to see all the portions of the image, without missing any.  So
when you get to the end of the image, there's a heuristic that decides
whether we can scroll past the image, and that is what you see.

I see no bug here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Wed, 27 Mar 2024 21:59:01 GMT) Full text and rfc822 format available.

Message #20 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Joseph Turner <joseph <at> ushin.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Mon, 25 Mar 2024 12:43:39 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Joseph Turner <joseph <at> ushin.org>
>> Cc: 69972 <at> debbugs.gnu.org
>> Date: Sun, 24 Mar 2024 18:06:44 -0700
>>
>> 1. "M-: (scroll-up) RET" (repeatedly)
>> 2. C-v (repeatedly)
>> 3. <wheel-down> (repeatedly)
>>
>> With all three methods, at first Emacs gradually scrolls the image, but
>> then when I reach the bottom of the image, the image disappears entirely
>> as Emacs scrolls past it all at once.
>
> Why is that a problem?  The default Emacs scrolling commands don't
> guarantee smooth constant-rate scrolling, they guarantee only that you
> get to see all the portions of the image, without missing any.  So
> when you get to the end of the image, there's a heuristic that decides
> whether we can scroll past the image, and that is what you see.
>
> I see no bug here.

With pixel-scroll-precision-mode enabled and at least one character after
the image, I am able to smoothly scroll around the image.

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil :scale 10))
  (insert " ") ;; There must be some text after the image
  (goto-char (point-min))
  (pixel-scroll-precision-mode 1)
  (pop-to-buffer (current-buffer)))

However, if the window is scrolled to the right, then it is impossible
to scroll down:

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil :scale 10))
  (insert-char 8203)
  (goto-char (point-min))
  (pixel-scroll-precision-mode 1)
  (pop-to-buffer (current-buffer))
  (set-window-hscroll (get-buffer-window) 1)) ;; Image scrolled to right

In this buffer, if I attempt to scroll down with the mouse wheel, I
immediately get "End of buffer" error and the image does not move.

Thank you!

Joseph




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Thu, 28 Mar 2024 06:25:02 GMT) Full text and rfc822 format available.

Message #23 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Joseph Turner <joseph <at> ushin.org>, Po Lu <luangruo <at> yahoo.com>
Cc: 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Thu, 28 Mar 2024 08:24:20 +0200
> From: Joseph Turner <joseph <at> ushin.org>
> Cc: 69972 <at> debbugs.gnu.org
> Date: Mon, 25 Mar 2024 12:43:39 -0700
> 
> >> With all three methods, at first Emacs gradually scrolls the image, but
> >> then when I reach the bottom of the image, the image disappears entirely
> >> as Emacs scrolls past it all at once.
> >
> > Why is that a problem?  The default Emacs scrolling commands don't
> > guarantee smooth constant-rate scrolling, they guarantee only that you
> > get to see all the portions of the image, without missing any.  So
> > when you get to the end of the image, there's a heuristic that decides
> > whether we can scroll past the image, and that is what you see.
> >
> > I see no bug here.
> 
> With pixel-scroll-precision-mode enabled and at least one character after
> the image, I am able to smoothly scroll around the image.

pixel-scroll-precision-mode indeed attempts to make the scrolling much
more smooth than the default scrolling in these cases.

> However, if the window is scrolled to the right, then it is impossible
> to scroll down:
> 
> (with-current-buffer (get-buffer-create "*test-scroll-image*")
>   (erase-buffer)
>   (insert-image (create-image "splash.png" nil nil :scale 10))
>   (insert-char 8203)
>   (goto-char (point-min))
>   (pixel-scroll-precision-mode 1)
>   (pop-to-buffer (current-buffer))
>   (set-window-hscroll (get-buffer-window) 1)) ;; Image scrolled to right
> 
> In this buffer, if I attempt to scroll down with the mouse wheel, I
> immediately get "End of buffer" error and the image does not move.

Then maybe Po Lu (CC'ed) could look into this and see if
pixel-scroll-precision-mode could do better in this case.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Thu, 28 Mar 2024 11:13:01 GMT) Full text and rfc822 format available.

Message #26 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Joseph Turner <joseph <at> ushin.org>, 69972 <at> debbugs.gnu.org
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Thu, 28 Mar 2024 19:12:09 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> Then maybe Po Lu (CC'ed) could look into this and see if
> pixel-scroll-precision-mode could do better in this case.

Thanks.  I think a solution to the OP's problem was proposed in a
previous bug report and we're still awaiting feedback, though at the
moment I don't have its bug number at hand.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69972; Package emacs. (Sat, 01 Mar 2025 03:06:02 GMT) Full text and rfc822 format available.

Message #29 received at 69972 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: Joseph Turner <joseph <at> ushin.org>, 69972 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#69972: 29.1; Unexpected behavior when scrolling images
Date: Fri, 28 Feb 2025 19:05:17 -0800
Po Lu <luangruo <at> yahoo.com> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> Then maybe Po Lu (CC'ed) could look into this and see if
>> pixel-scroll-precision-mode could do better in this case.
>
> Thanks.  I think a solution to the OP's problem was proposed in a
> previous bug report and we're still awaiting feedback, though at the
> moment I don't have its bug number at hand.

Was that patch ever installed?




Added tag(s) moreinfo. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 01 Mar 2025 03:06:03 GMT) Full text and rfc822 format available.

This bug report was last modified 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.