From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#47895: 28.0.50; Emacs should only animate images that are visible Date: Sun, 25 Apr 2021 22:01:28 +0300 Message-ID: <834kfukx2v.fsf@gnu.org> References: <87r1j6m920.fsf@gnus.org> <8335vmrux2.fsf@gnu.org> <87mttum230.fsf@gnus.org> <83r1j5qd2x.fsf@gnu.org> <87v98ajj3k.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33646"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47895@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 25 21:02:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lak1C-0008dh-Bo for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Apr 2021 21:02:10 +0200 Original-Received: from localhost ([::1]:50188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lak1B-0002IY-48 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Apr 2021 15:02:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lak14-0002I8-MF for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2021 15:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lak14-0008IE-F2 for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2021 15:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lak14-00065q-DM for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2021 15:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Apr 2021 19:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47895 X-GNU-PR-Package: emacs Original-Received: via spool by 47895-submit@debbugs.gnu.org id=B47895.161937731823199 (code B ref 47895); Sun, 25 Apr 2021 19:02:02 +0000 Original-Received: (at 47895) by debbugs.gnu.org; 25 Apr 2021 19:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:43827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lak0z-00061n-9d for submit@debbugs.gnu.org; Sun, 25 Apr 2021 15:01:57 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lak0x-0005x9-Ij for 47895@debbugs.gnu.org; Sun, 25 Apr 2021 15:01:55 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41577) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lak0s-0008A1-AJ; Sun, 25 Apr 2021 15:01:50 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4834 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lak0q-0008At-6g; Sun, 25 Apr 2021 15:01:49 -0400 In-Reply-To: <87v98ajj3k.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 25 Apr 2021 20:48:47 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:204909 Archived-At: > From: Lars Ingebrigtsen > Cc: 47895@debbugs.gnu.org > Date: Sun, 25 Apr 2021 20:48:47 +0200 > > Hm... No, even without the force-update, Emacs uses 100% CPU. Beware: changing that might make the timer run more frequently, so you might see CPU usage soar even though Emacs does almost nothing. > (plist-put (cdr image) :animate-tardiness > (+ (* (plist-get (cdr image) :animate-tardiness) 0.9) > (float-time (time-since target-time)))) > > and then re-runs itself, it'll use 100% CPU. This seems to indicate > that any alteration of the image plist leads to Emacs re-computing the > image -- even if it isn't displayed? Both of these things seem > unexpected: 1) Altering a plist item that's not relevant for the display of > the image shouldn't lead to an image recomputation, and 2) if the image > isn't displayed, it shouldn't be recomputed anyway. We access a different frame of the GIF image, so that would mean regenerating the pixmap for the image, no? > > In this simple case, we could use > > > > (get-buffer-window (plist-get (cdr image) :animate-buffer) 'visible) > > > > in image-animate-timeout to see if the buffer is displayed in any > > window. The harder questions are: > > > > . if the buffer is not displayed, what to do with the timer? > > continue running it? if so, how to interpret the LIMIT arg? > > I'd keep interpreting that the same -- that is, count down, even if the > image isn't displayed. But then if and when the image becomes visible, it won't show the animation, because it already reached the LIMIT. Right? > > . what if the window _is_ displayed, but the image is not visible? > > I think we'd need to record the image's buffer position in its > > plist, so that we could use pos-visible-in-window-p to find out > > whether the image is visible > > Or just compute the position on each iteration -- the image may change > its position if more text is inserted, for instance. Sure, but even if the position doesn't change we currently cannot tell if the image is visible. We have pos-visible-in-window-p, but that needs a buffer position -- which is why I suggest to record that position in the image. > But I'm still wondering about why this doesn't just work > "automatically" -- if we could handle this in the redisplay code, that > would be more natural. Animation doesn't work in redisplay, it works in this code I pointed to.