From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74537: [PATCH] An on-disk image modification does a cache miss Date: Tue, 10 Dec 2024 17:42:56 +0100 Message-ID: <87msh3h4kv.fsf@ledu-giraud.fr> References: <87ed2z6m7q.fsf@ledu-giraud.fr> <86plmiglyx.fsf@gnu.org> <87r06x4z84.fsf@ledu-giraud.fr> <86v7w8g3rb.fsf@gnu.org> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12970"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74537@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 10 17:44:25 2024 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 1tL3LU-0003EH-Kg for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Dec 2024 17:44:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tL3LA-0007Dq-VD; Tue, 10 Dec 2024 11:44:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL3L9-0007Cs-5n for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 11:44:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tL3L8-0002tt-Lq for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 11:44:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=Ok7xxyQRJ/U2sbFcJEhVK+/lzs8cZ9AKn5LQpxzF8rM=; b=IvnZSlgNLzg52QG1Of8rLJMZWag8qqA8ze3++F9sP6OLU2ZPxy0mMrKzEpAP+i7GdEZXUzelq8nmdEcbTsY/8zwNSUec2YjxmX38fJKvV8t1BLmtyRiPl5V/QmPCxFyfONrC8H5j6zrI1kXC2RUXEefQBhQjk3MBs8EW5GSEoyoCYxYp8R7/eqBMv0pIVxVxoZ/P4F7c+Zajx1PiVgrsIbpaK/AzWej7jvVBf/Ag6ngWtVJRzj9u5dUjqH03CnIsyOPZLPoIeONQHDlooP7FHcpqABZbu0CifV/duTMpTTA+DrXfko2wvRbkmji2m3QqcETZ8SeHTAvOYHzJhq21lg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tL3L8-0005Dy-5s for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 11:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Dec 2024 16:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74537 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74537-submit@debbugs.gnu.org id=B74537.173384898219831 (code B ref 74537); Tue, 10 Dec 2024 16:44:02 +0000 Original-Received: (at 74537) by debbugs.gnu.org; 10 Dec 2024 16:43:02 +0000 Original-Received: from localhost ([127.0.0.1]:59275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL3KA-00059Y-24 for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:43:02 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:13280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL3K7-000593-Ci for 74537@debbugs.gnu.org; Tue, 10 Dec 2024 11:43:01 -0500 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=FywSDf31 s+p/GhMKTPMp/mmIR6WSrD5ZaWYYn0rvwTc=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=iImjsNloBx8OVuI1q01fZN+Bu1K4c9 6tzV4R2dpxTb4I3pXt7JkoAnekPc4O5nfzdo6mmcbDaWLzhLJB2SwdBw== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=FywSDf31s+p/GhMK TPMp/mmIR6WSrD5ZaWYYn0rvwTc=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=ZI8SdG+egaXa4t3eNCBAumIu+eb9S8yzSP+J/z HAP7Nid5R+G+E+KO2cdcIqSSJ3hpMqaWgOqN7owQrrAJqKptr5rPD8FBdrtPQwqof1jeVr k6snYhr+S5w8Hd3Qmp4G7yx7fj7nR6EIk0j0GECYe443mm5A+2jbhnpIL6MlL63U6cZVv5 FdDBr8/BfC6qXKEfs2MkPV1GvwD/qWeQs2FqJqYWXq/0Ui9Fv18hMk2Vn+tSJR8hTJMMdQ Zf7c83xAqZs46yHgl6TK/GGipSChkNnTnVF6u2N5SE73bhl/jI+dkqO/JeM0sLvGrviLp+ 4Iagxt6B6xtzgpZUipz9alRw== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id b2aa17dd (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 10 Dec 2024 17:42:57 +0100 (CET) In-Reply-To: <86v7w8g3rb.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 27 Nov 2024 16:17:28 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296768 Archived-At: Eli Zaretskii writes: >> From: Manuel Giraud >> Cc: 74537@debbugs.gnu.org >> Date: Tue, 26 Nov 2024 19:38:35 +0100 >> >> Eli Zaretskii writes: >> >> > So this change could have weird confusing effects, whereby the fact >> > that the image was modified on disk becomes apparent only after some >> > display-related actions, but not after others. For example, scrolling >> > a window by a small amount will not notice the change on disk, whereas >> > significant changes, especially when the image goes off the window and >> > back into it, will show the change. Don't you see such issues if you >> > install the change? >> >> I've tried a bit with image-mode and also with something like: >> >> (insert (propertize "f" 'display '(image :file "/tmp/foo.jpg" :type jpeg :width 100))) >> >> and, yes, I can see the behavior you describe. But I also can't really >> see why it is a problem: the image has changed! At one point it should >> be reflected in Emacs, no? > > First, that isn't always true. Consider a file visited in some Emacs > buffer -- we don't revert it automatically when the visited file on > disk changes, do we? We have commands and minor modes to do that, but > they are optional. Why should images be different? > > But yes, it would be good to have a mode and command(s) to update the > images when/if they were modified. We just must be sure we update > _all_ of them, so if an image is displayed in several buffers/windows, > the update affects all of them. Otherwise we will have weird bugs > like the one above. And since the display engine has its own ideas > for when to perform a thorough redisplay and when flush the image > cache, these bugs will be hard to reproduce and debug. > > My point is that, since the display engine goes out of its way to try > not to do stuff that isn't necessary, it will not "re-lookup_image" if > it has no reason to believe what's on display is outdated. The image > cache is there to make redisplay of windows showing images faster. > What you want here is to disable some of these optimizations under > certain circumstances, but that must be done correctly, to avoid > incorrect/inaccurate/confusing display. > >> This I've tried with: >> >> (insert (propertize "foo" 'display '(space :width (0.1 . (image :file "/tmp/foo.jpg" :type jpeg))))) >> >> and also the re-alignment occurs at /some/ point. But likewise, I fail >> to see why this is a problem. > > It is a problem because what the Lisp program which used such a > property wanted (alignment on display) will not happen, since the > image on display and the one you generate by calling lookup_image in > the above scenario might have different metrics. What we must somehow > do in this case (assuming the user indeed wants the images to > immediately reflect their disk file changes) is to update the image on > display as well. One way of doing that is to perform a complete > redisplay of each window which shows the image. I'm not sure, but it > could be the only way, which means such updates will be somewhat > expensive if one has many windows with the image. (One trivial case > where an image is displayed many times is the tool bar, when you have > many frames. Another case could be the mode line.) > >> After all, maybe I'm a bit partial to image-mode with this patch. I >> think my idea was to eventually get rid of the systematic `image-flush' >> call in "image-mode.el" to make it beneficiate from the image cache more >> and still be able to display the correct image. > > Sorry, I don't understand: the patch you posted effectively flushes > the cache more often, so how is it more beneficial to users of the > cache? It flushes the cache iff the on-disk image has changed (which is, of course, rare)... I think this all boils down to the fact that I don't really understand the purpose of the `image-flush' call in image-mode.el -- Manuel Giraud